Skip to content

Commit 7f8a2b5

Browse files
committed
Merge branch 'release/v0.2.3'
2 parents 89b4797 + b16db24 commit 7f8a2b5

File tree

22 files changed

+243
-84
lines changed

22 files changed

+243
-84
lines changed

app/libs/clansFAB.aar

1.16 KB
Binary file not shown.

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/CardActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ class CardActivity : BaseActivity() {
9595
if (App.hasUserLogged()) {
9696
PrivateInteractor().setUserCardFavorite(card, !favorite) {
9797
favorite = !favorite
98-
MetricsManager.trackAction(if (favorite) MetricAction.ACTION_CARD_DETAILS_FAVORITE()
99-
else MetricAction.ACTION_CARD_DETAILS_UNFAVORITE())
10098
val stringRes = if (favorite) R.string.card_favorited else R.string.card_unfavorited
10199
toast(getString(stringRes, card.name))
102100
loadCardInfo()
103101
setResult(Activity.RESULT_OK, Intent())
102+
MetricsManager.trackAction(if (favorite)
103+
MetricAction.ACTION_CARD_DETAILS_FAVORITE() else MetricAction.ACTION_CARD_DETAILS_UNFAVORITE())
104104
}
105105
} else {
106106
showErrorUserNotLogged()

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import android.view.Menu
1919
import android.view.MenuItem
2020
import android.view.View
2121
import android.view.ViewGroup
22+
import android.widget.RelativeLayout
2223
import com.bumptech.glide.Glide
2324
import com.ediposouza.teslesgendstracker.App
2425
import com.ediposouza.teslesgendstracker.R
@@ -30,20 +31,15 @@ import com.ediposouza.teslesgendstracker.interactor.PublicInteractor
3031
import com.ediposouza.teslesgendstracker.ui.base.BaseActivity
3132
import com.ediposouza.teslesgendstracker.ui.base.CmdShowSnackbarMsg
3233
import com.ediposouza.teslesgendstracker.ui.util.CircleTransform
33-
import com.ediposouza.teslesgendstracker.util.MetricScreen
34-
import com.ediposouza.teslesgendstracker.util.MetricsManager
35-
import com.ediposouza.teslesgendstracker.util.inflate
36-
import com.ediposouza.teslesgendstracker.util.toggleExpanded
34+
import com.ediposouza.teslesgendstracker.ui.util.KeyboardUtil
35+
import com.ediposouza.teslesgendstracker.util.*
3736
import com.google.firebase.auth.FirebaseAuth
3837
import io.fabric.sdk.android.services.common.CommonUtils
3938
import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator
4039
import kotlinx.android.synthetic.main.activity_deck.*
4140
import kotlinx.android.synthetic.main.include_deck_info.*
4241
import kotlinx.android.synthetic.main.itemlist_deck_comment.view.*
43-
import org.jetbrains.anko.alert
44-
import org.jetbrains.anko.doAsync
45-
import org.jetbrains.anko.intentFor
46-
import org.jetbrains.anko.toast
42+
import org.jetbrains.anko.*
4743
import org.threeten.bp.format.DateTimeFormatter
4844
import timber.log.Timber
4945
import java.text.NumberFormat
@@ -67,6 +63,7 @@ class DeckActivity : BaseActivity() {
6763

6864
private val publicInteractor by lazy { PublicInteractor() }
6965
private val privateInteractor by lazy { PrivateInteractor() }
66+
private val keyboardUtil by lazy { KeyboardUtil(this, contentView) }
7067
private val deckOwned by lazy { intent.getBooleanExtra(EXTRA_OWNED, false) }
7168
private val deck: Deck by lazy { intent.getParcelableExtra<Deck>(EXTRA_DECK) }
7269
private val numberInstance: NumberFormat by lazy { NumberFormat.getNumberInstance() }
@@ -79,32 +76,53 @@ class DeckActivity : BaseActivity() {
7976
override fun onCreate(savedInstanceState: Bundle?) {
8077
super.onCreate(savedInstanceState)
8178
setContentView(R.layout.activity_deck)
82-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
79+
val statusBarHeight = resources.getDimensionPixelSize(R.dimen.status_bar_height)
80+
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
81+
val coverLP = deck_class_cover.layoutParams as RelativeLayout.LayoutParams
82+
coverLP.height = coverLP.height - statusBarHeight
83+
deck_class_cover.layoutParams = coverLP
84+
}
85+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
8386
val layoutParams = toolbar.layoutParams as CollapsingToolbarLayout.LayoutParams
84-
layoutParams.topMargin = resources.getDimensionPixelSize(R.dimen.status_bar_height)
87+
layoutParams.topMargin = statusBarHeight
8588
toolbar.layoutParams = layoutParams
8689
}
8790

8891
favorite = intent.getBooleanExtra(EXTRA_FAVORITE, false)
8992
like = intent.getBooleanExtra(EXTRA_LIKE, false)
93+
configViews()
94+
updateFavoriteItem()
95+
loadDeckInfo()
96+
}
97+
98+
private fun configViews() {
9099
deck_fab_favorite.setOnClickListener {
91100
if (App.hasUserLogged()) {
92101
privateInteractor.setUserDeckFavorite(deck, !favorite) {
93102
favorite = !favorite
94103
updateFavoriteItem()
104+
MetricsManager.trackAction(if (favorite)
105+
MetricAction.ACTION_DECK_DETAILS_FAVORITE() else MetricAction.ACTION_DECK_DETAILS_UNFAVORITE())
95106
}
96107
} else {
97108
showErrorUserNotLogged()
98109
}
99110
}
100-
deck_bottom_sheet.setOnClickListener { commentsSheetBehavior.toggleExpanded() }
101-
updateFavoriteItem()
102-
loadDeckInfo()
103-
}
111+
commentsSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
112+
override fun onSlide(bottomSheet: View, slideOffset: Float) {
113+
}
104114

105-
override fun onPostCreate(savedInstanceState: Bundle?) {
106-
super.onPostCreate(savedInstanceState)
107-
supportActionBar?.setDisplayHomeAsUpEnabled(true)
115+
override fun onStateChanged(bottomSheet: View, newState: Int) {
116+
when (newState) {
117+
BottomSheetBehavior.STATE_EXPANDED ->
118+
MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_EXPAND())
119+
BottomSheetBehavior.STATE_COLLAPSED ->
120+
MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_COLLAPSE())
121+
}
122+
}
123+
124+
})
125+
deck_bottom_sheet.setOnClickListener { commentsSheetBehavior.toggleExpanded() }
108126
deck_comment_send?.setOnClickListener {
109127
if (App.hasUserLogged()) {
110128
if (deck_comment_new.text.toString().length < 4) {
@@ -114,12 +132,18 @@ class DeckActivity : BaseActivity() {
114132
PrivateInteractor().addDeckComment(deck, deck_comment_new.text.toString()) {
115133
deck_comment_new.setText("")
116134
addComment(it)
135+
MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_SEND())
117136
}
118137
}
119138
} else {
120139
showErrorUserNotLogged()
121140
}
122141
}
142+
}
143+
144+
override fun onPostCreate(savedInstanceState: Bundle?) {
145+
super.onPostCreate(savedInstanceState)
146+
supportActionBar?.setDisplayHomeAsUpEnabled(true)
123147
onKeyboardVisibilityChange = {
124148
deck_comment_recycle_view.requestLayout()
125149
}
@@ -146,6 +170,16 @@ class DeckActivity : BaseActivity() {
146170
}
147171
}
148172

