Skip to content

Commit

Permalink
Merge branch 'release/v1.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
edipo2s committed Jul 29, 2017
2 parents 90094b7 + 66e2f6a commit bb39938
Show file tree
Hide file tree
Showing 70 changed files with 357 additions and 83 deletions.
32 changes: 19 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
//apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 26
buildToolsVersion "26.0.1"
packagingOptions.excludes = ['META-INF/services/javax.annotation.processing.Processor',
'META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/README.txt',
'LICENSE.txt', 'NOTICE.txt', 'README.txt', '.readme']
Expand All @@ -16,7 +16,7 @@ android {
props.load(file("secrets.properties").newInputStream())
defaultConfig {
applicationId "com.ediposouza.teslesgendstracker"
minSdkVersion prepareToRelease ? 16 : 21
minSdkVersion prepareToRelease ? 17 : 21
targetSdkVersion 26
versionCode appVersionCode
versionName appVersionName
Expand Down Expand Up @@ -77,20 +77,26 @@ kotlin {
}

ext {
anko_version = "0.9.1"
anko_version = "0.10.1"
coroutines_version = "0.15"
okIOVersion = "1.12.+"
okHttpVersion = "3.7.+"
playServicesVersion = "10.2.4"
supportLibraryVersion = "25.4.0"
threetenabpVersion = "1.0.+"
okIOVersion = "1.13.0"
okHttpVersion = "3.8.1"
playServicesVersion = "11.0.4"
supportLibraryVersion = "26.0.0"
threetenabpVersion = "1.0.5"

testMockitoVersion = "2.7.+"
testRoboletricVersion = "3.2.+"
}

configurations.all {
resolutionStrategy{
eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support" && !requested.name.startsWith("multidex")) {
details.useVersion "$supportLibraryVersion"
}
}
force "com.android.support:support-annotations:$supportLibraryVersion"
force "com.squareup.okio:okio:$okIOVersion"
force "com.squareup.okhttp3:okhttp:$okHttpVersion"
Expand Down Expand Up @@ -124,10 +130,10 @@ dependencies {
compile "com.google.firebase:firebase-config:$playServicesVersion"
compile "com.google.firebase:firebase-database:$playServicesVersion"
compile "com.google.firebase:firebase-messaging:$playServicesVersion"
// compile "com.google.firebase:firebase-perf:$playServicesVersion"
compile "com.google.firebase:firebase-perf:$playServicesVersion"
releaseCompile "com.google.firebase:firebase-crash:$playServicesVersion"
compile "com.google.firebase:firebase-storage:10.2.1"
compile "com.firebaseui:firebase-ui-storage:1.2.0"
compile "com.google.firebase:firebase-storage:$playServicesVersion"
compile "com.firebaseui:firebase-ui-storage:2.1.1"

//Fabric
compile('com.crashlytics.sdk.android:answers:1.3.13') {
Expand Down
Binary file modified app/src/main/assets/Arts/Core/Agility/blacksapprotector_alt.webp
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Arts/Core/Endurance/stonetoothscrapper_alt.webp
Binary file not shown.
Binary file modified app/src/main/assets/Arts/Core/Neutral/crushingblow_alt.webp
Binary file not shown.
Binary file modified app/src/main/assets/Arts/Core/Strength/sharpshooterscout_alt.webp
Binary file not shown.
Binary file modified app/src/main/assets/Arts/Core/Willpower/hivedefender_alt.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Agility/pahmarrahtrenegade.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Dual/shornhelmchampion.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Endurance/bloodmagiclord.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Endurance/iliacsorcerer.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Endurance/lucienlachance.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Endurance/nighttalonlord.webp
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Intelligence/bretonconjurer.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Intelligence/daggerfallmage.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Strength/belligerentgiant.webp
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Strength/childofhircine.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Core/Willpower/dawnstarhealer.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified app/src/main/assets/Cards/Heroesofskyrim/Neutral/barbas.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions app/src/main/kotlin/com/ediposouza/teslesgendstracker/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class App : MultiDexApplication() {
PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(PREF_USER_DONATE, false)
}

fun isFirstRun(): Boolean {
val firstRun = PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(PREF_FIRST_RUN, true)
PreferenceManager.getDefaultSharedPreferences(ctx).edit().putBoolean(PREF_FIRST_RUN, false).apply()
return firstRun
}

fun shouldShowChangelog(): Boolean {
return !PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(getVersion(), false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ val ARENA_TIER_PLUS_VALUE_DELIMITER = "_"
val TEXT_UNKNOWN = "unknown"
val DECK_NAME_MIN_SIZE = 5

val PREF_FIRST_RUN = "firstRun"
val PREF_USER_DONATE = "ud"
val PREF_USER_LANGUAGE = "language"
val PREF_NEWS_CHECK_LAST_TIME = "newsCheckPref"
Expand Down
38 changes: 30 additions & 8 deletions app/src/main/kotlin/com/ediposouza/teslesgendstracker/data/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,18 @@ enum class CardAttribute(@DrawableRes val imageRes: Int, val isBasic: Boolean =
AGILITY(R.drawable.attr_agility),
ENDURANCE(R.drawable.attr_endurance),
NEUTRAL(R.drawable.attr_neutral, false),
DUAL(R.drawable.attr_dual, false)
DUAL(R.drawable.attr_dual, false),
UNKNOWN(R.drawable.attr_neutral, false);

companion object {

fun of(value: String): CardAttribute {
val name = value.trim().toUpperCase().replace(" ", "_")
return if (values().map { it.name }.contains(name)) valueOf(name) else UNKNOWN
}

}


}

Expand Down Expand Up @@ -402,7 +413,8 @@ data class Card(
val generates: List<String>,
val tokens: List<String>,
val lore: String,
val loreLink: String
val loreLink: String,
val hasAlternativeArt: Boolean

) : Comparable<Card>, Parcelable {

Expand All @@ -415,8 +427,9 @@ data class Card(
val DUMMY = Card("", "", CardSet.CORE, CardAttribute.DUAL, CardAttribute.STRENGTH,
CardAttribute.WILLPOWER, CardRarity.EPIC, false, 0, 0, 0, CardType.ACTION,
CardRace.ARGONIAN, emptyList<CardKeyword>(), "", CardArenaTier.AVERAGE,
listOf(), false, "", 0, listOf(), listOf(), listOf(), "", "")
listOf(), false, "", 0, listOf(), listOf(), listOf(), "", "", false)

const val ALT_SUFFIX = "_alt"
const val ARTS_PATH = "Arts"
const val ARTS_TOKENS_PATH = "TokensArts"
const val SOUNDS_PATH = "Sounds"
Expand All @@ -438,7 +451,8 @@ data class Card(
1 == source.readInt(), source.readString(), source.readInt(),
mutableListOf<String>().apply { source.readStringList(this) },
mutableListOf<String>().apply { source.readStringList(this) },
mutableListOf<String>().apply { source.readStringList(this) }, source.readString(), source.readString())
mutableListOf<String>().apply { source.readStringList(this) }, source.readString(),
source.readString(), 1 == source.readInt())

override fun describeContents() = 0

Expand Down Expand Up @@ -492,22 +506,29 @@ data class Card(
}
}

fun isAlternativeArt(): Boolean = shortName.endsWith(ALT_SUFFIX)

fun toAlternativeArt(): Card = copy(shortName = "$shortName$ALT_SUFFIX")

fun canGenerateCards(): Boolean = generates.isNotEmpty()

fun canGenerateTokens(): Boolean = tokens.isNotEmpty()

fun isToken(): Boolean = creators.isNotEmpty()

fun hasLocalAttackSound(resources: Resources): Boolean {
return resources.getAssets().list(getLocalCardSoundPath()).contains("${shortName}_$SOUND_TYPE_ATTACK.mp3")
return resources.getAssets().list(getLocalCardSoundPath())
.contains("${shortName.removeSuffix(ALT_SUFFIX)}_$SOUND_TYPE_ATTACK.mp3")
}

fun hasLocalPlaySound(resources: Resources): Boolean {
return resources.getAssets().list(getLocalCardSoundPath()).contains("${shortName}_$SOUND_TYPE_PLAY.mp3")
return resources.getAssets().list(getLocalCardSoundPath())
.contains("${shortName.removeSuffix(ALT_SUFFIX)}_$SOUND_TYPE_PLAY.mp3")
}

fun hasLocalExtraSound(resources: Resources): Boolean {
return resources.getAssets().list(getLocalCardSoundPath()).contains("${shortName}_$SOUND_TYPE_EXTRA.mp3")
return resources.getAssets().list(getLocalCardSoundPath())
.contains("${shortName.removeSuffix(ALT_SUFFIX)}_$SOUND_TYPE_EXTRA.mp3")
}

private fun getLocalCardSoundPath(): String {
Expand All @@ -525,7 +546,7 @@ data class Card(
private fun soundPath(type: String): String {
val setName = set.name.toLowerCase().capitalize()
val attrName = attr.name.toLowerCase().capitalize()
return "$SOUNDS_PATH/$setName/$attrName/${shortName}_$type.mp3"
return "$SOUNDS_PATH/$setName/$attrName/${shortName.removeSuffix(ALT_SUFFIX)}_$type.mp3"
}

override fun writeToParcel(dest: Parcel?, flags: Int) {
Expand Down Expand Up @@ -554,6 +575,7 @@ data class Card(
dest?.writeStringList(tokens)
dest?.writeString(lore)
dest?.writeString(loreLink)
dest?.writeInt((if (hasAlternativeArt) 1 else 0))
}

override fun compareTo(other: Card): Int {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ abstract class FirebaseParsers {
val tokens: String = ""
val lore: String = ""
val loreLink: String = ""
val alternativeArt: Boolean = false

fun toCard(shortName: String, set: CardSet, attr: CardAttribute): Card {
var clsAttr1 = attr
var clsAttr2 = attr
if (attr == CardAttribute.DUAL) {
clsAttr1 = CardAttribute.valueOf(attr1.trim().toUpperCase())
clsAttr2 = CardAttribute.valueOf(attr2.trim().toUpperCase())
clsAttr1 = CardAttribute.of(attr1.trim().toUpperCase())
clsAttr2 = CardAttribute.of(attr2.trim().toUpperCase())
}
return Card(name, shortName, set, attr, clsAttr1, clsAttr2, CardRarity.of(rarity), unique,
cost.toIntSafely(), attack.toIntSafely(), health.toIntSafely(),
Expand All @@ -56,7 +57,7 @@ abstract class FirebaseParsers {
},
text, CardArenaTier.of(arenaTier), getCardArenaTierPlus(), evolves, season, shout,
creators.split(", ").filter { it.isNotEmpty() }, generates.split(", ").filter { it.isNotEmpty() },
tokens.split(", ").filter { it.isNotEmpty() }, lore, loreLink)
tokens.split(", ").filter { it.isNotEmpty() }, lore, loreLink, alternativeArt)
}

private fun getCardArenaTierPlus(): List<CardArenaTierPlus?> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ object PrivateInteractor : BaseInteractor() {
}

fun setUserCardQtd(card: Card, qtd: Int, onComplete: () -> Unit) {
var cardQtd = qtd.takeUnless { qtd < 0 } ?: 0
if (card.unique && qtd > 1) {
cardQtd = 1
}
dbUserCards(card.set, card.attr)?.apply {
child(card.shortName).child(KEY_CARD_QTD).setValue(qtd).addOnCompleteListener {
child(card.shortName).child(KEY_CARD_QTD).setValue(cardQtd).addOnCompleteListener {
onComplete.invoke()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object PublicInteractor : BaseInteractor() {

override fun onDataChange(ds: DataSnapshot) {
val cards = ds.children.map {
val attr = CardAttribute.valueOf(it.key.toUpperCase())
val attr = CardAttribute.of(it.key.toUpperCase())
it.children.map {
it.getValue(FirebaseParsers.CardParser::class.java)?.toCard(it.key, set, attr)
}.filterNotNull()
Expand Down Expand Up @@ -100,7 +100,8 @@ object PublicInteractor : BaseInteractor() {
it.getValue(FirebaseParsers.CardParser::class.java)?.toCard(it.key, set, attr)
}.filterNotNull()
Timber.d(cards.toString())
onEachSuccess.invoke(cards)
val cardsAlternativeArt = cards.filter { it.hasAlternativeArt }.map { it.toAlternativeArt() }
onEachSuccess.invoke(cards.plus(cardsAlternativeArt))
}

override fun onCancelled(de: DatabaseError) {
Expand All @@ -119,8 +120,8 @@ object PublicInteractor : BaseInteractor() {

override fun onDataChange(ds: DataSnapshot) {
val reviews = ds.children.map {
it.key to it.getValue(Int::class.java)
}.toList()
it.key to (it.getValue(Int::class.java) ?: -1)
}.filter { it.second >= 0 }.toList()
onSuccess.invoke(reviews)
}

Expand All @@ -140,7 +141,7 @@ object PublicInteractor : BaseInteractor() {

override fun onDataChange(ds: DataSnapshot) {
val cards = ds.children.map {
val attr = CardAttribute.valueOf(it.key.toUpperCase())
val attr = CardAttribute.of(it.key.toUpperCase())
it.children.map {
it.getValue(FirebaseParsers.CardParser::class.java)?.toCard(it.key, set, attr)
}.filterNotNull()
Expand Down Expand Up @@ -243,7 +244,7 @@ object PublicInteractor : BaseInteractor() {
unknownSetTitle = spoilerTitle
}
val cards = ds.children.map {
val attr = CardAttribute.valueOf(it.key.toUpperCase())
val attr = CardAttribute.of(it.key.toUpperCase())
it.children.map {
it.getValue(FirebaseParsers.CardParser::class.java)?.toCard(it.key, set, attr)
}.filterNotNull()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import kotlinx.android.synthetic.main.navigation_drawer_header.view.*
import org.greenrobot.eventbus.Subscribe
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.itemsSequence
import org.jetbrains.anko.longToast
import org.jetbrains.anko.toast
import timber.log.Timber

Expand Down Expand Up @@ -357,6 +358,7 @@ class DashActivity : BaseFilterActivity(),
}

private fun showLanguageDialog(): Boolean {
longToast(R.string.about_language_warning)
val languages = resources.getStringArray(R.array.languages)
AlertDialog.Builder(this, R.style.AppDialog)
.setAdapter(object : ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, languages) {
Expand Down Expand Up @@ -440,6 +442,15 @@ class DashActivity : BaseFilterActivity(),
AlertDialog.Builder(this, R.style.AppDialog)
.setTitle(R.string.title_changelog)
.setPositiveButton(android.R.string.ok, null)
.setOnDismissListener {
if (App.isFirstRun()) {
AlertDialog.Builder(this, R.style.AppDialog)
.setTitle(R.string.app_name_full)
.setMessage(R.string.app_warning)
.setPositiveButton(android.R.string.ok, null)
.show()
}
}
.create()
.apply {
setView(ChangeLogRecyclerView(context))
Expand Down Expand Up @@ -525,7 +536,7 @@ class DashActivity : BaseFilterActivity(),
}

private fun getStatisticsBottomSheetBehavior(): BottomSheetBehavior<*>? {
findViewById(R.id.cards_collection_statistics)?.apply {
findViewById<View>(R.id.cards_collection_statistics)?.apply {
return BottomSheetBehavior.from<View>(this)
}
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ class ArenaDraftCards(ctx: Context?, attrs: AttributeSet?, defStyleAttr: Int) :
CardArenaTierPlusType.COST -> getExtraPointsForIntValue(arenaTierPlus, draftedCard.cost)
CardArenaTierPlusType.HEALTH -> getExtraPointsForIntValue(arenaTierPlus, draftedCard.health)
CardArenaTierPlusType.ATTR -> extraPoints.takeIf {
!reverseCalc && (draftedCard.attr == CardAttribute.valueOf(arenaTierPlus.value.toUpperCase()) ||
draftedCard.dualAttr1 == CardAttribute.valueOf(arenaTierPlus.value.toUpperCase()) ||
draftedCard.dualAttr2 == CardAttribute.valueOf(arenaTierPlus.value.toUpperCase()))
!reverseCalc && (draftedCard.attr == CardAttribute.of(arenaTierPlus.value.toUpperCase()) ||
draftedCard.dualAttr1 == CardAttribute.of(arenaTierPlus.value.toUpperCase()) ||
draftedCard.dualAttr2 == CardAttribute.of(arenaTierPlus.value.toUpperCase()))
} ?: 0
CardArenaTierPlusType.KEYWORD -> extraPoints.takeIf {
draftedCard.keywords.filter { it.name == arenaTierPlus.value.toUpperCase() }.isNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ open class BaseActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFaile

override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
setSupportActionBar(findViewById(R.id.toolbar) as Toolbar?)
setSupportActionBar(findViewById<View>(R.id.toolbar) as Toolbar?)
supportActionBar?.title = ""
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_back)
contentView?.viewTreeObserver?.addOnGlobalLayoutListener(keyboardChangeListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ediposouza.teslesgendstracker.ui.base
import android.support.annotation.LayoutRes
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.ediposouza.teslesgendstracker.R
import com.ediposouza.teslesgendstracker.util.inflate
Expand Down Expand Up @@ -37,7 +38,7 @@ abstract class BaseAdsAdapter(val adsEachItems: Int, @LayoutRes val adsLayout: I
return onCreateDefaultViewHolder(parent)
} else {
val adsItemView = parent.inflate(adsLayout)
val ads = adsItemView.findViewById(R.id.ads_view)
val ads = adsItemView.findViewById<View>(R.id.ads_view)
when (ads) {
is AdView -> ads.load()
is NativeExpressAdView -> ads.load()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ediposouza.teslesgendstracker.ui.base
import android.support.annotation.LayoutRes
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import com.ediposouza.teslesgendstracker.R
import com.ediposouza.teslesgendstracker.util.inflate
Expand Down Expand Up @@ -37,7 +38,7 @@ abstract class BaseAdsFirebaseAdapter<T, VH : RecyclerView.ViewHolder>(model: Cl
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == VIEW_TYPE_ADS) {
val adsItemView = parent.inflate(adsLayout)
val ads = adsItemView.findViewById(R.id.ads_view)
val ads = adsItemView.findViewById<View>(R.id.ads_view)
when (ads) {
is AdView -> ads.load()
is NativeExpressAdView -> ads.load()
Expand Down
Loading

0 comments on commit bb39938

Please sign in to comment.