Skip to content

Commit

Permalink
Merge branch 'release/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
edipo2s committed Dec 27, 2016
2 parents 52a27e1 + a5c7c1a commit 6f93709
Show file tree
Hide file tree
Showing 33 changed files with 268 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildConfigField("boolean", "ENABLE_LOGS_IN_RELEASE", "false")
buildConfigField("String", "MIXPANEL_TOKEN", '"eb99af1dad563cbaaf02f008b28e321f"')
buildConfigField("String", "GCM_SENDER", '"597127048287"')
vectorDrawables.useSupportLibrary true
}
signingConfigs {
Expand Down Expand Up @@ -85,11 +87,13 @@ dependencies {

//Google
compile "com.google.android.gms:play-services-auth:$playServicesVersion"
compile "com.google.android.gms:play-services-gcm:$playServicesVersion"
compile "com.google.firebase:firebase-auth:$playServicesVersion"
compile "com.google.firebase:firebase-ads:$playServicesVersion"
compile "com.google.firebase:firebase-core:$playServicesVersion"
compile "com.google.firebase:firebase-config:$playServicesVersion"
compile "com.google.firebase:firebase-database:$playServicesVersion"
compile "com.google.firebase:firebase-messaging:$playServicesVersion"
releaseCompile "com.google.firebase:firebase-crash:$playServicesVersion"

//Fabric
Expand All @@ -101,6 +105,7 @@ dependencies {
}

//Others
compile "com.mixpanel.android:mixpanel-android:4.9.2"
compile "com.jakewharton.threetenabp:threetenabp:$threetenabpVersion"
compile "com.jakewharton.timber:timber:4.3.1"
compile "org.greenrobot:eventbus:3.0.0"
Expand Down
6 changes: 6 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@
-dontwarn org.junit.**
-dontwarn android.test.**
-dontwarn android.support.test.**

## MixPanel
-dontwarn com.mixpanel.**
-keep class **.R$* {
<fields>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ object MetricsManager : MetricsConstants() {
fun initialize(context: Context) {
}

fun flush() {
}

fun trackAction(action: MetricAction, vararg params: String) {
Timber.d(if (params.isEmpty()) action.name else "${action.name} with params: ${params.toSet()}")
}
Expand Down
Binary file added app/src/debug/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/debug/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 21 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ediposouza.teslesgendstracker">

<permission
android:name="com.ediposouza.teslesgendstracker.permission.C2D_MESSAGE"
android:protectionLevel="signature" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.ediposouza.teslesgendstracker.permission.C2D_MESSAGE" />

<application
android:name=".App"
Expand All @@ -21,20 +31,28 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".ui.CardActivity"
android:screenOrientation="portrait"
android:theme="@style/AppThemeTransparent" />

<activity
android:name=".ui.DeckActivity"
android:screenOrientation="portrait" />

<activity
android:name=".ui.decks.new.NewDeckActivity"
android:screenOrientation="portrait" />

<receiver
android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />

<category android:name="com.ediposouza.teslesgendstracker" />
</intent-filter>
</receiver>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ediposouza.teslesgendstracker

import android.content.Context
import android.os.Bundle
import android.support.annotation.IntegerRes
import android.support.design.widget.BottomSheetBehavior
import android.view.LayoutInflater
Expand All @@ -9,6 +10,7 @@ import android.view.ViewGroup
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdView
import com.google.android.gms.ads.NativeExpressAdView
import com.mixpanel.android.mpmetrics.MixpanelAPI

/**
* Created by ediposouza on 01/11/16.
Expand Down Expand Up @@ -47,4 +49,8 @@ private fun createAdRequest(context: Context): AdRequest {
adRequestBuilder.addTestDevice(deviceId)
}
return adRequestBuilder.build()
}

fun MixpanelAPI.trackBundle(eventName: String, bundle: Bundle) {
trackMap(eventName, bundle.keySet().map { it to bundle[it] }.toMap())
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ abstract class MetricsConstants() {

companion object {

const val EVENT_LOGIN = "Login"
const val EVENT_SIGNUP = "SignUp"
const val PARAM_SIGN_METHOD = "method"
const val PARAM_SIGN_METHOD_VALUE_GOOGLE = "Google"

const val EVENT_VIEW_CARD = "ViewCard"
const val PARAM_VIEW_CARD_ID = "ID"
const val PARAM_VIEW_CARD_NAME = "Name"
const val PARAM_VIEW_CARD_ATTR = "Attr"

const val EVENT_SEARCH = "Search"

const val PARAM_CONTENT_VIEW_TYPE_CARD = "Card"

const val PARAM_MIXPANEL_USER_ID = "User ID"
const val PARAM_MIXPANEL_USER_NAME = "\$name"
const val PARAM_MIXPANEL_USER_EMAIL = "\$email"
}

}
Expand All @@ -30,6 +44,13 @@ sealed class MetricAction(val name: String) {
}
}

class ACTION_CARD_FILTER_SET : MetricAction("FilterCardSet") {
companion object {
const val PARAM_SET = "Set"
const val VALUE_CLEAR = "Clear"
}
}

class ACTION_CARD_FILTER_ATTR : MetricAction("FilterCardAttr") {
companion object {
const val PARAM_ATTR = "Attr"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ enum class CardKeyword() {
CHARGE,
COVER,
DRAIN,
EVOLVES,
GUARD,
LAST_GASP,
LETHAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,24 @@ class PrivateInteractor() : BaseInteractor() {
val attr2 = deck.cls.attr2
val cards = hashMapOf<String, CardRarity>()
val userCards = hashMapOf<String, Long>()
publicInteractor.getCards(null, attr1) {
publicInteractor.getCards(null, Attribute.DUAL) {
cards.putAll(it.map { it.shortName to it.rarity })
publicInteractor.getCards(null, attr2) {
publicInteractor.getCards(null, Attribute.NEUTRAL) {
cards.putAll(it.map { it.shortName to it.rarity })
getUserCollection(null, attr1) {
userCards.putAll(it)
getUserCollection(null, attr2) {
userCards.putAll(it)
val missing = deck.cards.map { it.key to it.value.minus(userCards[it.key] ?: 0) }
.map { CardMissing(it.first, cards[it.first]!!, it.second) }
Timber.d(missing.toString())
onSuccess.invoke(missing)
publicInteractor.getCards(null, attr1) {
cards.putAll(it.map { it.shortName to it.rarity })
publicInteractor.getCards(null, attr2) {
cards.putAll(it.map { it.shortName to it.rarity })
getUserCollection(null, attr1) {
userCards.putAll(it)
getUserCollection(null, attr2) {
userCards.putAll(it)
val missing = deck.cards.map { it.key to it.value.minus(userCards[it.key] ?: 0) }
.map { CardMissing(it.first, cards[it.first]!!, it.second) }
Timber.d(missing.toString())
onSuccess.invoke(missing)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ open class BaseActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFaile
.build()
}

override fun onDestroy() {
MetricsManager.flush()
super.onDestroy()
}

override fun onConnectionFailed(p0: ConnectionResult) {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ediposouza.teslesgendstracker.ui.base

import android.support.v4.app.Fragment
import com.ediposouza.teslesgendstracker.manager.MetricsManager
import org.greenrobot.eventbus.EventBus
import timber.log.Timber

Expand Down Expand Up @@ -32,6 +33,11 @@ open class BaseFragment : Fragment() {
}
}

override fun onDestroy() {
MetricsManager.flush()
super.onDestroy()
}

override fun setMenuVisibility(menuVisible: Boolean) {
super.setMenuVisibility(menuVisible)
fragmentSelected = menuVisible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.ediposouza.teslesgendstracker.ui.utils.GridSpacingItemDecoration
import com.ediposouza.teslesgendstracker.ui.utils.SimpleDiffCallback
import jp.wasabeef.recyclerview.animators.ScaleInAnimator
import kotlinx.android.synthetic.main.fragment_cards_list.*
import kotlinx.android.synthetic.main.include_login_button.*
import kotlinx.android.synthetic.main.itemlist_card.view.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
Expand Down Expand Up @@ -107,12 +108,18 @@ open class CardsAllFragment : BaseFragment() {
}
}

open fun configLoggedViews() {
fun configLoggedViews() {
signin_button.setOnClickListener { EventBus.getDefault().post(CmdShowLogin()) }
signin_button.visibility = if (App.hasUserLogged) View.INVISIBLE else View.VISIBLE
cards_recycler_view.visibility = if (App.hasUserLogged) View.VISIBLE else View.INVISIBLE
}

@Subscribe
fun onCmdLoginSuccess(cmdLoginSuccess: CmdLoginSuccess) {
configLoggedViews()
loadCardsByAttr(currentAttr)
}

@Subscribe
fun onCmdShowCardsByAttr(showCardsByAttr: CmdShowCardsByAttr) {
loadCardsByAttr(showCardsByAttr.attr)
Expand All @@ -121,12 +128,6 @@ open class CardsAllFragment : BaseFragment() {
}
}

@Subscribe
fun onCmdLoginSuccess(cmdLoginSuccess: CmdLoginSuccess) {
configLoggedViews()
loadCardsByAttr(currentAttr)
}

@Subscribe
fun onCmdFilterSet(filterSet: CmdFilterSet) {
setFilter = filterSet.set
Expand All @@ -137,6 +138,10 @@ open class CardsAllFragment : BaseFragment() {
fun onCmdFilterClass(filterClass: CmdFilterClass) {
classFilter = filterClass.cls
showCards()
if (fragmentSelected) {
MetricsManager.trackAction(MetricAction.ACTION_CARD_FILTER_SET(),
setFilter?.name ?: MetricAction.ACTION_CARD_FILTER_SET.VALUE_CLEAR)
}
}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class NewDeckCardsListFragment() : CardsAllFragment() {

override fun configRecycleView() {
super.configRecycleView()
configLoggedViews()
cards_recycler_view.setPadding(0, 0, 0, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class DecksFavoritedFragment : DecksPublicFragment() {
return container?.inflate(R.layout.fragment_decks_list)
}

override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
configLoggedViews()
}

override fun getDecks(cls: Class?, last: Boolean) {
privateInteractor.getFavoriteDecks(cls, {
it?.forEach { Timber.d("Public: %s", it.toString()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DecksOwnerFragment : DecksPublicFragment() {
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
configLoggedViews()
}

override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.ediposouza.teslesgendstracker.App
import com.ediposouza.teslesgendstracker.R
import com.ediposouza.teslesgendstracker.data.Class
import com.ediposouza.teslesgendstracker.data.Deck
import com.ediposouza.teslesgendstracker.inflate
import com.ediposouza.teslesgendstracker.interactor.PrivateInteractor
import com.ediposouza.teslesgendstracker.interactor.PublicInteractor
import com.ediposouza.teslesgendstracker.ui.DeckActivity
import com.ediposouza.teslesgendstracker.ui.base.BaseAdsAdapter
import com.ediposouza.teslesgendstracker.ui.base.BaseFragment
import com.ediposouza.teslesgendstracker.ui.base.CmdShowDecksByClasses
import com.ediposouza.teslesgendstracker.ui.base.CmdUpdateDeckAndShowDeck
import com.ediposouza.teslesgendstracker.ui.base.*
import com.ediposouza.teslesgendstracker.ui.utils.SimpleDiffCallback
import com.google.firebase.auth.FirebaseAuth
import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator
import kotlinx.android.synthetic.main.fragment_decks_list.*
import kotlinx.android.synthetic.main.include_login_button.*
import kotlinx.android.synthetic.main.itemlist_deck.view.*
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import timber.log.Timber
import java.text.NumberFormat
Expand Down Expand Up @@ -92,6 +92,18 @@ open class DecksPublicFragment : BaseFragment() {
}
}

fun configLoggedViews() {
signin_button.setOnClickListener { EventBus.getDefault().post(CmdShowLogin()) }
signin_button.visibility = if (App.hasUserLogged) View.INVISIBLE else View.VISIBLE
decks_recycler_view.visibility = if (App.hasUserLogged) View.VISIBLE else View.INVISIBLE
}

@Subscribe
fun onCmdLoginSuccess(cmdLoginSuccess: CmdLoginSuccess) {
configLoggedViews()
showDecks()
}

@Subscribe
fun onCmdUpdateDeckAndShowDeck(cmdUpdateDeckAndShowDeck: CmdUpdateDeckAndShowDeck) {
showDecks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class DeckListAdapter(val itemClick: (View, Card) -> Unit, val itemLongClick: (V
} else {
val newQtd = if (cardSlot.qtd < 3) cardSlot.qtd.inc() else 3
val cardIndex = items.indexOf(cardSlot)
items[cardIndex] = CardSlot(card, newQtd)
items[cardIndex] = CardSlot(card, if (card.unique) 1 else newQtd)
notifyItemChanged(cardIndex)
}
}
Expand Down
Loading

0 comments on commit 6f93709

Please sign in to comment.