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

RC Version 1.10.0 #107

Merged
merged 19 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
6c17863
Re-organizing collection repository
r0adkll Oct 23, 2019
8f7a5ef
Close #94 - Updated support contact email
r0adkll Oct 23, 2019
2fe7383
#99 - Improved the scrolling performance of the home screen w/ collec…
r0adkll Oct 23, 2019
7697363
#99 - Added toggle action that let's users view only missing cards in…
r0adkll Oct 23, 2019
e7ac39e
Close #99 - Added action to let user's increment an entire set at once
r0adkll Oct 23, 2019
87eec53
#101 - Added debounce to card clicks to reduce freqency at which a us…
r0adkll Oct 23, 2019
974d930
Fixed #100 - Fixed promo legal override issues where cards in the cut…
r0adkll Oct 23, 2019
fc57de3
Fixed #102 - Patched SDK for issue with cards not loading on some sets
r0adkll Oct 23, 2019
057c50b
Fixed Crashlytics#126 -> NPE in EditDragListener.kt causing crashes o…
r0adkll Oct 23, 2019
1179981
Fixed Crashlytics crash
r0adkll Oct 23, 2019
1ef697b
Refactoring out the old ListRecyclerAdapter in favor of one that comp…
r0adkll Oct 24, 2019
df1e3de
Copy and visual tweaks
r0adkll Oct 24, 2019
4f2c5f5
Fixed crashlytics issue in PCV
r0adkll Oct 24, 2019
c039010
Added some more login failure guards to close crashlytics issue
r0adkll Oct 24, 2019
b17400c
Added analytic calls to marketplace integrations and new collection a…
r0adkll Oct 25, 2019
312fcc9
Added app referrer to custom tabs
r0adkll Oct 25, 2019
e660131
Fixed #106 - updated privacy policy url to new domain
r0adkll Oct 25, 2019
532b9fd
Updated CHANGELOG.md
r0adkll Oct 25, 2019
186edc2
Updated Target to API 29 (Q)
r0adkll Oct 25, 2019
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## 1.10.0
* [#5](https://github.com/r0adkll/DeckBox/issues/5) - Added pricing data from TCGPlayer API via Cloud Function + Firestore
* [#94](https://github.com/r0adkll/DeckBox/issues/94) - Updated support contact url
* [#99](https://github.com/r0adkll/DeckBox/issues/99) - Several improvements around Collection feature
* [#100](https://github.com/r0adkll/DeckBox/issues/100) - Fixed issue with promo legal overrides that belong to expanded showing as unlimited
* [#101](https://github.com/r0adkll/DeckBox/issues/101) - Fixed rapid clicking cards in builder interface issue
* [#102](https://github.com/r0adkll/DeckBox/issues/102) - Fixed model issues with API causing some expansion set's to not load cards
* [#106](https://github.com/r0adkll/DeckBox/issues/106) - Updated Privacy Policy URL

## 1.9.2
* [#85](https://github.com/r0adkll/DeckBox/issues/85) - Fixed issue with incorrect sorting of promo cards and special sets
Expand Down
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master


android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "com.r0adkll.deckbuilder"
buildToolsVersion "28.0.3"

minSdkVersion 22
targetSdkVersion 28
targetSdkVersion 29

versionCode gitVersion.version
versionName "$VERSION_NAME.${gitVersion.version}"
Expand Down Expand Up @@ -96,9 +96,9 @@ ext {
glide_version = '4.0.0'
leakcanary_version = '1.5.1'
play_version = '15.0.0'
poketcg_version = '1.0.18'
poketcg_version = '1.0.19'
retrofit_version = '2.3.0'
room_version = '2.2.0'
room_version = '2.2.1'
rxjava_version = '2.1.3'
rxandroid_version = '2.0.1'
rxbinding_version = '2.2.0'
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/r0adkll/deckbuilder/DeckApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.google.firebase.FirebaseApp
import com.r0adkll.deckbuilder.internal.AppDelegate
import com.r0adkll.deckbuilder.internal.analytics.Analytics
import com.r0adkll.deckbuilder.internal.analytics.LoggingAnalyticInterface
import com.r0adkll.deckbuilder.internal.analytics.UserProperty
import com.r0adkll.deckbuilder.internal.di.AppComponent
import com.r0adkll.deckbuilder.internal.di.AppModule
import com.r0adkll.deckbuilder.internal.di.DaggerAppComponent
Expand Down Expand Up @@ -42,6 +43,7 @@ class DeckApp : Application() {

private fun installAnalytics() {
Analytics.add(LoggingAnalyticInterface())
// Analytics.userProperty(UserProperty.FLAVOR, BuildConfig.FLAVOR)
}

private fun installDelegates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import com.r0adkll.deckbuilder.arch.data.features.cards.repository.source.Cachin
import com.r0adkll.deckbuilder.arch.data.features.cards.repository.source.CombinedSearchDataSource
import com.r0adkll.deckbuilder.arch.data.features.cards.repository.source.DiskSearchDataSource
import com.r0adkll.deckbuilder.arch.data.features.cards.repository.source.SearchDataSource
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.FirestoreCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.RoomCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.source.FirestoreCollectionSource
import com.r0adkll.deckbuilder.arch.data.features.collection.source.RoomCollectionSource
import com.r0adkll.deckbuilder.arch.data.features.collection.repository.DefaultCollectionRepository
import com.r0adkll.deckbuilder.arch.data.features.community.cache.CommunityCache
import com.r0adkll.deckbuilder.arch.data.features.community.cache.FirestoreCommunityCache
Expand Down Expand Up @@ -238,8 +238,8 @@ class DataModule {

@Provides @AppScope
fun provideCollectionRepository(
roomCollectionCache: RoomCollectionCache,
firestoreCollectionCache: FirestoreCollectionCache,
roomCollectionCache: RoomCollectionSource,
firestoreCollectionCache: FirestoreCollectionSource,
preferences: AppPreferences
): CollectionRepository {
return DefaultCollectionRepository(roomCollectionCache, firestoreCollectionCache, preferences)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ class FlagPreferences @Inject constructor(

override val sharedPreferences: SharedPreferences = context.getSharedPreferences(NAME, Context.MODE_PRIVATE)

var collections by BooleanPreference(KEY_NEWFEATURE_COLLECTIONS, true)

companion object {
private const val NAME = "com.r0adkll.deckbuilder.FlagPreferences"

private const val KEY_NEWFEATURE_DECK_IMAGE = "key_newfeature_deck_image"
private const val KEY_NEWFEATURE_COLLECTIONS = "key_newfeature_collections"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ abstract class CollectionDao {
@Query("SELECT * FROM collection WHERE cardId = :id")
abstract fun count(id: String): CollectionCountEntity?

@Query("SELECT * FROM collection WHERE `set` = :set")
abstract fun counts(set: String): List<CollectionCountEntity>

@Update
abstract fun updateCount(count: CollectionCountEntity): Int

@Update
abstract fun updateCounts(counts: List<CollectionCountEntity>)

@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun insertCount(count: CollectionCountEntity): Long

@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract fun insertCounts(count: List<CollectionCountEntity>)

@Query("DELETE FROM collection")
abstract fun deleteAll()


@Transaction
open fun incrementCount(card: PokemonCard): CollectionCountEntity? {
val count = count(card.id)
Expand Down Expand Up @@ -71,9 +79,22 @@ abstract class CollectionDao {
}

@Transaction
open fun incrementCounts(cards: List<PokemonCard>) {
cards.forEach { card ->
incrementCount(card)
open fun incrementSet(set: String, cards: List<PokemonCard>): List<CollectionCountEntity> {
val existingCards = counts(set)
existingCards.forEach { it.count++ }
updateCounts(existingCards)

val missingCards = cards.filter { card -> existingCards.none { existing -> existing.cardId == card.id } }
val newCountEntities = missingCards.map { card ->
CollectionCountEntity(
card.id,
1,
card.expansion!!.code,
card.expansion!!.series
)
}
insertCounts(newCountEntities)

return existingCards + newCountEntities
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.r0adkll.deckbuilder.arch.data.features.account

import com.r0adkll.deckbuilder.arch.data.AppPreferences
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.FirestoreCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.RoomCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.source.FirestoreCollectionSource
import com.r0adkll.deckbuilder.arch.data.features.collection.source.RoomCollectionSource
import com.r0adkll.deckbuilder.arch.data.features.decks.cache.FirestoreDeckCache
import com.r0adkll.deckbuilder.arch.data.features.decks.cache.RoomDeckCache
import com.r0adkll.deckbuilder.arch.domain.features.account.AccountRepository
Expand All @@ -15,9 +15,9 @@ import javax.inject.Inject

class DefaultAccountRepository @Inject constructor(
val roomDeckCache: RoomDeckCache,
val roomCollectionCache: RoomCollectionCache,
val roomCollectionCache: RoomCollectionSource,
val firestoreDeckCache: FirestoreDeckCache,
val firestoreCollectionCache: FirestoreCollectionCache,
val firestoreCollectionCache: FirestoreCollectionSource,
val preferences: AppPreferences,
val schedulers: Schedulers
): AccountRepository {
Expand Down Expand Up @@ -79,4 +79,4 @@ class DefaultAccountRepository @Inject constructor(
}
.subscribeOn(schedulers.database)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
package com.r0adkll.deckbuilder.arch.data.features.collection.repository

import com.r0adkll.deckbuilder.arch.data.AppPreferences
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.FirestoreCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.cache.RoomCollectionCache
import com.r0adkll.deckbuilder.arch.data.features.collection.source.FirestoreCollectionSource
import com.r0adkll.deckbuilder.arch.data.features.collection.source.RoomCollectionSource
import com.r0adkll.deckbuilder.arch.domain.features.cards.model.PokemonCard
import com.r0adkll.deckbuilder.arch.domain.features.collection.model.CollectionCount
import com.r0adkll.deckbuilder.arch.domain.features.collection.repository.CollectionRepository
import io.reactivex.Observable


class DefaultCollectionRepository(
private val roomCollectionCache: RoomCollectionCache,
private val firestoreCollectionCache: FirestoreCollectionCache,
private val roomCollectionSource: RoomCollectionSource,
private val firestoreCollectionSource: FirestoreCollectionSource,
private val preferences: AppPreferences
) : CollectionRepository {

override fun observeAll(): Observable<List<CollectionCount>> = when(isOffline()) {
true -> roomCollectionCache.observeAll()
else -> firestoreCollectionCache.observeAll()
true -> roomCollectionSource.observeAll()
else -> firestoreCollectionSource.observeAll()
}

override fun getCount(cardId: String): Observable<CollectionCount> = when(isOffline()) {
true -> roomCollectionCache.getCount(cardId)
else -> firestoreCollectionCache.getCount(cardId)
true -> roomCollectionSource.getCount(cardId)
else -> firestoreCollectionSource.getCount(cardId)
}

override fun getCountForSet(set: String): Observable<List<CollectionCount>> = when(isOffline()) {
true -> roomCollectionCache.getCountForSet(set)
else -> firestoreCollectionCache.getCountForSet(set)
true -> roomCollectionSource.getCountForSet(set)
else -> firestoreCollectionSource.getCountForSet(set)
}

override fun getCountForSeries(series: String): Observable<List<CollectionCount>> = when(isOffline()) {
true -> roomCollectionCache.getCountForSeries(series)
else -> firestoreCollectionCache.getCountForSeries(series)
true -> roomCollectionSource.getCountForSeries(series)
else -> firestoreCollectionSource.getCountForSeries(series)
}

override fun incrementCount(card: PokemonCard): Observable<Unit> = when(isOffline()) {
true -> roomCollectionCache.incrementCount(card)
else -> firestoreCollectionCache.incrementCount(card)
true -> roomCollectionSource.incrementCount(card)
else -> firestoreCollectionSource.incrementCount(card)
}

override fun decrementCount(card: PokemonCard): Observable<Unit> = when(isOffline()) {
true -> roomCollectionCache.decrementCount(card)
else -> firestoreCollectionCache.decrementCount(card)
true -> roomCollectionSource.decrementCount(card)
else -> firestoreCollectionSource.decrementCount(card)
}

override fun incrementCounts(cards: List<PokemonCard>): Observable<Unit> = when(isOffline()) {
true -> roomCollectionCache.incrementCounts(cards)
else -> firestoreCollectionCache.incrementCounts(cards)
override fun incrementSet(set: String, cards: List<PokemonCard>): Observable<List<CollectionCount>> = when(isOffline()) {
true -> roomCollectionSource.incrementSet(set, cards)
else -> firestoreCollectionSource.incrementSet(set, cards)
}

private fun isOffline(): Boolean = preferences.offlineId.isSet && preferences.offlineId.get().isNotBlank()
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.r0adkll.deckbuilder.arch.data.features.collection.cache
package com.r0adkll.deckbuilder.arch.data.features.collection.source

import com.r0adkll.deckbuilder.arch.domain.features.cards.model.Expansion
import com.r0adkll.deckbuilder.arch.domain.features.cards.model.PokemonCard
import com.r0adkll.deckbuilder.arch.domain.features.collection.model.CollectionCount
import io.reactivex.Observable


interface CollectionCache {
interface CollectionSource {

fun observeAll(): Observable<List<CollectionCount>>

Expand All @@ -16,5 +14,5 @@ interface CollectionCache {

fun incrementCount(card: PokemonCard): Observable<Unit>
fun decrementCount(card: PokemonCard): Observable<Unit>
fun incrementCounts(cards: List<PokemonCard>): Observable<Unit>
}
fun incrementSet(set: String, cards: List<PokemonCard>): Observable<List<CollectionCount>>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.r0adkll.deckbuilder.arch.data.features.collection.cache
package com.r0adkll.deckbuilder.arch.data.features.collection.source

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseAuthException
Expand All @@ -19,20 +19,22 @@ import javax.inject.Inject
import kotlin.math.ceil


class FirestoreCollectionCache @Inject constructor(
class FirestoreCollectionSource @Inject constructor(
val preferences: AppPreferences,
val schedulers: Schedulers
) : CollectionCache {
) : CollectionSource {

override fun observeAll(): Observable<List<CollectionCount>> {
return getUserCardCollection()
?.observeAs {
val documentId = it.id
val entity = it.toObject(CollectionCountEntity::class.java)
EntityMapper.to(entity, documentId)
}
?.toObservable()
?: Observable.error(FirebaseAuthException("-1", "No current user logged in"))
return getUserCardCollection()?.let { collection ->
collection
.observeAs {
val documentId = it.id
val entity = it.toObject(CollectionCountEntity::class.java)
EntityMapper.to(entity, documentId)
}
.toObservable()
.doOnNext { Timber.i("Collection All from Network: ${it.size}") }
} ?: Observable.error(FirebaseAuthException("-1", "No current user logged in"))
}

override fun getCount(cardId: String): Observable<CollectionCount> {
Expand Down Expand Up @@ -115,38 +117,40 @@ class FirestoreCollectionCache @Inject constructor(
} ?: Observable.error(FirebaseAuthException("-1", "no current user logged in"))
}

override fun incrementCounts(cards: List<PokemonCard>): Observable<Unit> {
override fun incrementSet(set: String, cards: List<PokemonCard>): Observable<List<CollectionCount>> {
return getUserCardCollection()?.let { collection ->
FirebaseFirestore.getInstance().runTransaction { transaction ->
val entities = ArrayList<CollectionCountEntity>()
collection.whereEqualTo("set", set)
.get()
.asObservable(schedulers.firebaseExecutor)
.flatMap {
val batch = FirebaseFirestore.getInstance().batch()
val entities = it.toObjects(CollectionCountEntity::class.java)
entities.forEach { entity ->
batch.update(collection.document(entity.cardId), "count", entity.count + 1)
}

cards.forEach { card ->
try {
val document = transaction.get(collection.document(card.id))
val entity = document.toObject(CollectionCountEntity::class.java)
if (entity != null) {
entity.count += 1
entities += entity
} else {
entities += CollectionCountEntity(
card.id, 1, card.expansion!!.code, card.expansion.series
val missingCards = cards.filter { card ->
entities.none { entity ->
entity.cardId == card.id
}
}.map { card ->
CollectionCountEntity(
card.id, 1, card.expansion!!.code, card.expansion.series
)
}
} catch (e: Exception) {
if (e is FirebaseFirestoreException) {
if (e.code == Code.NOT_FOUND) {
entities += CollectionCountEntity(
card.id, 1, card.expansion!!.code, card.expansion.series
)
}

missingCards.forEach { count ->
batch.set(collection.document(count.cardId), count)
}
}
}

entities.forEach { entity ->
transaction.set(collection.document(entity.cardId), entity)
}
}.asObservable(schedulers.firebaseExecutor)
batch.commit()
.asVoidObservable(schedulers.firebaseExecutor)
.map {
entities.forEach { it.count++ }
entities.plus(missingCards)
.map(EntityMapper::to)
}
}
} ?: Observable.error(FirebaseAuthException("-1", "no current user logged in"))
}

Expand Down Expand Up @@ -262,4 +266,4 @@ class FirestoreCollectionCache @Inject constructor(
private const val COLLECTION_OFFLINE_USERS = "offline_users" // Do to an error on my side, this is now stuck as 'decks', but it is users
private const val COLLECTION_COLLECTION = "collection"
}
}
}
Loading