173+
override fun onStart() {
174+
super.onStart()
175+
keyboardUtil.enable()
176+
}
177+
178+
override fun onStop() {
179+
super.onStop()
180+
keyboardUtil.disable()
181+
}
182+
149183
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
150184
menuInflater.inflate(if (deckOwned) R.menu.menu_deck_owner else R.menu.menu_deck, menu)
151185
menuLike = menu?.findItem(R.id.menu_like)
@@ -169,6 +203,8 @@ class DeckActivity : BaseActivity() {
169203
updateLikeItem()
170204
val deckLikes = Integer.parseInt(deck_details_likes.text.toString())
171205
deck_details_likes.text = numberInstance.format(deckLikes + if (like) 1 else -1)
206+
MetricsManager.trackAction(if (like)
207+
MetricAction.ACTION_DECK_DETAILS_LIKE() else MetricAction.ACTION_DECK_DETAILS_UNLIKE())
172208
}
173209
return true
174210
}
@@ -179,6 +215,7 @@ class DeckActivity : BaseActivity() {
179215
privateInteractor.deleteDeck(deck, deck.private) {
180216
toast(R.string.deck_deleted)
181217
ActivityCompat.finishAfterTransition(this@DeckActivity)
218+
MetricsManager.trackAction(MetricAction.ACTION_DECK_DETAILS_DELETE())
182219
}
183220
})
184221
setTheme(R.style.AppDialog)

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsAllFragment.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ open class CardsAllFragment : BaseFragment() {
130130
fun onCmdShowCardsByAttr(showCardsByAttr: CmdShowCardsByAttr) {
131131
loadCardsByAttr(showCardsByAttr.attr)
132132
if (isFragmentSelected) {
133-
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_ATTR(), showCardsByAttr.attr.name)
133+
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_ATTR(showCardsByAttr.attr))
134134
}
135135
}
136136

