forked from geode-sdk/android-launcher
show notification in forward compatibility
This commit is contained in:
3 files changed
+55
-21
No files matched your search
@@ -218,12 +218,32 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
|
|
||||||
setupPostLibraryLoad(gdPackageInfo)
|
setupPostLibraryLoad(gdPackageInfo)
|
||||||
|
|
||||||
try {
|
val geodeFailed = try {
|
||||||
loadGeodeLibrary()
|
loadGeodeLibrary()
|
||||||
|
false
|
||||||
} catch (e: UnsatisfiedLinkError) {
|
} catch (e: UnsatisfiedLinkError) {
|
||||||
handleGeodeException(e)
|
handleGeodeException(e)
|
||||||
|
true
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
handleGeodeException(e)
|
handleGeodeException(e)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
setupNotificationView(baseView, geodeFailed)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupNotificationView(baseView: FrameLayout, geodeFailed: Boolean) {
|
||||||
|
val disableNotification = PreferenceUtils.get(this).getBoolean(PreferenceUtils.Key.DISABLE_REDESIGN)
|
||||||
|
if (!disableNotification) {
|
||||||
|
val cards = determineDisplayedCards(this, geodeFailed)
|
||||||
|
if (cards.isNotEmpty()) {
|
||||||
|
val notificationView = ComposeView(this)
|
||||||
|
baseView.addView(notificationView)
|
||||||
|
|
||||||
|
notificationView.setContent {
|
||||||
|
LaunchNotification(cards)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,19 +464,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
this.mGLSurfaceView = glSurfaceView
|
this.mGLSurfaceView = glSurfaceView
|
||||||
frameLayout.addView(this.mGLSurfaceView)
|
frameLayout.addView(this.mGLSurfaceView)
|
||||||
|
|
||||||
val disableNotification = PreferenceUtils.get(this).getBoolean(PreferenceUtils.Key.DISABLE_REDESIGN)
|
|
||||||
if (!disableNotification) {
|
|
||||||
val hasCards = determineDisplayedCards(this)
|
|
||||||
if (hasCards.isNotEmpty()) {
|
|
||||||
val notificationView = ComposeView(this)
|
|
||||||
frameLayout.addView(notificationView)
|
|
||||||
|
|
||||||
notificationView.setContent {
|
|
||||||
LaunchNotification()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glSurfaceView.setEGLContextClientVersion(2)
|
glSurfaceView.setEGLContextClientVersion(2)
|
||||||
glSurfaceView.setEGLConfigChooser(EGLConfigChooser())
|
glSurfaceView.setEGLConfigChooser(EGLConfigChooser())
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ import com.geode.launcher.utils.PreferenceUtils
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
enum class LaunchNotificationType {
|
enum class LaunchNotificationType {
|
||||||
GEODE_UPDATED, LAUNCHER_UPDATE_AVAILABLE, UPDATE_FAILED, UNSUPPORTED_VERSION;
|
GEODE_UPDATED, LAUNCHER_UPDATE_AVAILABLE, UPDATE_FAILED, UNSUPPORTED_VERSION, FAILED_LOAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
fun determineDisplayedCards(context: Context): List<LaunchNotificationType> {
|
fun determineDisplayedCards(context: Context, geodeFailed: Boolean = false): List<LaunchNotificationType> {
|
||||||
val cards = mutableListOf<LaunchNotificationType>()
|
val cards = mutableListOf<LaunchNotificationType>()
|
||||||
|
|
||||||
if (GamePackageUtils.getGameVersionCode(context.packageManager) < Constants.SUPPORTED_VERSION_CODE_MIN_WARNING) {
|
if (GamePackageUtils.getGameVersionCode(context.packageManager) < Constants.SUPPORTED_VERSION_CODE_MIN_WARNING) {
|
||||||
@@ -71,6 +71,10 @@ fun determineDisplayedCards(context: Context): List<LaunchNotificationType> {
|
|||||||
cards.add(LaunchNotificationType.UPDATE_FAILED)
|
cards.add(LaunchNotificationType.UPDATE_FAILED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (geodeFailed) {
|
||||||
|
cards.add(LaunchNotificationType.FAILED_LOAD)
|
||||||
|
}
|
||||||
|
|
||||||
return cards
|
return cards
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,21 +109,22 @@ fun NotificationCardFromType(type: LaunchNotificationType) {
|
|||||||
OutdatedVersionContent()
|
OutdatedVersionContent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LaunchNotificationType.FAILED_LOAD -> {
|
||||||
|
AnimatedNotificationCard {
|
||||||
|
ForwardCompatibilityContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LaunchNotification() {
|
fun LaunchNotification(cards: List<LaunchNotificationType>) {
|
||||||
val context = LocalContext.current
|
|
||||||
|
|
||||||
val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME)
|
val themeOption by PreferenceUtils.useIntPreference(PreferenceUtils.Key.THEME)
|
||||||
val theme = Theme.fromInt(themeOption)
|
val theme = Theme.fromInt(themeOption)
|
||||||
|
|
||||||
val backgroundOption by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.BLACK_BACKGROUND)
|
val backgroundOption by PreferenceUtils.useBooleanPreference(PreferenceUtils.Key.BLACK_BACKGROUND)
|
||||||
|
|
||||||
val cards = determineDisplayedCards(context)
|
|
||||||
|
|
||||||
CompositionLocalProvider(LocalTheme provides theme) {
|
CompositionLocalProvider(LocalTheme provides theme) {
|
||||||
GeodeLauncherTheme(theme = theme, blackBackground = backgroundOption) {
|
GeodeLauncherTheme(theme = theme, blackBackground = backgroundOption) {
|
||||||
// surface is not in use, so this is unfortunately not provided
|
// surface is not in use, so this is unfortunately not provided
|
||||||
@@ -258,3 +263,22 @@ fun UpdateFailedContent(modifier: Modifier = Modifier) {
|
|||||||
modifier = modifier.width(IntrinsicSize.Max)
|
modifier = modifier.width(IntrinsicSize.Max)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ForwardCompatibilityContent(modifier: Modifier = Modifier) {
|
||||||
|
ListItem(
|
||||||
|
headlineContent = {
|
||||||
|
Text(text = stringResource(id = R.string.launcher_notification_forwards_compatibility))
|
||||||
|
},
|
||||||
|
leadingContent = {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.icon_warning),
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
supportingContent = {
|
||||||
|
Text(text = stringResource(id = R.string.launcher_notification_forwards_compatibility_description))
|
||||||
|
},
|
||||||
|
modifier = modifier.width(IntrinsicSize.Max)
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -62,6 +62,9 @@
|
|||||||
<string name="launcher_notification_update_success">Geode updated!</string>
|
<string name="launcher_notification_update_success">Geode updated!</string>
|
||||||
<string name="launcher_notification_compatibility">Unsupported Geometry Dash version.</string>
|
<string name="launcher_notification_compatibility">Unsupported Geometry Dash version.</string>
|
||||||
<string name="launcher_notification_compatibility_description">An update is required to receive Geode updates.</string>
|
<string name="launcher_notification_compatibility_description">An update is required to receive Geode updates.</string>
|
||||||
|
<string name="launcher_notification_forwards_compatibility_description">Geode failed to load.</string>
|
||||||
|
<string name="launcher_notification_forwards_compatibility">Unsupported Geometry Dash version.</string>
|
||||||
|
|
||||||
<string name="launcher_notification_update_cta">Tap for more information.</string>
|
<string name="launcher_notification_update_cta">Tap for more information.</string>
|
||||||
|
|
||||||
<string name="launcher_self_update_failed_title">Update failed</string>
|
<string name="launcher_self_update_failed_title">Update failed</string>
|
||||||
|
|||||||
Reference in new issue
Block a user