From 9686dc441e296522f1519f7563bc0c101a8a57ae Mon Sep 17 00:00:00 2001 From: Roman Tsisyk Date: Sun, 23 Feb 2025 20:20:53 +0000 Subject: [PATCH] [android] New splash screen Signed-off-by: Roman Tsisyk --- android/app/build.gradle | 1 + android/app/src/main/AndroidManifest.xml | 2 +- .../java/app/organicmaps/SplashActivity.java | 14 ++---- .../downloader/DownloaderNotifier.java | 4 +- .../location/TrackRecordingService.java | 2 +- .../routing/NavigationService.java | 2 +- .../app/src/main/res/drawable/ic_splash.xml | 5 -- android/app/src/main/res/drawable/splash.xml | 6 --- .../src/main/res/layout/activity_splash.xml | 47 ------------------- .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 -- android/app/src/main/res/values/themes.xml | 12 ++--- 11 files changed, 13 insertions(+), 87 deletions(-) delete mode 100644 android/app/src/main/res/drawable/ic_splash.xml delete mode 100644 android/app/src/main/res/drawable/splash.xml delete mode 100644 android/app/src/main/res/layout/activity_splash.xml delete mode 100644 android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/android/app/build.gradle b/android/app/build.gradle index ce3873bc2d..1ed509f061 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -399,6 +399,7 @@ dependencies { implementation(platform('org.jetbrains.kotlin:kotlin-bom:2.1.10')) implementation 'androidx.annotation:annotation:1.9.1' implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'androidx.core:core-splashscreen:1.0.1' implementation 'androidx.car.app:app:1.7.0-rc01' implementation 'androidx.car.app:app-projected:1.7.0-rc01' implementation 'androidx.constraintlayout:constraintlayout:2.2.0' diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 86bdadc494..acdc567d73 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -76,7 +76,7 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:localeConfig="@xml/locales_config" - android:theme="@style/MwmTheme" + android:theme="@style/MwmTheme.Splash" android:resizeableActivity="true" android:supportsRtl="true" android:networkSecurityConfig="@xml/network_security_config" diff --git a/android/app/src/main/java/app/organicmaps/SplashActivity.java b/android/app/src/main/java/app/organicmaps/SplashActivity.java index 37c7cd976b..fe783479e5 100644 --- a/android/app/src/main/java/app/organicmaps/SplashActivity.java +++ b/android/app/src/main/java/app/organicmaps/SplashActivity.java @@ -17,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.splashscreen.SplashScreen; import app.organicmaps.display.DisplayManager; import app.organicmaps.downloader.DownloaderActivity; @@ -57,19 +58,12 @@ public class SplashActivity extends AppCompatActivity @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + SplashScreen splashScreen = SplashScreen.installSplashScreen(this); + splashScreen.setKeepOnScreenCondition(() -> true); super.onCreate(savedInstanceState); - final Context context = getApplicationContext(); - final String theme = Config.getCurrentUiTheme(context); - if (ThemeUtils.isDefaultTheme(context, theme)) - setTheme(R.style.MwmTheme_Splash); - else if (ThemeUtils.isNightTheme(context, theme)) - setTheme(R.style.MwmTheme_Night_Splash); - else - throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme); - UiThread.cancelDelayedTasks(mInitCoreDelayedTask); - setContentView(R.layout.activity_splash); + mPermissionRequest = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), result -> Config.setLocationRequested()); mApiRequest = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { diff --git a/android/app/src/main/java/app/organicmaps/downloader/DownloaderNotifier.java b/android/app/src/main/java/app/organicmaps/downloader/DownloaderNotifier.java index 3a3eddddfa..63eb1a9c26 100644 --- a/android/app/src/main/java/app/organicmaps/downloader/DownloaderNotifier.java +++ b/android/app/src/main/java/app/organicmaps/downloader/DownloaderNotifier.java @@ -69,7 +69,7 @@ public class DownloaderNotifier .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_ERROR) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) - .setSmallIcon(R.drawable.ic_splash) + .setSmallIcon(R.drawable.logo) .setColor(ContextCompat.getColor(mContext, R.color.notification)) .setContentTitle(title) .setContentText(content) @@ -124,7 +124,7 @@ public class DownloaderNotifier return new NotificationCompat.Builder(mContext, CHANNEL_ID) .setAutoCancel(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) - .setSmallIcon(R.drawable.ic_splash) + .setSmallIcon(R.drawable.logo) .setColor(ContextCompat.getColor(mContext, R.color.notification)) .setShowWhen(true) .setContentTitle(title) diff --git a/android/app/src/main/java/app/organicmaps/location/TrackRecordingService.java b/android/app/src/main/java/app/organicmaps/location/TrackRecordingService.java index a217f355d8..8d085f885c 100644 --- a/android/app/src/main/java/app/organicmaps/location/TrackRecordingService.java +++ b/android/app/src/main/java/app/organicmaps/location/TrackRecordingService.java @@ -106,7 +106,7 @@ public class TrackRecordingService extends Service implements LocationListener .setOngoing(true) .setShowWhen(true) .setOnlyAlertOnce(true) - .setSmallIcon(R.drawable.ic_splash) + .setSmallIcon(R.drawable.logo) .setContentTitle(context.getString(R.string.track_recording)) .addAction(0, context.getString(R.string.navigation_stop_button), getExitPendingIntent(context)) .setContentIntent(getPendingIntent(context)) diff --git a/android/app/src/main/java/app/organicmaps/routing/NavigationService.java b/android/app/src/main/java/app/organicmaps/routing/NavigationService.java index 8e492dbbde..a371630e60 100644 --- a/android/app/src/main/java/app/organicmaps/routing/NavigationService.java +++ b/android/app/src/main/java/app/organicmaps/routing/NavigationService.java @@ -152,7 +152,7 @@ public class NavigationService extends Service implements LocationListener .setOngoing(true) .setShowWhen(false) .setOnlyAlertOnce(true) - .setSmallIcon(R.drawable.ic_splash) + .setSmallIcon(R.drawable.logo) .setContentIntent(pendingIntent) .addAction(0, context.getString(R.string.navigation_stop_button), exitPendingIntent) .setColorized(isColorizedSupported()) diff --git a/android/app/src/main/res/drawable/ic_splash.xml b/android/app/src/main/res/drawable/ic_splash.xml deleted file mode 100644 index 3a8431c890..0000000000 --- a/android/app/src/main/res/drawable/ic_splash.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/android/app/src/main/res/drawable/splash.xml b/android/app/src/main/res/drawable/splash.xml deleted file mode 100644 index 13c05b365f..0000000000 --- a/android/app/src/main/res/drawable/splash.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/layout/activity_splash.xml b/android/app/src/main/res/layout/activity_splash.xml deleted file mode 100644 index 94da3281a2..0000000000 --- a/android/app/src/main/res/layout/activity_splash.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 036d09bc5f..0000000000 --- a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/android/app/src/main/res/values/themes.xml b/android/app/src/main/res/values/themes.xml index 47a97a0165..e3592d21f4 100644 --- a/android/app/src/main/res/values/themes.xml +++ b/android/app/src/main/res/values/themes.xml @@ -3,18 +3,12 @@ - -