@@ -145,8 +145,7 @@ open class CardsAllFragment : BaseFragment() {
145145
classFilter = filterClass.cls
146146
showCards()
147147
if (isFragmentSelected) {
148-
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_SET(),
149-
setFilter?.name ?: MetricAction.ACTION_CARD_FILTER_SET.VALUE_CLEAR)
148+
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_SET(setFilter))
150149
}
151150
}
152151

@@ -161,8 +160,7 @@ open class CardsAllFragment : BaseFragment() {
161160
rarityFilter = filterRarity.rarity
162161
showCards()
163162
if (isFragmentSelected) {
164-
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_RARITY(),
165-
rarityFilter?.name ?: MetricAction.ACTION_CARD_FILTER_RARITY.VALUE_CLEAR)
163+
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_RARITY(rarityFilter))
166164
}
167165
}
168166

@@ -171,8 +169,7 @@ open class CardsAllFragment : BaseFragment() {
171169
magikaFilter = filterMagika.magika
172170
showCards()
173171
if (isFragmentSelected) {
174-
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_MAGIKA(), if (magikaFilter >= 0)
175-
magikaFilter.toString() else MetricAction.ACTION_CARD_FILTER_MAGIKA.VALUE_CLEAR)
172+
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_MAGIKA(magikaFilter))
176173
}
177174
}
178175

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsCollectionFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class CardsCollectionFragment : CardsAllFragment() {
108108
cards_recycler_view?.itemAnimator = null
109109
cardsCollectionAdapter.updateSlot(cardSlot, finalQtd)
110110
view_statistics.updateStatistics(currentAttr)
111-
MetricsManager.trackAction(MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE(), finalQtd.toString())
111+
MetricsManager.trackAction(MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE(finalQtd))
112112
}
113113
}
114114

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/new/NewDeckActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.ediposouza.teslesgendstracker.ui.cards.CmdFilterMagika
2323
import com.ediposouza.teslesgendstracker.ui.cards.CmdFilterRarity
2424
import com.ediposouza.teslesgendstracker.ui.decks.CmdAddCard
2525
import com.ediposouza.teslesgendstracker.ui.decks.CmdRemAttr
26+
import com.ediposouza.teslesgendstracker.util.MetricAction
2627
import com.ediposouza.teslesgendstracker.util.MetricScreen
2728
import com.ediposouza.teslesgendstracker.util.MetricsManager
2829
import kotlinx.android.synthetic.main.activity_new_deck.*
@@ -182,6 +183,7 @@ class NewDeckActivity : BaseFilterActivity() {
182183
val data = intentFor<NewDeckActivity>(DECK_PRIVATE_EXTRA to deckPrivate)
183184
setResult(Activity.RESULT_OK, data)
184185
ActivityCompat.finishAfterTransition(this)
186+
MetricsManager.trackAction(MetricAction.ACTION_NEW_DECK_SAVE(deckTypeText, deckPatchDesc, deckPrivate))
185187
}
186188
}
187189

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/widget/MagikaCosts.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ class MagikaCosts(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
7676
constructor(ctx: Context?, attrs: AttributeSet) : this(ctx, attrs, 0)
7777

7878
fun updateCosts(cards: List<CardSlot>) {
79-
magikaCost0Qtd = cards.filter { it.card.cost == 0 }.sumBy { it.qtd.toInt() }
80-
magikaCost1Qtd = cards.filter { it.card.cost == 1 }.sumBy { it.qtd.toInt() }
81-
magikaCost2Qtd = cards.filter { it.card.cost == 2 }.sumBy { it.qtd.toInt() }
82-
magikaCost3Qtd = cards.filter { it.card.cost == 3 }.sumBy { it.qtd.toInt() }
83-
magikaCost4Qtd = cards.filter { it.card.cost == 4 }.sumBy { it.qtd.toInt() }
84-
magikaCost5Qtd = cards.filter { it.card.cost == 5 }.sumBy { it.qtd.toInt() }
85-
magikaCost6Qtd = cards.filter { it.card.cost == 6 }.sumBy { it.qtd.toInt() }
86-
magikaCost7PlusQtd = cards.filter { it.card.cost >= 7 }.sumBy { it.qtd.toInt() }
79+
magikaCost0Qtd = cards.filter { it.card.cost == 0 }.sumBy { it.qtd }
80+
magikaCost1Qtd = cards.filter { it.card.cost == 1 }.sumBy { it.qtd }
81+
magikaCost2Qtd = cards.filter { it.card.cost == 2 }.sumBy { it.qtd }
82+
magikaCost3Qtd = cards.filter { it.card.cost == 3 }.sumBy { it.qtd }
83+
magikaCost4Qtd = cards.filter { it.card.cost == 4 }.sumBy { it.qtd }
84+
magikaCost5Qtd = cards.filter { it.card.cost == 5 }.sumBy { it.qtd }
85+
magikaCost6Qtd = cards.filter { it.card.cost == 6 }.sumBy { it.qtd }
86+
magikaCost7PlusQtd = cards.filter { it.card.cost >= 7 }.sumBy { it.qtd }
8787
}
8888

8989
private fun updateMagikaCostBars() {
@@ -108,7 +108,8 @@ class MagikaCosts(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
108108
val zeroMargin = resources.getDimensionPixelSize(R.dimen.deck_new_magika_costs_bar_min_height)
109109
val magikaCostViewLP = magikaCostView?.layoutParams as RelativeLayout.LayoutParams
110110
val factor: Float = if (maxMagikaCostQtd == 0) 0f else magikaCostQtd / maxMagikaCostQtd.toFloat()
111-
magikaCostViewLP.topMargin = (zeroMargin - zeroMargin * factor).toInt()
111+
val topMargin = (zeroMargin - zeroMargin * factor).toInt()
112+
magikaCostViewLP.topMargin = if (topMargin == zeroMargin) topMargin - 5 else topMargin
112113
magikaCostView?.layoutParams = magikaCostViewLP
113114
}
114115

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.ediposouza.teslesgendstracker.ui.util
2+
3+
import android.app.Activity
4+
import android.graphics.Rect
5+
import android.os.Build
6+
import android.view.View
7+
import android.view.ViewTreeObserver
8+
9+
10+
/**
11+
* Created by EdipoSouza on 12/31/16.
12+
*/
13+
/**
14+
* Created by mikepenz on 14.03.15.
15+
* This class implements a hack to change the layout padding on bottom if the keyboard is shown
16+
* to allow long lists with editTextViews
17+
* Basic idea for this solution found here: http://stackoverflow.com/a/9108219/325479
18+
*/
19+
class KeyboardUtil(act: Activity, private val contentView: View?) {
20+
21+
//a small helper to allow showing the editText focus
22+
private var onGlobalLayoutListener: ViewTreeObserver.OnGlobalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
23+
val r = Rect()
24+
//r will be populated with the coordinates of your view that area still visible.
25+
decorView.getWindowVisibleDisplayFrame(r)
26+
27+
//get screen height and calculate the difference with the useable area from the r
28+
val height = decorView.context.resources.displayMetrics.heightPixels
29+
val diff = height - r.bottom
30+
31+
//if it could be a keyboard add the padding to the view
32+
if (diff != 0) {
33+
// if the use-able screen height differs from the total screen height we assume that it shows a keyboard now
34+
//check if the padding is 0 (if yes set the padding for the keyboard)
35+
if (contentView?.paddingBottom !== diff) {
36+
//set the padding of the contentView for the keyboard
37+
contentView?.setPadding(0, 0, 0, diff)
38+
}
39+
} else {
40+
//check if the padding is != 0 (if yes reset the padding)
41+
if (contentView?.paddingBottom !== 0) {
42+
//reset the padding of the contentView
43+
contentView?.setPadding(0, 0, 0, 0)
44+
}
45+
}
46+
}
47+
48+
private val decorView: View
49+
50+
init {
51+
this.decorView = act.window.decorView
52+
53+
//only required on newer android versions. it was working on API level 19 (Build.VERSION_CODES.KITKAT)
54+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
55+
decorView.viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
56+
}
57+
}
58+
59+
fun enable() {
60+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
61+
decorView.viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener)
62+
}
63+
}
64+
65+
fun disable() {
66+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
67+
decorView.viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener)
68+
}
69+
}
70+
71+
}

app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/widget/CollectionStatistics.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class CollectionStatistics(ctx: Context?, attrs: AttributeSet?, defStyleAttr: In
3737
constructor(ctx: Context?, attrs: AttributeSet) : this(ctx, attrs, 0)
3838

3939
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
40-
return true
40+
val statisticPeekHeight = resources.getDimensionPixelSize(R.dimen.statistics_bottom_peek_height)
41+
val clickYPos = ev?.y ?: 0f
42+
return clickYPos < statisticPeekHeight || super.onInterceptTouchEvent(ev)
4143
}
4244

4345
fun scrollToTop() {

0 commit comments

Comments
 (0)