From cb6b1d2d71488347bbccf418b81f593ea14093a1 Mon Sep 17 00:00:00 2001 From: EdipoSouza Date: Sat, 31 Dec 2016 11:58:55 -0200 Subject: [PATCH 1/4] Add Decks metrics --- .../teslesgendstracker/ui/CardActivity.kt | 4 +- .../teslesgendstracker/ui/DeckActivity.kt | 43 +++++++++++---- .../ui/cards/tabs/CardsAllFragment.kt | 11 ++-- .../ui/cards/tabs/CardsCollectionFragment.kt | 2 +- .../ui/decks/new/NewDeckActivity.kt | 2 + .../util/MetricsConstants.kt | 55 +++++++++++-------- .../teslesgendstracker/util/MetricsManager.kt | 21 +++++-- build.gradle | 2 +- 8 files changed, 89 insertions(+), 51 deletions(-) diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/CardActivity.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/CardActivity.kt index be956a9..855f6aa 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/CardActivity.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/CardActivity.kt @@ -95,12 +95,12 @@ class CardActivity : BaseActivity() { if (App.hasUserLogged()) { PrivateInteractor().setUserCardFavorite(card, !favorite) { favorite = !favorite - MetricsManager.trackAction(if (favorite) MetricAction.ACTION_CARD_DETAILS_FAVORITE() - else MetricAction.ACTION_CARD_DETAILS_UNFAVORITE()) val stringRes = if (favorite) R.string.card_favorited else R.string.card_unfavorited toast(getString(stringRes, card.name)) loadCardInfo() setResult(Activity.RESULT_OK, Intent()) + MetricsManager.trackAction(if (favorite) + MetricAction.ACTION_CARD_DETAILS_FAVORITE() else MetricAction.ACTION_CARD_DETAILS_UNFAVORITE()) } } else { showErrorUserNotLogged() diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt index 040e155..09edd20 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt @@ -30,10 +30,7 @@ import com.ediposouza.teslesgendstracker.interactor.PublicInteractor import com.ediposouza.teslesgendstracker.ui.base.BaseActivity import com.ediposouza.teslesgendstracker.ui.base.CmdShowSnackbarMsg import com.ediposouza.teslesgendstracker.ui.util.CircleTransform -import com.ediposouza.teslesgendstracker.util.MetricScreen -import com.ediposouza.teslesgendstracker.util.MetricsManager -import com.ediposouza.teslesgendstracker.util.inflate -import com.ediposouza.teslesgendstracker.util.toggleExpanded +import com.ediposouza.teslesgendstracker.util.* import com.google.firebase.auth.FirebaseAuth import io.fabric.sdk.android.services.common.CommonUtils import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator @@ -87,24 +84,39 @@ class DeckActivity : BaseActivity() { favorite = intent.getBooleanExtra(EXTRA_FAVORITE, false) like = intent.getBooleanExtra(EXTRA_LIKE, false) + configViews() + updateFavoriteItem() + loadDeckInfo() + } + + private fun configViews() { deck_fab_favorite.setOnClickListener { if (App.hasUserLogged()) { privateInteractor.setUserDeckFavorite(deck, !favorite) { favorite = !favorite updateFavoriteItem() + MetricsManager.trackAction(if (favorite) + MetricAction.ACTION_DECK_DETAILS_FAVORITE() else MetricAction.ACTION_DECK_DETAILS_UNFAVORITE()) } } else { showErrorUserNotLogged() } } - deck_bottom_sheet.setOnClickListener { commentsSheetBehavior.toggleExpanded() } - updateFavoriteItem() - loadDeckInfo() - } + commentsSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { + override fun onSlide(bottomSheet: View, slideOffset: Float) { + } - override fun onPostCreate(savedInstanceState: Bundle?) { - super.onPostCreate(savedInstanceState) - supportActionBar?.setDisplayHomeAsUpEnabled(true) + override fun onStateChanged(bottomSheet: View, newState: Int) { + when (newState) { + BottomSheetBehavior.STATE_EXPANDED -> + MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_EXPAND()) + BottomSheetBehavior.STATE_COLLAPSED -> + MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_COLLAPSE()) + } + } + + }) + deck_bottom_sheet.setOnClickListener { commentsSheetBehavior.toggleExpanded() } deck_comment_send?.setOnClickListener { if (App.hasUserLogged()) { if (deck_comment_new.text.toString().length < 4) { @@ -114,12 +126,18 @@ class DeckActivity : BaseActivity() { PrivateInteractor().addDeckComment(deck, deck_comment_new.text.toString()) { deck_comment_new.setText("") addComment(it) + MetricsManager.trackAction(MetricAction.ACTION_DECK_COMMENTS_SEND()) } } } else { showErrorUserNotLogged() } } + } + + override fun onPostCreate(savedInstanceState: Bundle?) { + super.onPostCreate(savedInstanceState) + supportActionBar?.setDisplayHomeAsUpEnabled(true) onKeyboardVisibilityChange = { deck_comment_recycle_view.requestLayout() } @@ -169,6 +187,8 @@ class DeckActivity : BaseActivity() { updateLikeItem() val deckLikes = Integer.parseInt(deck_details_likes.text.toString()) deck_details_likes.text = numberInstance.format(deckLikes + if (like) 1 else -1) + MetricsManager.trackAction(if (like) + MetricAction.ACTION_DECK_DETAILS_LIKE() else MetricAction.ACTION_DECK_DETAILS_UNLIKE()) } return true } @@ -179,6 +199,7 @@ class DeckActivity : BaseActivity() { privateInteractor.deleteDeck(deck, deck.private) { toast(R.string.deck_deleted) ActivityCompat.finishAfterTransition(this@DeckActivity) + MetricsManager.trackAction(MetricAction.ACTION_DECK_DETAILS_DELETE()) } }) setTheme(R.style.AppDialog) diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsAllFragment.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsAllFragment.kt index d714790..840ed55 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsAllFragment.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsAllFragment.kt @@ -130,7 +130,7 @@ open class CardsAllFragment : BaseFragment() { fun onCmdShowCardsByAttr(showCardsByAttr: CmdShowCardsByAttr) { loadCardsByAttr(showCardsByAttr.attr) if (isFragmentSelected) { - MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_ATTR(), showCardsByAttr.attr.name) + MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_ATTR(showCardsByAttr.attr)) } } @@ -145,8 +145,7 @@ open class CardsAllFragment : BaseFragment() { classFilter = filterClass.cls showCards() if (isFragmentSelected) { - MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_SET(), - setFilter?.name ?: MetricAction.ACTION_CARD_FILTER_SET.VALUE_CLEAR) + MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_SET(setFilter)) } } @@ -161,8 +160,7 @@ open class CardsAllFragment : BaseFragment() { rarityFilter = filterRarity.rarity showCards() if (isFragmentSelected) { - MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_RARITY(), - rarityFilter?.name ?: MetricAction.ACTION_CARD_FILTER_RARITY.VALUE_CLEAR) + MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_RARITY(rarityFilter)) } } @@ -171,8 +169,7 @@ open class CardsAllFragment : BaseFragment() { magikaFilter = filterMagika.magika showCards() if (isFragmentSelected) { - MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_MAGIKA(), if (magikaFilter >= 0) - magikaFilter.toString() else MetricAction.ACTION_CARD_FILTER_MAGIKA.VALUE_CLEAR) + MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_MAGIKA(magikaFilter)) } } diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsCollectionFragment.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsCollectionFragment.kt index ab85242..1ec7344 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsCollectionFragment.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/cards/tabs/CardsCollectionFragment.kt @@ -108,7 +108,7 @@ class CardsCollectionFragment : CardsAllFragment() { cards_recycler_view?.itemAnimator = null cardsCollectionAdapter.updateSlot(cardSlot, finalQtd) view_statistics.updateStatistics(currentAttr) - MetricsManager.trackAction(MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE(), finalQtd.toString()) + MetricsManager.trackAction(MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE(finalQtd)) } } diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/new/NewDeckActivity.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/new/NewDeckActivity.kt index e352fa6..4f1f1a1 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/new/NewDeckActivity.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/new/NewDeckActivity.kt @@ -23,6 +23,7 @@ import com.ediposouza.teslesgendstracker.ui.cards.CmdFilterMagika import com.ediposouza.teslesgendstracker.ui.cards.CmdFilterRarity import com.ediposouza.teslesgendstracker.ui.decks.CmdAddCard import com.ediposouza.teslesgendstracker.ui.decks.CmdRemAttr +import com.ediposouza.teslesgendstracker.util.MetricAction import com.ediposouza.teslesgendstracker.util.MetricScreen import com.ediposouza.teslesgendstracker.util.MetricsManager import kotlinx.android.synthetic.main.activity_new_deck.* @@ -182,6 +183,7 @@ class NewDeckActivity : BaseFilterActivity() { val data = intentFor(DECK_PRIVATE_EXTRA to deckPrivate) setResult(Activity.RESULT_OK, data) ActivityCompat.finishAfterTransition(this) + MetricsManager.trackAction(MetricAction.ACTION_NEW_DECK_SAVE(deckTypeText, deckPatchDesc, deckPrivate)) } } diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/util/MetricsConstants.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/util/MetricsConstants.kt index 2c9628f..22f7583 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/util/MetricsConstants.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/util/MetricsConstants.kt @@ -1,5 +1,9 @@ package com.ediposouza.teslesgendstracker.util +import com.ediposouza.teslesgendstracker.data.Attribute +import com.ediposouza.teslesgendstracker.data.CardRarity +import com.ediposouza.teslesgendstracker.data.CardSet + /** * Created by ediposouza on 08/12/16. */ @@ -30,6 +34,10 @@ abstract class MetricsConstants { sealed class MetricAction(val name: String) { + companion object { + const val CLEAR = "Clear" + } + class ACTION_CARD_DETAILS_EXPAND : MetricAction("CardDetailsExpand") class ACTION_CARD_DETAILS_COLLAPSE : MetricAction("CardDetailsCollapse") class ACTION_CARD_DETAILS_CLOSE_TAP : MetricAction("CardDetailsCloseTap") @@ -38,41 +46,42 @@ sealed class MetricAction(val name: String) { class ACTION_COLLECTION_STATISTICS_EXPAND : MetricAction("CollectionStatisticsExpand") class ACTION_COLLECTION_STATISTICS_COLLAPSE : MetricAction("CollectionStatisticsCollapse") - class ACTION_COLLECTION_CARD_QTD_CHANGE : MetricAction("CollectionCardQtdChange") { - companion object { - val PARAM_QTD = "Qtd" - } + class ACTION_COLLECTION_CARD_QTD_CHANGE(val qtd: Int) : MetricAction("CollectionCardQtdChange") { + val PARAM_QTD = "Qtd" } - class ACTION_CARD_FILTER_SET : MetricAction("FilterCardSet") { - companion object { - const val PARAM_SET = "Set" - const val VALUE_CLEAR = "Clear" - } + class ACTION_CARD_FILTER_SET(val set: CardSet?) : MetricAction("FilterCardSet") { + val PARAM_SET = "Set" } - class ACTION_CARD_FILTER_ATTR : MetricAction("FilterCardAttr") { - companion object { - const val PARAM_ATTR = "Attr" - } + class ACTION_CARD_FILTER_ATTR(val attr: Attribute?) : MetricAction("FilterCardAttr") { + val PARAM_ATTR = "Attr" } - class ACTION_CARD_FILTER_RARITY : MetricAction("FilterCardRarity") { - companion object { - const val PARAM_RARITY = "Rarity" - const val VALUE_CLEAR = "Clear" - } + class ACTION_CARD_FILTER_RARITY(val rarity: CardRarity?) : MetricAction("FilterCardRarity") { + val PARAM_RARITY = "Rarity" } - class ACTION_CARD_FILTER_MAGIKA : MetricAction("FilterCardMagika") { - companion object { - const val PARAM_MAGIKA = "Magika" - const val VALUE_CLEAR = "Clear" - } + class ACTION_CARD_FILTER_MAGIKA(val magika: Int) : MetricAction("FilterCardMagika") { + val PARAM_MAGIKA = "Magika" } class ACTION_NOTIFY_UPDATE : MetricAction("NotifyUpdate") class ACTION_VERSION_UNSUPPORTED : MetricAction("VersionUnsupported") + class ACTION_DECK_DETAILS_DELETE : MetricAction("DeckDetailsDelete") + class ACTION_DECK_DETAILS_LIKE : MetricAction("DeckDetailsLike") + class ACTION_DECK_DETAILS_UNLIKE : MetricAction("DeckDetailsUnlike") + class ACTION_DECK_DETAILS_FAVORITE : MetricAction("DeckDetailsFavorite") + class ACTION_DECK_DETAILS_UNFAVORITE : MetricAction("DeckDetailsUnfavorite") + class ACTION_DECK_COMMENTS_EXPAND : MetricAction("DeckCommentExpand") + class ACTION_DECK_COMMENTS_COLLAPSE : MetricAction("DeckCommentCollapse") + class ACTION_DECK_COMMENTS_SEND : MetricAction("DeckCommentSend") + + class ACTION_NEW_DECK_SAVE(val type: String, val patch: String, val private: Boolean) : MetricAction("DeckCommentSend") { + val PARAM_TYPE = "Type" + val PARAM_PATCH = "Patch" + val PARAM_PRIVATE = "Private" + } } diff --git a/app/src/release/java/com/ediposouza/teslesgendstracker/util/MetricsManager.kt b/app/src/release/java/com/ediposouza/teslesgendstracker/util/MetricsManager.kt index 6e47889..85796f4 100644 --- a/app/src/release/java/com/ediposouza/teslesgendstracker/util/MetricsManager.kt +++ b/app/src/release/java/com/ediposouza/teslesgendstracker/util/MetricsManager.kt @@ -38,15 +38,24 @@ object MetricsManager : MetricsConstants() { mixpanelAnalytics?.flush() } - fun trackAction(action: MetricAction, vararg params: String) { + fun trackAction(action: MetricAction) { val bundle = Bundle().apply { when (action) { is MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE -> - putString(MetricAction.ACTION_COLLECTION_CARD_QTD_CHANGE.PARAM_QTD, params[0]) - is MetricAction.ACTION_CARD_FILTER_SET -> putString(MetricAction.ACTION_CARD_FILTER_SET.PARAM_SET, params[0]) - is MetricAction.ACTION_CARD_FILTER_ATTR -> putString(MetricAction.ACTION_CARD_FILTER_ATTR.PARAM_ATTR, params[0]) - is MetricAction.ACTION_CARD_FILTER_RARITY -> putString(MetricAction.ACTION_CARD_FILTER_RARITY.PARAM_RARITY, params[0]) - is MetricAction.ACTION_CARD_FILTER_MAGIKA -> putString(MetricAction.ACTION_CARD_FILTER_MAGIKA.PARAM_MAGIKA, params[0]) + putInt(action.PARAM_QTD, action.qtd) + is MetricAction.ACTION_CARD_FILTER_SET -> + putString(action.PARAM_SET, action.set?.name ?: MetricAction.CLEAR) + is MetricAction.ACTION_CARD_FILTER_ATTR -> + putString(action.PARAM_ATTR, action.attr?.name ?: MetricAction.CLEAR) + is MetricAction.ACTION_CARD_FILTER_RARITY -> + putString(action.PARAM_RARITY, action.rarity?.name ?: MetricAction.CLEAR) + is MetricAction.ACTION_CARD_FILTER_MAGIKA -> + putString(action.PARAM_MAGIKA, if (action.magika > 0) action.magika.toString() else MetricAction.CLEAR) + is MetricAction.ACTION_NEW_DECK_SAVE -> { + putString(action.PARAM_TYPE, action.type) + putString(action.PARAM_PATCH, action.patch) + putString(action.PARAM_PRIVATE, action.private.toString()) + } } } answers?.logCustom(CustomEvent(action.name)) diff --git a/build.gradle b/build.gradle index 323cc3c..ee5f305 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { appVersionCode = 4 kotlin_version = "1.0.6" - prepareToRelease = true + prepareToRelease = false } repositories { From 470947a94a5e13916a1f494adae89d3d4b488e43 Mon Sep 17 00:00:00 2001 From: EdipoSouza Date: Sat, 31 Dec 2016 16:42:42 -0200 Subject: [PATCH 2/4] Fix JellyBean and Kitkat layout. Fix Statistics scroll. Fix empty cost bar below Lollipop. --- app/libs/clansFAB.aar | Bin 53080 -> 54265 bytes .../teslesgendstracker/ui/DeckActivity.kt | 11 ++++++++-- .../ui/decks/widget/MagikaCosts.kt | 19 +++++++++-------- .../ui/widget/CollectionStatistics.kt | 4 +++- app/src/main/res/layout/activity_dash.xml | 1 + app/src/main/res/layout/activity_deck.xml | 4 +++- app/src/main/res/layout/activity_new_deck.xml | 9 ++++---- app/src/main/res/layout/include_deck_info.xml | 2 -- .../main/res/layout/widget_magika_filter.xml | 2 +- app/src/main/res/values-hdpi/dimens.xml | 2 ++ app/src/main/res/values-v19/dimens.xml | 19 +++++++++++++++++ app/src/main/res/values-xhdpi/dimens.xml | 2 ++ app/src/main/res/values-xxhdpi/dimens.xml | 2 ++ app/src/main/res/values/dimens.xml | 20 +++++++++++------- 14 files changed, 69 insertions(+), 28 deletions(-) create mode 100644 app/src/main/res/values-v19/dimens.xml diff --git a/app/libs/clansFAB.aar b/app/libs/clansFAB.aar index 9d2f57649121417d11355a454bd5f114833c78f4..f0b7dfc24213da5151e0e5e93a63fd32f39ffcbb 100644 GIT binary patch delta 2432 zcmcaHkNM|vX5IjAW)?061`ZB}q~iG#dA~9Psm-j62Ai2P8|H7e*kZuSe7a=*l0UAzB->7G6RK=kI`y)2Aiqo(WwGC(?J?>7R=T-YxT z6Ofy{?+nLefrC6?1@Z^afa!M!jll|44k<$vdL1?a3p5^1hX}krqQL=lou^0KT;0ji zM>XqzYqQ)9KJFRyMZwx5iA7_=Hpe;6Ra_Z`s=`Y>rY@0L{^I!bDe;q5u)mC3HT$V# z)>dol-CgU)m1p17O-d5GG=n(T-qo77NcF~|9ADLd zi0Q}gebjL;GtzZ^(zM*|c=XlE2h%nF&E$$RxTCjRY^mIimc#&sl3x=ynflFW61g>h z*1}%?d)ivTCvP8)mV9-iNJ9Vl&s9sWeVOaVu&c#2o;})CkMs1UOZ8%wUA;kfES7fo zFu8ikltewP@Y>_`c6wF*63atr3^t$tsN7>#;rn*ksYdDLE0brs*HcgWEhc5tC zbqK5U(~PISw+>aT5Z8Xz)c8VzC3n%fjN_?RSLZ*q=+d2Z*<)LT?B;D&63n?7&ZmgUQT zZ&}dl_ps66dkphZ75OLvoePw?+KiRZ(vmr|)f7`nbB`@yhV# zr+KR%9z1ETHnq$=YUiKx+m_8zIl~|u(U|o&$|HB<_c^?4%y#d5wefA3#Jbmct&jH9 zzYnvB%H`%*JJ1BTXVMEe9C&x^diHr1H1L+)&9A{zWxoPb@YswlWg-|Y)q(a zWO-$K-Ml04s)m%j{qg@yh+GTITAuX`K)?hdfIt|Ci&BgA%Mx=+Q;T&oQVKG4%S`l{ z84!9vdB@XE50bZ6^d@(b^k!wUYWSKLZOf&+`uLoG?GDMR=ed6wwthC!<6)NY{_5y{ll})V*Od-^Tw;@lF)li4!^a~A)* z+$gjuY5s)+kJQz_xK8ijd~>0-Kaanl)pGh1Can1};Te+RH)P}v8Rx|=z7J}(o(in=O zMHiNiVC4{u4@y_a?f@D(85qiZqNk8;oILNWcoep@i?GiNMFUdu$Ci?jZ3Lwwx%1LY zJf|lwJSS`ckBP;_sU^kw$Yy|=LX9V-#Up^yS$UZlazOLtYk+b& YnMojxtZX1d<$=(NgMncosLW*m027R_UjP6A delta 1325 zcmeylocYE)X5IjAW)?061`ZB}N$XlB@_uEOS>LjmmC;}`m|?NSfR!02F*$puBAD*q zsRpKZ?0f~Lm+pE5rn`3k2h%-!{(pA<9N$}5bmLD;-#@e8M8>jF zzQjgogL0MQ63&aF|2#g;X=05lS{FYx^kLD_`}4v$K5u`xIJI-PZoc`!87T*RSaS|3 zA6hcOu4nptPbJ5n0d*w-4Wf~}zIDz!f)70G;z{FA+%3eG?ZW-{v)BCVoo6|e-Jk5} z>Ty%6Z*x;&5)z1-alz+5ud-Cay;YJm+NrJvCBaLCqIQScxO#7Jy*bNk!3Mqly-y?i z-lRlzonZCv?JHmP`G9`lA7jxy2|Hr_biHhgI1evyc=1I!HG7T$tL7GaQ)g-UJ>enC zCVhS!E&1w1k%a#9pR1N$`!d&!VONW5JbSdO9_Q&xm+I#giAXQqQRpQ&lcj5l#fvSc zK2E8adQ1Q7J&)p+vkVo_en#%8_Kj;U%sy<;1(LU8_N z4xy#D{w1!dnE?(x`t25#G0WlW`n}i0}cgs}gvOQa1t*?dy;oase|Uk85c&8z)$g?;@S#_DJZ{}g8bFA*E|IWTQK`;|8- zq*SoiZ~o(YMwDFZIa%toA~@^VomK&5+sUawK8WrF@69Id3qn zeck~~=beY}_ndbG@h4sI0So(Ia01g)E= Build.VERSION_CODES.LOLLIPOP) { + val statusBarHeight = resources.getDimensionPixelSize(R.dimen.status_bar_height) + if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { + val coverLP = deck_class_cover.layoutParams as RelativeLayout.LayoutParams + coverLP.height = coverLP.height - statusBarHeight + deck_class_cover.layoutParams = coverLP + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { val layoutParams = toolbar.layoutParams as CollapsingToolbarLayout.LayoutParams - layoutParams.topMargin = resources.getDimensionPixelSize(R.dimen.status_bar_height) + layoutParams.topMargin = statusBarHeight toolbar.layoutParams = layoutParams } diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/widget/MagikaCosts.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/widget/MagikaCosts.kt index efbe49c..5f1fd17 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/widget/MagikaCosts.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/decks/widget/MagikaCosts.kt @@ -76,14 +76,14 @@ class MagikaCosts(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) : constructor(ctx: Context?, attrs: AttributeSet) : this(ctx, attrs, 0) fun updateCosts(cards: List) { - magikaCost0Qtd = cards.filter { it.card.cost == 0 }.sumBy { it.qtd.toInt() } - magikaCost1Qtd = cards.filter { it.card.cost == 1 }.sumBy { it.qtd.toInt() } - magikaCost2Qtd = cards.filter { it.card.cost == 2 }.sumBy { it.qtd.toInt() } - magikaCost3Qtd = cards.filter { it.card.cost == 3 }.sumBy { it.qtd.toInt() } - magikaCost4Qtd = cards.filter { it.card.cost == 4 }.sumBy { it.qtd.toInt() } - magikaCost5Qtd = cards.filter { it.card.cost == 5 }.sumBy { it.qtd.toInt() } - magikaCost6Qtd = cards.filter { it.card.cost == 6 }.sumBy { it.qtd.toInt() } - magikaCost7PlusQtd = cards.filter { it.card.cost >= 7 }.sumBy { it.qtd.toInt() } + magikaCost0Qtd = cards.filter { it.card.cost == 0 }.sumBy { it.qtd } + magikaCost1Qtd = cards.filter { it.card.cost == 1 }.sumBy { it.qtd } + magikaCost2Qtd = cards.filter { it.card.cost == 2 }.sumBy { it.qtd } + magikaCost3Qtd = cards.filter { it.card.cost == 3 }.sumBy { it.qtd } + magikaCost4Qtd = cards.filter { it.card.cost == 4 }.sumBy { it.qtd } + magikaCost5Qtd = cards.filter { it.card.cost == 5 }.sumBy { it.qtd } + magikaCost6Qtd = cards.filter { it.card.cost == 6 }.sumBy { it.qtd } + magikaCost7PlusQtd = cards.filter { it.card.cost >= 7 }.sumBy { it.qtd } } private fun updateMagikaCostBars() { @@ -108,7 +108,8 @@ class MagikaCosts(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) : val zeroMargin = resources.getDimensionPixelSize(R.dimen.deck_new_magika_costs_bar_min_height) val magikaCostViewLP = magikaCostView?.layoutParams as RelativeLayout.LayoutParams val factor: Float = if (maxMagikaCostQtd == 0) 0f else magikaCostQtd / maxMagikaCostQtd.toFloat() - magikaCostViewLP.topMargin = (zeroMargin - zeroMargin * factor).toInt() + val topMargin = (zeroMargin - zeroMargin * factor).toInt() + magikaCostViewLP.topMargin = if (topMargin == zeroMargin) topMargin - 5 else topMargin magikaCostView?.layoutParams = magikaCostViewLP } diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/widget/CollectionStatistics.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/widget/CollectionStatistics.kt index cbc8dd5..ce24283 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/widget/CollectionStatistics.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/widget/CollectionStatistics.kt @@ -37,7 +37,9 @@ class CollectionStatistics(ctx: Context?, attrs: AttributeSet?, defStyleAttr: In constructor(ctx: Context?, attrs: AttributeSet) : this(ctx, attrs, 0) override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { - return true + val statisticPeekHeight = resources.getDimensionPixelSize(R.dimen.statistics_bottom_peek_height) + val clickYPos = ev?.y ?: 0f + return clickYPos < statisticPeekHeight || super.onInterceptTouchEvent(ev) } fun scrollToTop() { diff --git a/app/src/main/res/layout/activity_dash.xml b/app/src/main/res/layout/activity_dash.xml index bcf8886..69f2a61 100644 --- a/app/src/main/res/layout/activity_dash.xml +++ b/app/src/main/res/layout/activity_dash.xml @@ -31,6 +31,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" + android:lines="1" android:textAppearance="?android:attr/textAppearanceMedium" android:textColor="@android:color/white" android:textStyle="bold" diff --git a/app/src/main/res/layout/activity_deck.xml b/app/src/main/res/layout/activity_deck.xml index c2cdedf..744c3c2 100644 --- a/app/src/main/res/layout/activity_deck.xml +++ b/app/src/main/res/layout/activity_deck.xml @@ -30,6 +30,7 @@ android:layout_height="wrap_content" android:elevation="@dimen/cardview_default_elevation" android:gravity="center" + android:lines="1" android:minHeight="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" @@ -117,7 +118,8 @@ diff --git a/app/src/main/res/layout/activity_new_deck.xml b/app/src/main/res/layout/activity_new_deck.xml index f73f654..44e782c 100644 --- a/app/src/main/res/layout/activity_new_deck.xml +++ b/app/src/main/res/layout/activity_new_deck.xml @@ -40,6 +40,7 @@ android:background="@android:color/transparent" android:elevation="@dimen/cardview_default_elevation" android:fitsSystemWindows="true" + android:lines="1" android:minHeight="?attr/actionBarSize" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:theme="@style/ThemeOverlay.AppCompat.Dark" @@ -90,17 +91,17 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center" - android:paddingStart="@dimen/huge_margin" + android:layout_marginBottom="@dimen/large_margin" android:layout_marginStart="@dimen/huge_margin" - android:layout_marginBottom="@dimen/large_margin" /> + android:paddingStart="@dimen/huge_margin" /> + android:layout_margin="@dimen/large_margin" + android:paddingStart="@dimen/nano_margin" /> diff --git a/app/src/main/res/layout/include_deck_info.xml b/app/src/main/res/layout/include_deck_info.xml index 95630ae..9f88d88 100644 --- a/app/src/main/res/layout/include_deck_info.xml +++ b/app/src/main/res/layout/include_deck_info.xml @@ -4,8 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginBottom="@dimen/small_margin" - android:layout_marginTop="@dimen/medium_margin" android:orientation="horizontal" tools:layout_marginTop="@dimen/status_bar_height"> diff --git a/app/src/main/res/layout/widget_magika_filter.xml b/app/src/main/res/layout/widget_magika_filter.xml index 1bdf209..2640036 100644 --- a/app/src/main/res/layout/widget_magika_filter.xml +++ b/app/src/main/res/layout/widget_magika_filter.xml @@ -4,7 +4,7 @@ android:id="@+id/magika_filter" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:menu_buttonSpacing="-4dp" + app:menu_buttonSpacing="@dimen/filter_hide_magika_spacing" app:menu_colorNormal="@android:color/transparent" app:menu_fab_size="mini" app:menu_icon="@drawable/ic_magika"> diff --git a/app/src/main/res/values-hdpi/dimens.xml b/app/src/main/res/values-hdpi/dimens.xml index f2d22f8..e34b950 100644 --- a/app/src/main/res/values-hdpi/dimens.xml +++ b/app/src/main/res/values-hdpi/dimens.xml @@ -7,4 +7,6 @@ 14dp 20dp + -7dp + diff --git a/app/src/main/res/values-v19/dimens.xml b/app/src/main/res/values-v19/dimens.xml new file mode 100644 index 0000000..9ce581c --- /dev/null +++ b/app/src/main/res/values-v19/dimens.xml @@ -0,0 +1,19 @@ + + + 25dp + 48dp + + + + 56dp + + + + 84dp + + + + 140dp + + 86dp + diff --git a/app/src/main/res/values-xhdpi/dimens.xml b/app/src/main/res/values-xhdpi/dimens.xml index d923b4c..617fdb6 100644 --- a/app/src/main/res/values-xhdpi/dimens.xml +++ b/app/src/main/res/values-xhdpi/dimens.xml @@ -7,4 +7,6 @@ 15dp 22dp + -5dp + diff --git a/app/src/main/res/values-xxhdpi/dimens.xml b/app/src/main/res/values-xxhdpi/dimens.xml index 2b6e19e..903c152 100644 --- a/app/src/main/res/values-xxhdpi/dimens.xml +++ b/app/src/main/res/values-xxhdpi/dimens.xml @@ -7,4 +7,6 @@ 16dp 24dp + -4dp + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index b12b153..ea1f938 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,7 +1,7 @@ - 25dp - 48dp + 24dp + 0dp 8dp 4dp @@ -24,8 +24,8 @@ 200dp 16dp @dimen/default_margin - - 56dp + + 8dp 48dp 2dp @dimen/default_margin @@ -44,7 +44,8 @@ 24dp @dimen/status_bar_height - 84dp + + 36dp @dimen/navigation_bar_height @@ -52,11 +53,14 @@ 24dp 16dp 20dp - 12dp + @dimen/medium_margin - 140dp + + 115dp 32dp - 88dp + 40dp + + 38dp 56dp 32dp 16dp From 9cfe488f8f578be51df2edcbff835dd6ace56ee0 Mon Sep 17 00:00:00 2001 From: EdipoSouza Date: Sat, 31 Dec 2016 17:47:48 -0200 Subject: [PATCH 3/4] Fix keyboard cover comment edittext --- .../teslesgendstracker/ui/DeckActivity.kt | 17 +++-- .../ui/util/KeyboardUtil.kt | 71 +++++++++++++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/util/KeyboardUtil.kt diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt index 9ebc9a5..1a0b66d 100644 --- a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/DeckActivity.kt @@ -31,6 +31,7 @@ import com.ediposouza.teslesgendstracker.interactor.PublicInteractor import com.ediposouza.teslesgendstracker.ui.base.BaseActivity import com.ediposouza.teslesgendstracker.ui.base.CmdShowSnackbarMsg import com.ediposouza.teslesgendstracker.ui.util.CircleTransform +import com.ediposouza.teslesgendstracker.ui.util.KeyboardUtil import com.ediposouza.teslesgendstracker.util.* import com.google.firebase.auth.FirebaseAuth import io.fabric.sdk.android.services.common.CommonUtils @@ -38,10 +39,7 @@ import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator import kotlinx.android.synthetic.main.activity_deck.* import kotlinx.android.synthetic.main.include_deck_info.* import kotlinx.android.synthetic.main.itemlist_deck_comment.view.* -import org.jetbrains.anko.alert -import org.jetbrains.anko.doAsync -import org.jetbrains.anko.intentFor -import org.jetbrains.anko.toast +import org.jetbrains.anko.* import org.threeten.bp.format.DateTimeFormatter import timber.log.Timber import java.text.NumberFormat @@ -65,6 +63,7 @@ class DeckActivity : BaseActivity() { private val publicInteractor by lazy { PublicInteractor() } private val privateInteractor by lazy { PrivateInteractor() } + private val keyboardUtil by lazy { KeyboardUtil(this, contentView) } private val deckOwned by lazy { intent.getBooleanExtra(EXTRA_OWNED, false) } private val deck: Deck by lazy { intent.getParcelableExtra(EXTRA_DECK) } private val numberInstance: NumberFormat by lazy { NumberFormat.getNumberInstance() } @@ -171,6 +170,16 @@ class DeckActivity : BaseActivity() { } } + override fun onStart() { + super.onStart() + keyboardUtil.enable() + } + + override fun onStop() { + super.onStop() + keyboardUtil.disable() + } + override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(if (deckOwned) R.menu.menu_deck_owner else R.menu.menu_deck, menu) menuLike = menu?.findItem(R.id.menu_like) diff --git a/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/util/KeyboardUtil.kt b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/util/KeyboardUtil.kt new file mode 100644 index 0000000..56d7ecd --- /dev/null +++ b/app/src/main/kotlin/com/ediposouza/teslesgendstracker/ui/util/KeyboardUtil.kt @@ -0,0 +1,71 @@ +package com.ediposouza.teslesgendstracker.ui.util + +import android.app.Activity +import android.graphics.Rect +import android.os.Build +import android.view.View +import android.view.ViewTreeObserver + + +/** + * Created by EdipoSouza on 12/31/16. + */ +/** + * Created by mikepenz on 14.03.15. + * This class implements a hack to change the layout padding on bottom if the keyboard is shown + * to allow long lists with editTextViews + * Basic idea for this solution found here: http://stackoverflow.com/a/9108219/325479 + */ +class KeyboardUtil(act: Activity, private val contentView: View?) { + + //a small helper to allow showing the editText focus + private var onGlobalLayoutListener: ViewTreeObserver.OnGlobalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener { + val r = Rect() + //r will be populated with the coordinates of your view that area still visible. + decorView.getWindowVisibleDisplayFrame(r) + + //get screen height and calculate the difference with the useable area from the r + val height = decorView.context.resources.displayMetrics.heightPixels + val diff = height - r.bottom + + //if it could be a keyboard add the padding to the view + if (diff != 0) { + // if the use-able screen height differs from the total screen height we assume that it shows a keyboard now + //check if the padding is 0 (if yes set the padding for the keyboard) + if (contentView?.paddingBottom !== diff) { + //set the padding of the contentView for the keyboard + contentView?.setPadding(0, 0, 0, diff) + } + } else { + //check if the padding is != 0 (if yes reset the padding) + if (contentView?.paddingBottom !== 0) { + //reset the padding of the contentView + contentView?.setPadding(0, 0, 0, 0) + } + } + } + + private val decorView: View + + init { + this.decorView = act.window.decorView + + //only required on newer android versions. it was working on API level 19 (Build.VERSION_CODES.KITKAT) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + decorView.viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener) + } + } + + fun enable() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + decorView.viewTreeObserver.addOnGlobalLayoutListener(onGlobalLayoutListener) + } + } + + fun disable() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + decorView.viewTreeObserver.removeOnGlobalLayoutListener(onGlobalLayoutListener) + } + } + +} \ No newline at end of file From b16db247b4149df4d2e3cb1771de121f891c8d81 Mon Sep 17 00:00:00 2001 From: EdipoSouza Date: Sat, 31 Dec 2016 17:49:28 -0200 Subject: [PATCH 4/4] Bump version to 0.2.3 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index ee5f305..9f9e9cb 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,11 @@ buildscript { ext { - appVersionName = "0.2.2" - appVersionCode = 4 + appVersionName = "0.2.3" + appVersionCode = 5 kotlin_version = "1.0.6" - prepareToRelease = false + prepareToRelease = true } repositories {