Skip to content

Commit

Permalink
Merge branch 'maint/v5.4.x' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
frett committed Jan 29, 2021
2 parents d778458 + 43f45d0 commit 6e510c8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ branches:
only:
- develop
- master
- /^maint\/v(\d+\.){1,}x$/

stages:
- test
Expand Down
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,13 @@ android {
buildConfigField "String", "OKTA_AUTH_SCHEME", "\"org.cru.godtools\""
}
}
bundle {
language.enableSplit = false
}
dynamicFeatures = [
':feature:bundledcontent',
]

sourceSets {
qa {
java.srcDir 'src/debug/java'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ plugins {
id "org.jlleitschuh.gradle.ktlint" version "9.4.1"
}

version '5.4.3-SNAPSHOT'
version '5.4.4-SNAPSHOT'
ext.versionCode = grgit.log(includes:['HEAD']).size() + 4029765

// define dependency versions for this project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,22 +233,25 @@ class GodToolsShortcutManager @VisibleForTesting internal constructor(

@VisibleForTesting
@RequiresApi(Build.VERSION_CODES.N_MR1)
internal suspend fun updateDynamicShortcuts(shortcuts: Map<String, ShortcutInfoCompat>) =
withContext(ioDispatcher) {
val dynamicShortcuts = Query.select<Tool>()
internal suspend fun updateDynamicShortcuts(shortcuts: Map<String, ShortcutInfoCompat>) {
val manager = shortcutManager ?: return

val dynamicShortcuts = withContext(ioDispatcher) {
Query.select<Tool>()
.where(ToolTable.FIELD_ADDED.eq(true))
.orderBy(ToolTable.SQL_ORDER_BY_ORDER)
.get(dao).asSequence()
.mapNotNull { shortcuts[it.shortcutId]?.toShortcutInfo() }
.take(ShortcutManagerCompat.getMaxShortcutCountPerActivity(context))
.take(manager.maxShortcutCountPerActivity)
.toList()
}

try {
shortcutManager?.dynamicShortcuts = dynamicShortcuts
} catch (e: IllegalStateException) {
Timber.tag("GodToolsShortcutManager").e(e, "Error updating dynamic shortcuts")
}
try {
manager.dynamicShortcuts = dynamicShortcuts
} catch (e: IllegalStateException) {
Timber.tag("GodToolsShortcutManager").e(e, "Error updating dynamic shortcuts")
}
}

@RequiresApi(Build.VERSION_CODES.N_MR1)
private fun updatePinnedShortcuts(shortcuts: Map<String, ShortcutInfoCompat>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,19 @@ class GodToolsShortcutManagerTest {
}
}
// endregion Update Existing Shortcuts

// region Instant App
@Test
fun verifyUpdateDynamicShortcutsOnInstantAppIsANoop() {
assumeThat(Build.VERSION.SDK_INT, greaterThanOrEqualTo(Build.VERSION_CODES.N_MR1))

// Instant Apps don't have access to the system ShortcutManager
whenever(app.getSystemService<ShortcutManager>()).thenReturn(null)
coroutineScope.resumeDispatcher()
clearInvocations(dao)

coroutineScope.launch { shortcutManager.updateDynamicShortcuts(emptyMap()) }
verifyZeroInteractions(dao)
}
// endregion Instant App
}

0 comments on commit 6e510c8

Please sign in to comment.