Skip to content

Commit 98beeba

Browse files
m4plthestinger
authored andcommitted
Fix dialog theme and tidy up settings
1 parent 80a3257 commit 98beeba

10 files changed

Lines changed: 614 additions & 577 deletions

File tree

app/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
alias(libs.plugins.detekt)
66
alias(libs.plugins.hilt)
77
alias(libs.plugins.kotlin.compose)
8-
alias(libs.plugins.kotlin.parcelize)
98
alias(libs.plugins.ksp)
109
}
1110

@@ -92,7 +91,6 @@ dependencies {
9291
implementation(libs.androidx.appcompat)
9392
implementation(libs.androidx.palette)
9493
implementation(libs.androidx.swiperefreshlayout)
95-
implementation(libs.accompanist.drawablepainter)
9694

9795
implementation(platform(libs.androidx.compose.bom))
9896
implementation(libs.androidx.activity.compose)

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
alias(libs.plugins.android.application) apply false
55
alias(libs.plugins.hilt) apply false
66
alias(libs.plugins.kotlin.compose) apply false
7-
alias(libs.plugins.kotlin.parcelize) apply false
87
alias(libs.plugins.ksp) apply false
98
alias(libs.plugins.android.library) apply false
109
alias(libs.plugins.ktlint)

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ guava = "33.6.0-android"
1717
material = "1.14.0"
1818
palette = "1.0.0"
1919
swiperefreshlayout = "1.2.0"
20-
accompanist = "0.37.3"
2120

2221
junit4 = "4.13.2"
2322
mockk = "1.14.11"
@@ -46,7 +45,6 @@ androidx-lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-
4645

4746
androidx-palette = { module = "androidx.palette:palette", version.ref = "palette" }
4847
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" }
49-
accompanist-drawablepainter = { module = "com.google.accompanist:accompanist-drawablepainter", version.ref = "accompanist" }
5048

5149
guava = { module = "com.google.guava:guava", version.ref = "guava" }
5250

@@ -83,6 +81,5 @@ detekt = { id = "dev.detekt", version.ref = "detekt" }
8381
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
8482

8583
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
86-
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
8784
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
8885
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint-gradle" }

gradle/verification-metadata.xml

Lines changed: 583 additions & 549 deletions
Large diffs are not rendered by default.

lint-baseline.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@
2323
column="17"/>
2424
</issue>
2525

26-
<issue
27-
id="GestureBackNavigation"
28-
message="`onBackPressed` is no longer called for back gestures; migrate to AndroidX's backward compatible `OnBackPressedDispatcher`"
29-
errorLine1=" public void onBackPressed() {"
30-
errorLine2=" ~~~~~~~~~~~~~">
31-
<location
32-
file="packages/apps/Contacts/src/com/android/contacts/preference/ContactsPreferenceActivity.java"
33-
line="189"
34-
column="17"/>
35-
</issue>
36-
3726
<issue
3827
id="GestureBackNavigation"
3928
message="`onBackPressed` is no longer called for back gestures; migrate to AndroidX's backward compatible `OnBackPressedDispatcher`"

res/values-night/styles.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
<resources>
1818

19-
<style name="Theme.Compose" parent="android:Theme.Material.NoActionBar" />
19+
<style name="Theme.Compose" parent="android:Theme.Material.NoActionBar">
20+
<item name="alertDialogTheme">@style/ContactsAlertDialogThemeAppCompat</item>
21+
</style>
2022

2123
</resources>

res/values/styles.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<resources xmlns:android="http://schemas.android.com/apk/res/android"
1717
xmlns:tools="http://schemas.android.com/tools">
1818

19-
<style name="Theme.Compose" parent="android:Theme.Material.Light.NoActionBar" />
19+
<style name="Theme.Compose" parent="android:Theme.Material.Light.NoActionBar">
20+
<item name="alertDialogTheme">@style/ContactsAlertDialogThemeAppCompat</item>
21+
</style>
2022

2123
<style name="EditorActivityTheme" parent="@style/PeopleActivityTheme">
2224
<item name="actionBarStyle">@style/EditorActionBarStyle</item>

src/com/android/contacts/ui/settings/about/AboutScreen.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import androidx.compose.foundation.layout.fillMaxSize
99
import androidx.compose.foundation.layout.padding
1010
import androidx.compose.material3.ExperimentalMaterial3Api
1111
import androidx.compose.material3.Scaffold
12+
import androidx.compose.material3.SnackbarHost
13+
import androidx.compose.material3.SnackbarHostState
1214
import androidx.compose.material3.TopAppBarDefaults
1315
import androidx.compose.runtime.Composable
16+
import androidx.compose.runtime.remember
1417
import androidx.compose.ui.Modifier
1518
import androidx.compose.ui.input.nestedscroll.nestedScroll
1619
import androidx.compose.ui.platform.LocalLayoutDirection
@@ -26,6 +29,7 @@ import com.android.contacts.ui.settings.common.SettingsCell
2629
import com.android.contacts.ui.settings.common.SettingsTopAppBar
2730
import com.android.contacts.ui.settings.screen.model.ABOUT_BUILD_VERSION_TEST_TAG
2831
import com.android.contacts.ui.settings.screen.model.ABOUT_LICENSES_TEST_TAG
32+
import com.android.contacts.ui.settings.screen.model.SETTINGS_SNACKBAR_TEST_TAG
2933

3034
@OptIn(ExperimentalMaterial3Api::class)
3135
@Composable
@@ -35,6 +39,7 @@ internal fun AboutScreen(
3539
onLicensesClick: () -> Unit,
3640
onNavigateBack: () -> Unit,
3741
modifier: Modifier = Modifier,
42+
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() },
3843
) {
3944
val layoutDirection = LocalLayoutDirection.current
4045
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
@@ -47,6 +52,12 @@ internal fun AboutScreen(
4752
scrollBehavior = scrollBehavior,
4853
)
4954
},
55+
snackbarHost = {
56+
SnackbarHost(
57+
hostState = snackbarHostState,
58+
modifier = Modifier.testTag(SETTINGS_SNACKBAR_TEST_TAG),
59+
)
60+
},
5061
modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
5162
) { contentPadding ->
5263
Column(

src/com/android/contacts/ui/settings/screen/SettingsNavHost.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ internal fun SettingsNavHost(
5959
onBuildVersionLongClick = { onAction(Action.BuildVersionLongClicked) },
6060
onLicensesClick = { onAction(Action.LicensesClicked) },
6161
onNavigateBack = { route = SettingsNavRoute.Main },
62+
snackbarHostState = snackbarHostState,
6263
)
6364
}
6465
}

