Skip to content

Commit 642c736

Browse files
authored
Merge pull request #3587 from stefanosansone/fix/android-save-article
Android - Fix save article crash
2 parents befb479 + b4fc617 commit 642c736

File tree

11 files changed

+65
-67
lines changed

11 files changed

+65
-67
lines changed

android/Omnivore/app/build.gradle.kts

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ android {
2727
applicationId = "app.omnivore.omnivore"
2828
minSdk = 26
2929
targetSdk = 34
30-
versionCode = 194
31-
versionName = "0.194.0"
30+
versionCode = 194001
31+
versionName = "0.194.1"
3232

3333
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3434
vectorDrawables {
@@ -148,8 +148,6 @@ dependencies {
148148

149149
implementation(libs.apollo.runtime)
150150

151-
// TODO: Remove in favor of new Compose libs
152-
implementation(libs.accompanist.systemuicontroller)
153151
implementation(libs.accompanist.flowlayout)
154152

155153
implementation(libs.coil.kt.compose)
@@ -168,7 +166,7 @@ dependencies {
168166

169167
implementation(libs.androidx.lifecycle.runtimeCompose)
170168

171-
implementation("androidx.core:core-splashscreen:1.0.1")
169+
implementation(libs.androidx.core.splashscreen)
172170

173171
}
174172

android/Omnivore/app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
android:label="@string/app_name"
1717
android:supportsRtl="true"
1818
android:largeHeap="true"
19+
android:theme="@style/Theme.AppCompat.Translucent"
1920
tools:targetApi="31">
2021

2122
<activity

android/Omnivore/app/src/main/java/app/omnivore/omnivore/MainActivity.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import app.omnivore.omnivore.feature.editinfo.EditInfoViewModel
1919
import app.omnivore.omnivore.feature.library.SearchViewModel
2020
import app.omnivore.omnivore.feature.root.RootView
2121
import app.omnivore.omnivore.feature.save.SaveViewModel
22-
import app.omnivore.omnivore.feature.settings.SettingsViewModel
2322
import app.omnivore.omnivore.feature.theme.OmnivoreTheme
2423
import com.pspdfkit.PSPDFKit
2524
import dagger.hilt.android.AndroidEntryPoint
@@ -58,6 +57,7 @@ class MainActivity : ComponentActivity() {
5857
enableEdgeToEdge()
5958

6059
setContent {
60+
6161
OmnivoreTheme {
6262
Box(
6363
modifier = Modifier

android/Omnivore/app/src/main/java/app/omnivore/omnivore/feature/auth/WelcomeScreen.kt

+18-40
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
44
import android.content.Intent
55
import android.net.Uri
66
import androidx.compose.foundation.Image
7-
import androidx.compose.foundation.isSystemInDarkTheme
87
import androidx.compose.foundation.layout.*
98
import androidx.compose.foundation.text.ClickableText
109
import androidx.compose.material3.*
@@ -22,31 +21,16 @@ import androidx.compose.ui.text.style.TextDecoration
2221
import androidx.compose.ui.unit.dp
2322
import app.omnivore.omnivore.R
2423
import app.omnivore.omnivore.feature.theme.OmnivoreTheme
25-
import com.google.accompanist.systemuicontroller.rememberSystemUiController
2624
import com.google.android.gms.common.GoogleApiAvailability
2725
import kotlinx.coroutines.launch
2826

2927
@Composable
3028
fun WelcomeScreen(viewModel: LoginViewModel) {
31-
32-
val systemUiController = rememberSystemUiController()
33-
val useDarkIcons = !isSystemInDarkTheme()
34-
35-
DisposableEffect(systemUiController, useDarkIcons) {
36-
systemUiController.setSystemBarsColor(
37-
color = Color.Black,
38-
darkIcons = true
39-
)
40-
onDispose {
41-
systemUiController.setSystemBarsColor(
42-
color = Color.Black,
43-
darkIcons = useDarkIcons
44-
)
45-
}
46-
}
47-
4829
OmnivoreTheme(darkTheme = false) {
49-
Surface(modifier = Modifier.fillMaxSize(), color = Color(0xFFFCEBA8)) {
30+
Surface(
31+
modifier = Modifier.fillMaxSize(),
32+
color = Color(0xFFFCEBA8)
33+
) {
5034
WelcomeScreenContent(viewModel = viewModel)
5135
}
5236
}
@@ -55,9 +39,9 @@ fun WelcomeScreen(viewModel: LoginViewModel) {
5539
@SuppressLint("CoroutineCreationDuringComposition")
5640
@Composable
5741
fun WelcomeScreenContent(viewModel: LoginViewModel) {
58-
val registrationState: RegistrationState by viewModel
59-
.registrationStateLiveData
60-
.observeAsState(RegistrationState.SocialLogin)
42+
val registrationState: RegistrationState by viewModel.registrationStateLiveData.observeAsState(
43+
RegistrationState.SocialLogin
44+
)
6145

6246
val snackBarHostState = remember { SnackbarHostState() }
6347
val coroutineScope = rememberCoroutineScope()
@@ -92,11 +76,13 @@ fun WelcomeScreenContent(viewModel: LoginViewModel) {
9276
RegistrationState.SocialLogin -> {
9377
Text(
9478
text = stringResource(id = R.string.welcome_title),
79+
color = MaterialTheme.colorScheme.onSurface,
9580
style = MaterialTheme.typography.headlineLarge
9681
)
9782

9883
Text(
9984
text = stringResource(id = R.string.welcome_subtitle),
85+
color = MaterialTheme.colorScheme.onSurface,
10086
style = MaterialTheme.typography.titleSmall
10187
)
10288

@@ -117,8 +103,7 @@ fun WelcomeScreenContent(viewModel: LoginViewModel) {
117103

118104
if (viewModel.errorMessage != null) {
119105
coroutineScope.launch {
120-
val result = snackBarHostState
121-
.showSnackbar(
106+
val result = snackBarHostState.showSnackbar(
122107
viewModel.errorMessage!!,
123108
actionLabel = "Dismiss",
124109
duration = SnackbarDuration.Indefinite
@@ -135,9 +120,8 @@ fun WelcomeScreenContent(viewModel: LoginViewModel) {
135120

136121
@Composable
137122
fun AuthProviderView(viewModel: LoginViewModel) {
138-
val isGoogleAuthAvailable: Boolean = GoogleApiAvailability
139-
.getInstance()
140-
.isGooglePlayServicesAvailable(LocalContext.current) == 0
123+
val isGoogleAuthAvailable: Boolean =
124+
GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(LocalContext.current) == 0
141125

142126
Row(
143127
horizontalArrangement = Arrangement.Center
@@ -153,22 +137,17 @@ fun AuthProviderView(viewModel: LoginViewModel) {
153137

154138
AppleAuthButton(viewModel)
155139

156-
ClickableText(
157-
text = AnnotatedString(stringResource(R.string.welcome_screen_action_continue_with_email)),
158-
style = MaterialTheme.typography.titleMedium
159-
.plus(TextStyle(textDecoration = TextDecoration.Underline)),
160-
onClick = { viewModel.showEmailSignIn() }
161-
)
140+
ClickableText(text = AnnotatedString(stringResource(R.string.welcome_screen_action_continue_with_email)),
141+
style = MaterialTheme.typography.titleMedium.plus(TextStyle(textDecoration = TextDecoration.Underline)),
142+
onClick = { viewModel.showEmailSignIn() })
162143

163144
Spacer(modifier = Modifier.weight(1.0F))
164145

165146
ClickableText(
166147
text = AnnotatedString(stringResource(R.string.welcome_screen_action_self_hosting_options)),
167-
style = MaterialTheme.typography.titleMedium
168-
.plus(TextStyle(textDecoration = TextDecoration.Underline)),
148+
style = MaterialTheme.typography.titleMedium.plus(TextStyle(textDecoration = TextDecoration.Underline)),
169149
onClick = { viewModel.showSelfHostedSettings() },
170-
modifier = Modifier
171-
.padding(vertical = 10.dp)
150+
modifier = Modifier.padding(vertical = 10.dp)
172151
)
173152
}
174153
Spacer(modifier = Modifier.weight(1.0F))
@@ -184,8 +163,7 @@ fun MoreInfoButton() {
184163
text = AnnotatedString(
185164
stringResource(id = R.string.learn_more),
186165
),
187-
style = MaterialTheme.typography.titleSmall
188-
.plus(TextStyle(textDecoration = TextDecoration.Underline)),
166+
style = MaterialTheme.typography.titleSmall.plus(TextStyle(textDecoration = TextDecoration.Underline)),
189167
onClick = {
190168
context.startActivity(intent)
191169
},

android/Omnivore/app/src/main/java/app/omnivore/omnivore/feature/library/LibraryView.kt

-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ fun LibraryViewContent(
368368
)
369369
SwipeToDismiss(
370370
state = swipeState,
371-
modifier = Modifier.padding(vertical = 4.dp),
372371
directions = setOf(DismissDirection.StartToEnd, DismissDirection.EndToStart),
373372
dismissThresholds = { FractionalThreshold(swipeThreshold) },
374373
background = {

android/Omnivore/app/src/main/java/app/omnivore/omnivore/feature/reader/WebReaderLoadingContainer.kt

-14
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import androidx.compose.material3.IconButton
3030
import androidx.compose.material3.Scaffold
3131
import androidx.compose.material3.Text
3232
import androidx.compose.runtime.Composable
33-
import androidx.compose.runtime.DisposableEffect
3433
import androidx.compose.runtime.LaunchedEffect
3534
import androidx.compose.runtime.getValue
3635
import androidx.compose.runtime.livedata.observeAsState
@@ -61,7 +60,6 @@ import app.omnivore.omnivore.feature.notebook.NotebookView
6160
import app.omnivore.omnivore.feature.notebook.NotebookViewModel
6261
import app.omnivore.omnivore.feature.savedItemViews.SavedItemContextMenu
6362
import app.omnivore.omnivore.feature.theme.OmnivoreTheme
64-
import com.google.accompanist.systemuicontroller.rememberSystemUiController
6563
import dagger.hilt.android.AndroidEntryPoint
6664
import kotlinx.coroutines.launch
6765
import kotlin.math.roundToInt
@@ -81,18 +79,6 @@ class WebReaderLoadingContainerActivity : ComponentActivity() {
8179
viewModel.loadItem(slug = slug, requestID = requestID)
8280

8381
setContent {
84-
val systemUiController = rememberSystemUiController()
85-
val useDarkIcons = !isSystemInDarkTheme()
86-
87-
DisposableEffect(systemUiController, useDarkIcons) {
88-
systemUiController.setSystemBarsColor(
89-
color = Color.Black,
90-
darkIcons = false
91-
)
92-
93-
onDispose {}
94-
}
95-
9682
OmnivoreTheme {
9783
Box(
9884
modifier = Modifier

android/Omnivore/app/src/main/java/app/omnivore/omnivore/feature/root/RootView.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package app.omnivore.omnivore.feature.root
22

3+
import androidx.compose.foundation.background
34
import androidx.compose.foundation.layout.Box
45
import androidx.compose.foundation.layout.WindowInsets
56
import androidx.compose.foundation.layout.WindowInsetsSides
@@ -18,6 +19,7 @@ import androidx.compose.runtime.getValue
1819
import androidx.compose.runtime.livedata.observeAsState
1920
import androidx.compose.runtime.remember
2021
import androidx.compose.ui.Modifier
22+
import androidx.compose.ui.graphics.Color
2123
import androidx.navigation.compose.NavHost
2224
import androidx.navigation.compose.composable
2325
import androidx.navigation.compose.rememberNavController
@@ -50,7 +52,7 @@ fun RootView(
5052
snackbarHost = { SnackbarHost(snackbarHostState) },
5153
) { padding ->
5254
Box(
53-
modifier = Modifier
55+
modifier = if (!hasAuthToken) Modifier.background(Color(0xFFFCEBA8)) else Modifier
5456
.fillMaxSize()
5557
.padding(padding)
5658
.consumeWindowInsets(padding)

android/Omnivore/app/src/main/java/app/omnivore/omnivore/feature/savedItemViews/SavedItemCard.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
1515
import androidx.compose.foundation.layout.padding
1616
import androidx.compose.foundation.layout.size
1717
import androidx.compose.foundation.shape.RoundedCornerShape
18-
import androidx.compose.material3.Divider
18+
import androidx.compose.material3.HorizontalDivider
1919
import androidx.compose.material3.MaterialTheme
2020
import androidx.compose.material3.Text
2121
import androidx.compose.runtime.Composable
@@ -122,7 +122,7 @@ fun SavedItemCard(
122122
}
123123
}
124124

125-
Divider(color = MaterialTheme.colorScheme.outlineVariant, thickness = 1.dp)
125+
HorizontalDivider(thickness = 1.dp, color = MaterialTheme.colorScheme.outlineVariant)
126126
}
127127
}
128128

android/Omnivore/app/src/main/res/values-night/themes.xml

+16
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,20 @@
1414
<item name="postSplashScreenTheme">@style/Theme.Omnivore</item>
1515
</style>
1616

17+
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
18+
<item name="android:background">@android:color/transparent</item>
19+
<item name="android:windowNoTitle">true</item>
20+
<item name="windowActionBar">true</item>
21+
<item name="windowNoTitle">true</item>
22+
<item name="android:windowBackground">@android:color/transparent</item>
23+
<item name="android:colorBackgroundCacheHint">@null</item>
24+
<item name="android:windowIsTranslucent">true</item>
25+
<item name="android:windowAnimationStyle">@null</item>
26+
<item name="android:windowTranslucentStatus">true</item>
27+
<item name="android:windowFullscreen">true</item>
28+
<item name="android:windowIsFloating">false</item>
29+
<item name="android:backgroundDimEnabled">true</item>
30+
<item name="android:statusBarColor">@android:color/transparent</item>
31+
</style>
32+
1733
</resources>

android/Omnivore/app/src/main/res/values/themes.xml

+16
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,20 @@
1616
<item name="postSplashScreenTheme">@style/Theme.Omnivore</item>
1717
</style>
1818

19+
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar">
20+
<item name="android:background">@android:color/transparent</item>
21+
<item name="android:windowNoTitle">true</item>
22+
<item name="windowActionBar">true</item>
23+
<item name="windowNoTitle">true</item>
24+
<item name="android:windowBackground">@android:color/transparent</item>
25+
<item name="android:colorBackgroundCacheHint">@null</item>
26+
<item name="android:windowIsTranslucent">true</item>
27+
<item name="android:windowAnimationStyle">@null</item>
28+
<item name="android:windowTranslucentStatus">true</item>
29+
<item name="android:windowFullscreen">true</item>
30+
<item name="android:windowIsFloating">false</item>
31+
<item name="android:backgroundDimEnabled">true</item>
32+
<item name="android:statusBarColor">@android:color/transparent</item>
33+
</style>
34+
1935
</resources>

android/Omnivore/gradle/libs.versions.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ accompanistFlowLayout = "0.32.0"
44
androidGradlePlugin = "8.2.2"
55
androidxActivity = "1.8.2"
66
androidxAppCompat = "1.6.1"
7-
androidxComposeBom = "2024.02.00"
7+
androidxComposeBom = "2024.02.01"
88
androidxComposeCompiler = "1.5.9"
99
androidxCore = "1.12.0"
1010
androidxDataStore = "1.0.0"
1111
androidxEspresso = "3.5.1"
12-
androidxHiltNavigationCompose = "1.1.0"
12+
androidxHiltNavigationCompose = "1.2.0"
1313
androidxLifecycle = "2.7.0"
1414
androidxNavigation = "2.7.7"
1515
androidxSecurity = "1.0.0"
@@ -18,6 +18,7 @@ apollo = "3.8.2"
1818
chiptextfieldM3 = "0.6.5"
1919
coil = "2.5.0"
2020
composeMarkdown = "0.3.3"
21+
coreSplashscreen = "1.0.1"
2122
gson = "2.10.1"
2223
hilt = "2.50"
2324
intercom = "15.1.0"
@@ -26,7 +27,7 @@ kotlin = "1.9.22"
2627
ksp = "1.9.22-1.0.17"
2728
kotlinxCoroutines = "1.7.3"
2829
playServices = "18.3.0"
29-
playServicesAuth = "20.7.0"
30+
playServicesAuth = "21.0.0"
3031
posthog = "2.0.3"
3132
pspdfkit = "8.9.1"
3233
retrofit = "2.9.0"
@@ -48,6 +49,7 @@ androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-toolin
4849
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
4950
androidx-compose-ui-util = { group = "androidx.compose.ui", name = "ui-util" }
5051
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
52+
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreen" }
5153
androidx-dataStore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "androidxDataStore" }
5254
androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" }
5355
androidx-lifecycle-viewModelKtx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidxLifecycle" }

0 commit comments

Comments
 (0)