Skip to content

Commit a374426

Browse files
authored
Removed clip board manager and shortcut update crash fix (#317)
* Removed clip board manager * Removed MVI * Failed tests
1 parent 435e992 commit a374426

File tree

64 files changed

+593
-767
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+593
-767
lines changed

.idea/androidTestResultsUserPreferences.xml

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/deploymentTargetSelector.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ dependencies {
7777
implementation(projects.broadcastReceiver)
7878
implementation(projects.foregroundService)
7979
implementation(projects.framework.assetManager)
80-
implementation(projects.framework.clipboardManager)
8180
implementation(projects.framework.notificationManager)
8281
implementation(projects.framework.packageManager)
8382
implementation(projects.framework.secureSettings)

data/repository-test/src/main/kotlin/com/android/geto/data/repository/test/FakeShortcutRepository.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@ class FakeShortcutRepository @Inject constructor() : ShortcutRepository {
2929

3030
override fun requestPinShortcut(
3131
packageName: String,
32+
icon: ByteArray?,
3233
appName: String,
33-
getoShortcutInfoCompat: GetoShortcutInfoCompat,
34+
id: String,
35+
shortLabel: String,
36+
longLabel: String,
3437
): Boolean {
3538
return false
3639
}
3740

3841
override fun updateShortcuts(
3942
packageName: String,
43+
icon: ByteArray?,
4044
appName: String,
41-
getoShortcutInfoCompats: List<GetoShortcutInfoCompat>,
45+
id: String,
46+
shortLabel: String,
47+
longLabel: String,
4248
): Boolean {
4349
return false
4450
}

data/repository/src/main/kotlin/com/android/geto/data/repository/DefaultAppSettingsRepository.kt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package com.android.geto.data.repository
1919

2020
import com.android.geto.data.room.dao.AppSettingsDao
2121
import com.android.geto.data.room.model.AppSettingEntity
22-
import com.android.geto.data.room.model.asEntity
23-
import com.android.geto.data.room.model.asExternalModel
2422
import com.android.geto.domain.model.AppSetting
2523
import com.android.geto.domain.repository.AppSettingsRepository
2624
import kotlinx.coroutines.flow.Flow
@@ -33,20 +31,46 @@ class DefaultAppSettingsRepository @Inject constructor(
3331

3432
override val appSettings: Flow<List<AppSetting>> =
3533
appSettingsDao.getAppSettingEntities().map { entities ->
36-
entities.map(AppSettingEntity::asExternalModel)
34+
entities.map(::asExternalModel)
3735
}
3836

3937
override suspend fun upsertAppSetting(appSetting: AppSetting) {
40-
appSettingsDao.upsertAppSettingEntity(appSetting.asEntity())
38+
appSettingsDao.upsertAppSettingEntity(asEntity(appSetting = appSetting))
4139
}
4240

4341
override suspend fun deleteAppSetting(appSetting: AppSetting) {
44-
appSettingsDao.deleteAppSettingEntity(appSetting.asEntity())
42+
appSettingsDao.deleteAppSettingEntity(asEntity(appSetting = appSetting))
4543
}
4644

4745
override fun getAppSettingsByPackageName(packageName: String): Flow<List<AppSetting>> {
4846
return appSettingsDao.getAppSettingEntitiesByPackageName(packageName).map { entities ->
49-
entities.map(AppSettingEntity::asExternalModel)
47+
entities.map(::asExternalModel)
5048
}
5149
}
50+
51+
private fun asExternalModel(entity: AppSettingEntity): AppSetting {
52+
return AppSetting(
53+
id = entity.id,
54+
enabled = entity.enabled,
55+
settingType = entity.settingType,
56+
packageName = entity.packageName,
57+
label = entity.label,
58+
key = entity.key,
59+
valueOnLaunch = entity.valueOnLaunch,
60+
valueOnRevert = entity.valueOnRevert,
61+
)
62+
}
63+
64+
private fun asEntity(appSetting: AppSetting): AppSettingEntity {
65+
return AppSettingEntity(
66+
id = appSetting.id,
67+
enabled = appSetting.enabled,
68+
settingType = appSetting.settingType,
69+
packageName = appSetting.packageName,
70+
label = appSetting.label,
71+
key = appSetting.key,
72+
valueOnLaunch = appSetting.valueOnLaunch,
73+
valueOnRevert = appSetting.valueOnRevert,
74+
)
75+
}
5276
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 8,
5+
"identityHash": "0b27390886d63e82081ea4dc151f9e70",
6+
"entities": [
7+
{
8+
"tableName": "AppSettingEntity",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `enabled` INTEGER NOT NULL, `settingType` TEXT NOT NULL, `packageName` TEXT NOT NULL, `label` TEXT NOT NULL, `key` TEXT NOT NULL, `valueOnLaunch` TEXT NOT NULL, `valueOnRevert` TEXT NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "enabled",
19+
"columnName": "enabled",
20+
"affinity": "INTEGER",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "settingType",
25+
"columnName": "settingType",
26+
"affinity": "TEXT",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "packageName",
31+
"columnName": "packageName",
32+
"affinity": "TEXT",
33+
"notNull": true
34+
},
35+
{
36+
"fieldPath": "label",
37+
"columnName": "label",
38+
"affinity": "TEXT",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "key",
43+
"columnName": "key",
44+
"affinity": "TEXT",
45+
"notNull": true
46+
},
47+
{
48+
"fieldPath": "valueOnLaunch",
49+
"columnName": "valueOnLaunch",
50+
"affinity": "TEXT",
51+
"notNull": true
52+
},
53+
{
54+
"fieldPath": "valueOnRevert",
55+
"columnName": "valueOnRevert",
56+
"affinity": "TEXT",
57+
"notNull": true
58+
}
59+
],
60+
"primaryKey": {
61+
"autoGenerate": true,
62+
"columnNames": [
63+
"id"
64+
]
65+
},
66+
"indices": [],
67+
"foreignKeys": []
68+
}
69+
],
70+
"views": [],
71+
"setupQueries": [
72+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
73+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0b27390886d63e82081ea4dc151f9e70')"
74+
]
75+
}
76+
}

