forked from geode-sdk/android-launcher
move launcher update button to top
This commit is contained in:
4 files changed
+56
-19
No files matched your search
@@ -26,7 +26,9 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
@@ -69,29 +71,31 @@ fun determineDisplayedCards(context: Context): List<LaunchNotificationType> {
|
||||
|
||||
@Composable
|
||||
fun NotificationCardFromType(type: LaunchNotificationType) {
|
||||
val context = LocalContext.current
|
||||
|
||||
when (type) {
|
||||
LaunchNotificationType.LAUNCHER_UPDATE_AVAILABLE -> {
|
||||
var showInfoDialog by remember { mutableStateOf(false) }
|
||||
|
||||
if (showInfoDialog) {
|
||||
LauncherUpdateInformation {
|
||||
showInfoDialog = false
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedNotificationCard(
|
||||
displayLength = 5000L,
|
||||
onClick = {
|
||||
installLauncherUpdate(context)
|
||||
showInfoDialog = true
|
||||
}
|
||||
) {
|
||||
LauncherUpdateContent()
|
||||
}
|
||||
}
|
||||
LaunchNotificationType.GEODE_UPDATED -> {
|
||||
AnimatedNotificationCard {
|
||||
UpdateNotificationContent()
|
||||
}
|
||||
}
|
||||
LaunchNotificationType.UPDATE_FAILED -> {
|
||||
AnimatedNotificationCard {
|
||||
UpdateFailedContent()
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,18 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.SheetValue
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
@@ -40,6 +44,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -149,7 +154,32 @@ fun LauncherUpdateInformation(onDismiss: () -> Unit) {
|
||||
style = Typography.labelLarge
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Row(modifier = Modifier.padding(vertical = 12.dp)) {
|
||||
Button(
|
||||
onClick = { installLauncherUpdate(context) },
|
||||
) {
|
||||
Icon(painterResource(R.drawable.icon_download), contentDescription = null)
|
||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||
Text(stringResource(R.string.launcher_install))
|
||||
}
|
||||
|
||||
val uriHandler = LocalUriHandler.current
|
||||
|
||||
IconButton(onClick = { uriHandler.openUri(nextRelease.release.htmlUrl) }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.icon_link),
|
||||
stringResource(R.string.launcher_update_external_link)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HorizontalDivider(modifier = Modifier.padding(vertical = 8.dp))
|
||||
|
||||
Text(
|
||||
stringResource(R.string.launcher_update_changelog),
|
||||
style = Typography.titleLarge
|
||||
)
|
||||
|
||||
if (nextRelease.release.body != null) {
|
||||
CompositionLocalProvider(LocalBulletListHandler provides { _, _, _ -> "• " }) {
|
||||
@@ -166,15 +196,6 @@ fun LauncherUpdateInformation(onDismiss: () -> Unit) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
TextButton(
|
||||
modifier = Modifier.align(Alignment.End),
|
||||
onClick = { installLauncherUpdate(context) },
|
||||
) {
|
||||
Icon(painterResource(R.drawable.icon_download), contentDescription = null)
|
||||
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||
Text(stringResource(R.string.launcher_install))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M440,680L280,680Q197,680 138.5,621.5Q80,563 80,480Q80,397 138.5,338.5Q197,280 280,280L440,280L440,360L280,360Q230,360 195,395Q160,430 160,480Q160,530 195,565Q230,600 280,600L440,600L440,680ZM320,520L320,440L640,440L640,520L320,520ZM520,680L520,600L680,600Q730,600 765,565Q800,530 800,480Q800,430 765,395Q730,360 680,360L520,360L520,280L680,280Q763,280 821.5,338.5Q880,397 880,480Q880,563 821.5,621.5Q763,680 680,680L520,680Z"/>
|
||||
</vector>
|
||||
@@ -40,7 +40,9 @@
|
||||
<string name="launcher_update_available">A new launcher update is available!</string>
|
||||
<string name="launcher_update_dismiss">Dismiss</string>
|
||||
<string name="launcher_update_view">View</string>
|
||||
<string name="launcher_update_external_link">View in browser</string>
|
||||
<string name="launcher_update_name">Geode Launcher v%1$s</string>
|
||||
<string name="launcher_update_changelog">Changelog</string>
|
||||
<string name="launcher_update_released">Released %1$s</string>
|
||||
<string name="safe_mode_enable_title">Enable safe mode?</string>
|
||||
<string name="safe_mode_enable_description">Safe mode disables loading of all mods, allowing one to remove problematic mods or diagnose crashes. If you\'re not experiencing issues with Geode, you should probably not be using safe mode.</string>
|
||||
@@ -58,7 +60,7 @@
|
||||
<string name="launcher_notification_settings">Launcher Settings</string>
|
||||
<string name="launcher_notification_update_failed">Failed to check for updates.</string>
|
||||
<string name="launcher_notification_update_success">Geode updated!</string>
|
||||
<string name="launcher_notification_update_cta">Tap to install.</string>
|
||||
<string name="launcher_notification_update_cta">Tap to view.</string>
|
||||
|
||||
<string name="launcher_starting_game">Starting Geometry Dash…</string>
|
||||
<string name="launcher_downloading_update">Downloading update…</string>
|
||||
|
||||
Reference in new issue
Block a user