Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.5.2 #16

Merged
merged 14 commits into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ DeckBox is **100%** written in [Kotlin](https://kotlinlang.org) and follows an *
* RxJava 2
* Firebase Firestore

## Design
<img src="art/sketch_icon.png" width="64px" />

Check out the designs using [Sketch](https://www.sketchapp.com/)

**Sketch Cloud**
https://sketch.cloud/s/vgnyn

## Build-it Yourself
To build/run DeckBox your self you will need to configure and setup the following items:

Expand All @@ -53,4 +61,4 @@ Please follow the guidelines set forth in the [CONTRIBUTING](CONTRIBUTING.md) do

GNU General Public License v3.0

See [LICENSE](LICENSE) to see the full text.
See [LICENSE](LICENSE) to see the full text.
28 changes: 13 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.oss.licenses.plugin'
apply plugin: 'io.fabric'

def GIT_SHA = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def GIT_TAG = 'git describe --tags'.execute([], project.rootDir).text.trim()

def VERSION_NAME = "1.5.2"

// Optional: configure the versioner

ext.gitVersioner = [
defaultBranch : "development", // default "master"
stableBranches : ["master", "release"], // default [], the feature branch postfix (-dm4(6)) will not be appended on stable branches, all commits are included into the version number calculation
yearFactor : 1200, // default "1000", increasing every 8.57h
snapshotEnabled : false, // default false, the "-SNAPSHOT" postfix
localChangesCountEnabled: false, // default false, the (<commitCount>) before -SNAPSHOT
shortName: { gitVersion -> // optional closure to build a short name
// allows you to add your own short name logic
// All properties from gitVersion are available
// can be used for CI `System.getenv("BUILD_NUMBER")`

// i.e. use short sha1
defaultBranch : "development",
stableBranches : ["master", "release"],
yearFactor : 1200,
snapshotEnabled : false,
localChangesCountEnabled: false,
shortName: { gitVersion ->
return gitVersion.commit.subSequence(0, 7)
}
]

apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'


android {
compileSdkVersion rootProject.ext.compileSdkVersion

Expand Down Expand Up @@ -98,7 +94,9 @@ dependencies {
implementation "com.google.firebase:firebase-config:$play_version"
implementation "com.google.android.gms:play-services-auth:$play_version"
implementation "com.google.android.gms:play-services-oss-licenses:$play_version"
releaseImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.1'
releaseImplementation('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
transitive = true;
}

implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
Expand Down Expand Up @@ -151,7 +149,7 @@ dependencies {
implementation 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
debugImplementation "com.facebook.stetho:stetho:$stetho_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class AppPreferences @Inject constructor(
const val KEY_PLAYER_ID = "pref_player_id"
const val KEY_PLAYER_AGE_DIVISION = "pref_player_age_division"
const val KEY_PLAYER_DOB = "pref_player_dob"
const val KEY_SET_FORBIDDEN_LIGHT = "pref_set_ultraprism_new"

const val KEY_LAST_VERSION = "pref_last_version"
const val KEY_DEVICE_ID = "pref_local_offline_device_id"
const val KEY_SET_ULTRAPRISM = "pref_set_ultraprism_new"

const val KEY_OFFLINE_ENABLED = "pref_offline_enabled"
}
Expand All @@ -39,7 +39,6 @@ class AppPreferences @Inject constructor(
var lastVersion by IntPreference(KEY_LAST_VERSION, -1)
var deviceId by StringPreference(KEY_DEVICE_ID)
var offlineEnabled by BooleanPreference(KEY_OFFLINE_ENABLED, false)
val previewUltraPrism by ReactiveBooleanPreference(KEY_SET_ULTRAPRISM, true)

val expansions by ReactiveExpansionsPreference(KEY_EXPANSIONS)
val basicEnergySet by ReactiveBasicEnergySetPreference(KEY_DEFAULT_ENERGY_SET)
Expand All @@ -49,6 +48,7 @@ class AppPreferences @Inject constructor(
val playerDOB by ReactiveDatePreference(KEY_PLAYER_DOB)
val playerAgeDivision by ReactiveEnumPreference(KEY_PLAYER_AGE_DIVISION, AgeDivision.MASTERS)

val previewNewExpansion by ReactiveBooleanPreference(KEY_SET_FORBIDDEN_LIGHT, true)

fun clear() {
sharedPreferences.edit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import io.requery.reactivex.KotlinReactiveEntityStore
import io.requery.sql.KotlinConfiguration
import io.requery.sql.KotlinEntityDataStore
import okhttp3.logging.HttpLoggingInterceptor.Level.HEADERS
import okhttp3.logging.HttpLoggingInterceptor.Level.BODY
import okhttp3.logging.HttpLoggingInterceptor.Level.NONE
import java.util.concurrent.Executors

Expand Down Expand Up @@ -85,7 +86,7 @@ class DataModule {

@Provides @AppScope
fun providePokemonApiConfig(): Config {
val level = if (BuildConfig.DEBUG) HEADERS else NONE
val level = if (BuildConfig.DEBUG) BODY else NONE
return Config(logLevel = level)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.r0adkll.deckbuilder.arch.data.features.cards.cache


import com.r0adkll.deckbuilder.arch.data.Remote
import com.r0adkll.deckbuilder.arch.domain.features.cards.model.Expansion
import io.reactivex.Observable

Expand All @@ -9,7 +10,9 @@ import io.reactivex.Observable
* In Memory implementation of [Expansion] cache to store a list of
* expansions loaded from API in memory so we don't have to keep requesting it
*/
class InMemoryExpansionCache : ExpansionCache {
class InMemoryExpansionCache(
val remote: Remote
) : ExpansionCache {

private val expansions: ArrayList<Expansion> = ArrayList()

Expand All @@ -21,6 +24,9 @@ class InMemoryExpansionCache : ExpansionCache {


override fun getExpansions(): Observable<List<Expansion>> {
if (expansions.none { it.code == remote.latestExpansion }) {
expansions.clear()
}
return Observable.just(expansions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CachingCardDataSource @Inject constructor(
remote: Remote
) : CardDataSource {

private val memoryCache: ExpansionCache = InMemoryExpansionCache()
private val memoryCache: ExpansionCache = InMemoryExpansionCache(remote)
private val diskCache: ExpansionCache = PreferenceExpansionCache(preferences, remote)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ class CombinedSearchDataSource @Inject constructor(


override fun search(type: SuperType?, query: String, filter: Filter?): Observable<List<PokemonCard>> {
return Observable.concat(network.search(type, query, filter), disk.search(type, query, filter))
.takeUntil { it.isNotEmpty() }
.filter { it.isNotEmpty() }
return network.search(type, query, filter)
// return Observable.concat(network.search(type, query, filter), disk.search(type, query, filter))
// .takeUntil { it.isNotEmpty() }
// .filter { it.isNotEmpty() }
}


override fun find(ids: List<String>): Observable<List<PokemonCard>> {
return Observable.concat(network.find(ids), disk.find(ids))
.takeUntil { it.isNotEmpty() }
.filter { it.isNotEmpty() }
return network.find(ids)
// return Observable.concat(network.find(ids), disk.find(ids))
// .takeUntil { it.isNotEmpty() }
// .filter { it.isNotEmpty() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SetBrowserActivity : BaseActivity(), SetBrowserUi, SetBrowserUi.Intentions
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_set_browser)

state = state.copy(setCode = expansion.code)
state = state.copy(setCode = expansion.code, pageSize = expansion.totalCards)

supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.title = " "
Expand Down Expand Up @@ -174,7 +174,7 @@ class SetBrowserActivity : BaseActivity(), SetBrowserUi, SetBrowserUi.Intentions
inner class TargetPaletteAction : PaletteBitmapViewTarget.PaletteAction {
override fun execute(palette: Palette?) {
palette?.let {
if (expansion.code != "sm5") {
if (expansion.code != "sm6" && expansion.code != "sm5") {
it.vibrantSwatch?.rgb?.let {
backdrop.imageTintList = ColorStateList.valueOf(it)

Expand Down Expand Up @@ -210,5 +210,11 @@ class SetBrowserActivity : BaseActivity(), SetBrowserUi, SetBrowserUi.Intentions
intent.putExtra(EXTRA_EXPANSION, expansion)
return intent
}


fun createIntent(context: Context, setCode: String): Intent {
val expansion = Expansion(setCode, null, "", "", 300, false, false, "", "", "https://images.pokemontcg.io/sm6/logo.png")
return createIntent(context, expansion)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SetBrowserPresenter @Inject constructor(

val handleUnknownError: (Throwable) -> Change = {
Timber.e(it, "Error loading cards")
Change.Error(it.localizedMessage ?: "Unable to load cards for this set")
Change.Error("Unable to load cards for this set")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ interface SetBrowserUi : StateRenderer<SetBrowserUi.State> {
val isLoading: Boolean,
val error: String?,
val cards: List<PokemonCard>,
val filter: BrowseFilter
val filter: BrowseFilter,
val pageSize: Int = 300
) : PaperParcelable {

val searchFilter: Filter
get() = Filter.DEFAULT.copy(expansions = listOf(Expansion(setCode, null, "", "", 0, false, false, "", "", "")))
get() = Filter.DEFAULT.copy(expansions = listOf(Expansion(setCode, null, "", "", 0, false, false, "", "", "")), pageSize = pageSize)


fun reduce(change: Change): State = when(change) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BrowsePresenter @Inject constructor(
companion object {
val handleUnknownError: (Throwable) -> Change = {
Timber.e(it, "Error loading expansions")
Change.Error(it.localizedMessage ?: "Error loading expansions")
Change.Error("Error loading expansions")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ class CardDetailPresenter @Inject constructor(
it.cards.filter { it.id == ui.state.card?.id }.count()
}
.map { Change.CountChanged(it) as Change }
.onErrorReturn(handleUnknownError)
} ?: Observable.empty<Change>()

val loadValidation = validator.validate(listOf(ui.state.card!!))
.map { Change.Validated(it) as Change }
.onErrorReturn(handleUnknownError)

val loadVariants = repository.search(ui.state.card!!.supertype, "\"${ui.state.card!!.name}\"")
// FIXME: Replace with actual error implementation
.onErrorReturnItem(emptyList())
.map { it.filter { it.id != ui.state.card!!.id } }
.map { Change.VariantsLoaded(it) as Change }
.onErrorReturn(handleUnknownError)

val loadEvolves = ui.state.card!!.evolvesFrom?.let {
// FIXME: Replace with actual error implementation
repository.search(ui.state.card!!.supertype, "\"$it\"")
.onErrorReturnItem(emptyList())
.map { Change.EvolvesFromLoaded(it) as Change }
.onErrorReturn(handleUnknownError)
} ?: Observable.empty()

disposables += intentions.addCardClicks()
Expand All @@ -72,4 +72,13 @@ class CardDetailPresenter @Inject constructor(
.logState()
.subscribe { ui.render(it) }
}


companion object {

val handleUnknownError: (Throwable) -> Change = {
Timber.e(it, "Unknown error has occurred")
Change.Error("An unknown error has occurred")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface CardDetailUi : StateRenderer<CardDetailUi.State> {
data class State(
val sessionId: Long?,
val card: PokemonCard?,
val error: String?,
val count: Int?,
val variants: List<PokemonCard>,
val evolvesFrom: List<PokemonCard>,
Expand All @@ -45,6 +46,7 @@ interface CardDetailUi : StateRenderer<CardDetailUi.State> {


fun reduce(change: Change): State = when(change) {
is Change.Error -> this.copy(error = error)
is Change.CountChanged -> this.copy(count = change.count)
is Change.Validated -> this.copy(validation = change.validation)
is Change.VariantsLoaded -> this.copy(variants = change.cards)
Expand All @@ -53,6 +55,7 @@ interface CardDetailUi : StateRenderer<CardDetailUi.State> {


sealed class Change(val logText: String) {
class Error(val description: String): Change("error -> $description")
class CountChanged(val count: Int) : Change("user -> number of copies changed $count")
class VariantsLoaded(val cards: List<PokemonCard>) : Change("network -> variants loaded")
class EvolvesFromLoaded(val cards: List<PokemonCard>) : Change("network -> evolves loaded")
Expand All @@ -69,7 +72,7 @@ interface CardDetailUi : StateRenderer<CardDetailUi.State> {
@JvmField val CREATOR = PaperParcelCardDetailUi_State.CREATOR

val DEFAULT by lazy {
CardDetailUi.State(null, null, null, emptyList(), emptyList(), Validation(false, false, emptyList()))
CardDetailUi.State(null, null, null, null, emptyList(), emptyList(), Validation(false, false, emptyList()))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DeckBuilderPresenter @Inject constructor(

private val handleUnknownError: (Throwable) -> Change = { t ->
Timber.e(t, "Error processing deck")
Change.Error(t.localizedMessage)
Change.Error("Error validating your deck")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class DeckImagePresenter @Inject constructor(

val handleUnknownError: (Throwable) -> Change = {
Timber.e(it, "Unknown error loading session")
Change.Error(it.localizedMessage ?: "Unable to find any Pokémon cards in your deck to set an image with.")
Change.Error("Unable to find any Pokémon cards in your deck to set an image with.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class DecksFragment : BaseFragment(), DecksUi, DecksUi.Intentions, DecksUi.Actio

disposables += viewPreview
.subscribe {
startActivity(SetBrowserActivity.createIntent(activity!!, "sm6"))
}

renderer.start()
Expand Down Expand Up @@ -149,7 +150,7 @@ class DecksFragment : BaseFragment(), DecksUi, DecksUi.Intentions, DecksUi.Actio
}


override fun dismissPreview(): Observable<Unit> = dismissPreview.doOnNext { Analytics.event(Event.SelectContent.Action("dismiss_preview", "Ultra Prism")) }
override fun dismissPreview(): Observable<Unit> = dismissPreview.doOnNext { Analytics.event(Event.SelectContent.Action("dismiss_preview", "Forbidden Light")) }
override fun shareClicks(): Observable<Deck> = shareClicks
override fun duplicateClicks(): Observable<Deck> = duplicateClicks
override fun deleteClicks(): Observable<Deck> = deleteClicks.flatMap { deck ->
Expand Down
Loading