src/com/android/contacts/ui/settings/screen/SettingsViewModel.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import kotlinx.coroutines.flow.Flow
2525
import kotlinx.coroutines.flow.SharingStarted
2626
import kotlinx.coroutines.flow.StateFlow
2727
import kotlinx.coroutines.flow.combine
28+
import kotlinx.coroutines.flow.filterNotNull
29+
import kotlinx.coroutines.flow.first
2830
import kotlinx.coroutines.flow.flatMapLatest
2931
import kotlinx.coroutines.flow.launchIn
3032
import kotlinx.coroutines.flow.onEach
@@ -64,7 +66,7 @@ internal class SettingsViewModel @Inject constructor(
6466
private val profile: StateFlow<ProfileData?> = profileRepository.observeProfile()
6567
.stateIn(
6668
scope = viewModelScope,
67-
started = SharingStarted.Eagerly,
69+
started = SharingStarted.WhileSubscribed(STATE_STOP_TIMEOUT_MILLIS),
6870
initialValue = null,
6971
)
7072

@@ -146,16 +148,18 @@ internal class SettingsViewModel @Inject constructor(
146148
}
147149

148150
private fun openProfile() {
149-
val contactId = profile.value
150-
?.takeIf { it.hasProfile }
151-
?.contactId
151+
viewModelScope.launch {
152+
val contactId = profile.filterNotNull().first()
153+
.takeIf { it.hasProfile }
154+
?.contactId
152155

153-
val effect = when (contactId) {
154-
null -> Effect.CreateProfile
155-
else -> Effect.OpenProfile(contactId)
156-
}
156+
val effect = when (contactId) {
157+
null -> Effect.CreateProfile
158+
else -> Effect.OpenProfile(contactId)
159+
}
157160

158-
emitEffect(effect)
161+
emitEffect(effect)
162+
}
159163
}
160164

161165
private fun selectSortOrder(sortOrder: SortOrder) {

0 commit comments

Comments
 (0)