Skip to content

Commit

Permalink
Merge branch 'release/v0.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
edipo2s committed Dec 31, 2016
2 parents 6f93709 + ad96a0f commit 89b4797
Show file tree
Hide file tree
Showing 85 changed files with 1,839 additions and 1,149 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ android {
'LICENSE.txt', 'NOTICE.txt', 'README.txt', '.readme']
defaultConfig {
applicationId "com.ediposouza.teslesgendstracker"
minSdkVersion prepareRelease ? 16 : 21
minSdkVersion prepareToRelease ? 16 : 21
targetSdkVersion 25
versionCode appVersionCode
versionName appVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

buildConfigField("boolean", "ENABLE_LOGS_IN_RELEASE", "false")
buildConfigField("boolean", "PREPARE_TO_RELEASE", "$prepareToRelease")
buildConfigField("String", "MIXPANEL_TOKEN", '"eb99af1dad563cbaaf02f008b28e321f"')
buildConfigField("String", "GCM_SENDER", '"597127048287"')
vectorDrawables.useSupportLibrary true
Expand Down Expand Up @@ -58,7 +59,7 @@ ext {
icePickVersion = "3.2.+"
okIOVersion = "1.10.+"
okHttpVersion = "3.4.+"
playServicesVersion = prepareRelease ? "10.0.1" : "9.8.0"
playServicesVersion = prepareToRelease ? "10.0.1" : "9.8.0"
supportLibraryVersion = "25.1.0"
threetenabpVersion = "1.0.+"

Expand Down
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#}

## TES Legends Tracker
-keepclassmembers class com.ediposouza.teslesgendstracker.interactor.*Parser { *; }
-keepclassmembers class com.ediposouza.teslesgendstracker.interactor.FirebaseParsers$* { *; }

## Kotlin
-dontwarn kotlin.**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ediposouza.teslesgendstracker.manager
package com.ediposouza.teslesgendstracker.util

import timber.log.Timber

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.ediposouza.teslesgendstracker.manager
package com.ediposouza.teslesgendstracker.util

import android.content.Context
import com.ediposouza.teslesgendstracker.MetricAction
import com.ediposouza.teslesgendstracker.MetricScreen
import com.ediposouza.teslesgendstracker.MetricsConstants
import com.ediposouza.teslesgendstracker.data.Card
import com.google.firebase.auth.FirebaseUser
import timber.log.Timber
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
android:screenOrientation="portrait" />
<activity
android:name=".ui.decks.new.NewDeckActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />

<receiver
android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
Expand All @@ -57,10 +58,17 @@
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_legend" />

<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />

<meta-data
android:name="io.fabric.ApiKey"
android:value="e056905fcbc01f84ea9cad8acf63b74cb07f2506" />

</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 19 additions & 5 deletions app/src/main/kotlin/com/ediposouza/teslesgendstracker/App.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.ediposouza.teslesgendstracker

import android.app.Application
import android.content.Context
import android.support.v7.app.AppCompatDelegate
import com.ediposouza.teslesgendstracker.interactor.BaseInteractor
import com.ediposouza.teslesgendstracker.manager.LoggerManager
import com.ediposouza.teslesgendstracker.manager.MetricsManager
import com.ediposouza.teslesgendstracker.util.ConfigManager
import com.ediposouza.teslesgendstracker.util.LoggerManager
import com.ediposouza.teslesgendstracker.util.MetricsManager
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
import com.jakewharton.threetenabp.AndroidThreeTen
import timber.log.Timber
Expand All @@ -16,24 +19,35 @@ class App : Application() {

companion object {

var hasUserLogged: Boolean = false
private var ctx: Context? = null

var hasUserAlreadyLogged: Boolean = false

fun hasUserLogged(): Boolean = FirebaseAuth.getInstance().currentUser != null

fun getVersion() = ctx?.packageManager?.getPackageInfo(ctx?.packageName, 0)?.versionName ?: ""

}

override fun onCreate() {
super.onCreate()
ctx = applicationContext
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
initializeDependencies()
}

private fun initializeDependencies() {
Timber.plant(LoggerManager())
MetricsManager.initialize(this)
AndroidThreeTen.init(this)
FirebaseDatabase.getInstance().apply {
setPersistenceEnabled(true)
reference.child(BaseInteractor.NODE_CARDS).keepSynced(true)
ConfigManager.updateCaches {
val sync = !ConfigManager.isDBUpdating() && !ConfigManager.isVersionUnsupported()
reference.child(BaseInteractor.NODE_CARDS).keepSynced(sync)
reference.child(BaseInteractor.NODE_PATCHES).keepSynced(sync)
}
}
Timber.plant(LoggerManager())
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ package com.ediposouza.teslesgendstracker
/**
* Created by EdipoSouza on 11/15/16.
*/
val TIME_PATTERN = "HH:mm"
val TIME_PATTERN = "HH:mm"

val DEFAULT_DELIMITER = ";"
31 changes: 18 additions & 13 deletions app/src/main/kotlin/com/ediposouza/teslesgendstracker/data/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ enum class CardSet(val db: String) {

}

enum class Attribute(val color: Int, @IntegerRes val imageRes: Int) {
enum class Attribute(@IntegerRes val imageRes: Int) {

STRENGTH(Color.RED, R.drawable.attr_strength),
INTELLIGENCE(Color.BLUE, R.drawable.attr_intelligence),
WILLPOWER(Color.YELLOW, R.drawable.attr_willpower),
AGILITY(Color.GREEN, R.drawable.attr_agility),
ENDURANCE(Color.parseColor("purple"), R.drawable.attr_endurance),
NEUTRAL(Color.GRAY, R.drawable.attr_neutral),
DUAL(Color.LTGRAY, R.drawable.attr_dual)
STRENGTH(R.drawable.attr_strength),
INTELLIGENCE(R.drawable.attr_intelligence),
WILLPOWER(R.drawable.attr_willpower),
AGILITY(R.drawable.attr_agility),
ENDURANCE(R.drawable.attr_endurance),
NEUTRAL(R.drawable.attr_neutral),
DUAL(R.drawable.attr_dual)

}

Expand Down Expand Up @@ -90,7 +90,7 @@ enum class CardRarity(val color: Int, val soulCost: Int, @IntegerRes val imageRe

}

enum class CardType() {
enum class CardType {

ACTION,
CREATURE,
Expand Down Expand Up @@ -175,7 +175,7 @@ enum class CardRace(val desc: String) {
}
}

enum class CardKeyword() {
enum class CardKeyword {

ACTIVATE,
BREAKTHROUGH,
Expand Down Expand Up @@ -205,7 +205,7 @@ enum class CardKeyword() {
}
}

enum class CardArenaTier() {
enum class CardArenaTier {

TERRIBLE,
POOR,
Expand All @@ -231,7 +231,7 @@ data class CardMissing(

val shortName: String,
val rarity: CardRarity,
val qtd: Long
val qtd: Int

)

Expand Down Expand Up @@ -262,7 +262,7 @@ data class Card(
val arenaTier: CardArenaTier,
val evolves: Boolean

) : Parcelable {
) : Comparable<Card>, Parcelable {

private val CARD_BACK = "card_back.png"
private val CARD_PATH = "Cards"
Expand Down Expand Up @@ -314,4 +314,9 @@ data class Card(
dest?.writeInt(arenaTier.ordinal)
dest?.writeInt((if (evolves) 1 else 0))
}

override fun compareTo(other: Card): Int {
val compareCost = cost.compareTo(other.cost)
return if (compareCost != 0) compareCost else name.compareTo(other.name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.os.Parcelable
import org.threeten.bp.LocalDateTime
import java.util.*

enum class DeckType() {
enum class DeckType {

AGGRO,
ARENA,
Expand Down Expand Up @@ -82,7 +82,7 @@ data class Deck(
val patch: String,
val likes: List<String>,
val views: Int,
val cards: Map<String, Long>,
val cards: Map<String, Int>,
val updates: List<DeckUpdate>,
val comments: List<DeckComment>

Expand All @@ -102,7 +102,7 @@ data class Deck(
1 == source.readInt(), DeckType.values()[source.readInt()], Class.values()[source.readInt()],
source.readInt(), source.readSerializable() as LocalDateTime, source.readSerializable() as LocalDateTime,
source.readString(), source.createStringArrayList(), source.readInt(),
hashMapOf<String, Long>().apply { source.readMap(this, Long::class.java.classLoader) },
hashMapOf<String, Int>().apply { source.readMap(this, Int::class.java.classLoader) },
ArrayList<DeckUpdate>().apply { source.readList(this, DeckUpdate::class.java.classLoader) },
ArrayList<DeckComment>().apply { source.readList(this, DeckComment::class.java.classLoader) })

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
package com.ediposouza.teslesgendstracker.data

import android.os.Parcel
import android.os.Parcelable

/**
* Created by EdipoSouza on 10/31/16.
*/
data class CardSlot(

val card: Card,
val qtd: Long
val qtd: Int

) : Comparable<CardSlot>, Parcelable {

companion object {
@JvmField val CREATOR: Parcelable.Creator<CardSlot> = object : Parcelable.Creator<CardSlot> {
override fun createFromParcel(source: Parcel): CardSlot = CardSlot(source)
override fun newArray(size: Int): Array<CardSlot?> = arrayOfNulls(size)
}
}

constructor(source: Parcel) : this(source.readParcelable<Card>(Card::class.java.classLoader),
source.readInt())

override fun compareTo(other: CardSlot): Int = card.compareTo(other.card)

override fun describeContents() = 0

)
override fun writeToParcel(dest: Parcel?, flags: Int) {
dest?.writeParcelable(card, 0)
dest?.writeInt(qtd)
}
}

data class Patch(

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ package com.ediposouza.teslesgendstracker.interactor

import com.ediposouza.teslesgendstracker.data.Attribute
import com.ediposouza.teslesgendstracker.data.CardSet
import com.ediposouza.teslesgendstracker.util.ConfigManager
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.Query

/**
* Created by ediposouza on 01/11/16.
*/
open class BaseInteractor() {
open class BaseInteractor {

companion object {

val NODE_CARDS = "cards"
val NODE_PATCHES = "patches"

}

Expand All @@ -26,11 +30,9 @@ open class BaseInteractor() {
protected val KEY_DECK_CLASS = "cls"
protected val KEY_DECK_UPDATE_AT = "updatedAt"

protected val database by lazy { FirebaseDatabase.getInstance().reference }

protected val dbDecks by lazy { database.child(NODE_DECKS) }

protected val dbUsers by lazy { database.child(NODE_USERS) }
protected val database: DatabaseReference by lazy { FirebaseDatabase.getInstance().reference }
protected val dbDecks: DatabaseReference by lazy { database.child(NODE_DECKS) }
protected val dbUsers: DatabaseReference by lazy { database.child(NODE_USERS) }

fun <T> getListFromSets(set: CardSet?, onSuccess: (List<T>) -> Unit,
getFromSet: (set: CardSet, onSuccess: (List<T>) -> Unit) -> Unit) {
Expand Down Expand Up @@ -88,4 +90,8 @@ open class BaseInteractor() {
getFromSet(CardSet.values()[setIndex], attr, getSetsOnSuccess(attr, onSuccess))
}

fun Query.keepSynced() {
keepSynced(!ConfigManager.isDBUpdating() && !ConfigManager.isVersionUnsupported())
}

}
Loading

0 comments on commit 89b4797

Please sign in to comment.