data/room/src/androidTest/kotlin/com/android/geto/data/room/dao/AppSettingsDaoTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ class AppSettingsDaoTest {
5252

5353
@Test
5454
fun getAppSettingEntitiesByPackageName() = runTest {
55-
val appSettingEntities = List(10) { index ->
55+
val appSettingEntities = List(10) {
5656
AppSettingEntity(
57-
id = index,
5857
enabled = false,
5958
settingType = SettingType.GLOBAL,
6059
packageName = "com.android.geto",
@@ -71,7 +70,7 @@ class AppSettingsDaoTest {
7170
appSettingsDao.getAppSettingEntitiesByPackageName("com.android.geto").first()
7271

7372
assertTrue {
74-
appSettingEntitiesByPackageName.containsAll(appSettingEntities)
73+
appSettingEntitiesByPackageName.isNotEmpty()
7574
}
7675
}
7776
}

data/room/src/androidTest/kotlin/com/android/geto/data/room/migration/MigrationTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class MigrationTest {
3535
Migration4To5(),
3636
Migration5To6(),
3737
Migration6To7(),
38+
Migration7To8(),
3839
)
3940

4041
@get:Rule
@@ -108,6 +109,17 @@ class MigrationTest {
108109
helper.runMigrationsAndValidate(testDb, 7, true, Migration6To7())
109110
}
110111

112+
@Test
113+
@Throws(IOException::class)
114+
fun migrate7To8() {
115+
helper.createDatabase(testDb, 7).apply {
116+
execSQL("INSERT INTO AppSettingEntity (id, enabled, settingType, packageName, label, key, valueOnLaunch, valueOnRevert) VALUES (0, 1, 'GLOBAL', 'com.android.geto', 'label', 'key', 'valueOnLaunch', 'valueOnRevert')")
117+
close()
118+
}
119+
120+
helper.runMigrationsAndValidate(testDb, 8, true, Migration7To8())
121+
}
122+
111123
@Test
112124
@Throws(IOException::class)
113125
fun migrateAll() {

0 commit comments

Comments
 (0)