From 4ac6345f83e56814a73b4ea62b46effa5656f678 Mon Sep 17 00:00:00 2001 From: qimiko <25387744+qimiko@users.noreply.github.com> Date: Sat, 6 Jan 2024 02:38:54 -0700 Subject: [PATCH] no internet messages --- app/src/main/java/com/geode/launcher/MainActivity.kt | 8 +++++++- .../main/java/com/geode/launcher/SettingsActivity.kt | 12 +++++++++--- app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/geode/launcher/MainActivity.kt b/app/src/main/java/com/geode/launcher/MainActivity.kt index 098f10fa..7b9b6621 100644 --- a/app/src/main/java/com/geode/launcher/MainActivity.kt +++ b/app/src/main/java/com/geode/launcher/MainActivity.kt @@ -36,6 +36,8 @@ import com.geode.launcher.ui.theme.Typography import com.geode.launcher.utils.LaunchUtils import com.geode.launcher.utils.PreferenceUtils import com.geode.launcher.utils.useCountdownTimer +import java.net.ConnectException +import java.net.UnknownHostException class MainActivity : ComponentActivity() { @@ -137,7 +139,11 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier when (val state = releaseState) { is ReleaseViewModel.ReleaseUIState.Failure -> { - val message = state.exception.message + val message = when (state.exception) { + is UnknownHostException, is ConnectException -> + stringResource(R.string.release_fetch_no_internet) + else -> state.exception.message + } UpdateMessageIndicator( stringResource(R.string.release_fetch_failed, message ?: ""), diff --git a/app/src/main/java/com/geode/launcher/SettingsActivity.kt b/app/src/main/java/com/geode/launcher/SettingsActivity.kt index d87b0f05..286517d4 100644 --- a/app/src/main/java/com/geode/launcher/SettingsActivity.kt +++ b/app/src/main/java/com/geode/launcher/SettingsActivity.kt @@ -37,6 +37,8 @@ import com.geode.launcher.api.ReleaseViewModel import com.geode.launcher.ui.theme.GeodeLauncherTheme import com.geode.launcher.ui.theme.Typography import com.geode.launcher.utils.PreferenceUtils +import java.net.ConnectException +import java.net.UnknownHostException class SettingsActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -118,9 +120,13 @@ fun UpdateIndicator( when (updateStatus) { is ReleaseViewModel.ReleaseUIState.Failure -> { - snackbarHostState.showSnackbar( - context.getString(R.string.preference_check_for_updates_failed), - ) + val message = when (updateStatus.exception) { + is UnknownHostException, is ConnectException -> + context.getString(R.string.release_fetch_no_internet) + else -> context.getString(R.string.preference_check_for_updates_failed) + } + + snackbarHostState.showSnackbar(message) } is ReleaseViewModel.ReleaseUIState.Finished -> { if (updateStatus.hasUpdated) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f51d6756..6aa0d6bd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,7 @@ Geode updated! Downloading update… (%1$s/%2$s) Cancelling update… + No internet found. Update cancelled. Retry Cancel @@ -54,5 +55,6 @@ No updates found. Geode has been updated! Downloading update… + No internet found. An update is already in progress! \ No newline at end of file