diff --git a/android/app/build.gradle b/android/app/build.gradle index ce3873bc2d..5fe1ecf583 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -396,6 +396,7 @@ dependencies { // We don't use Kotlin, but some dependencies are actively using it. // See https://stackoverflow.com/a/75719642 implementation 'androidx.core:core:1.15.0' + implementation 'androidx.core:core-splashscreen:1.0.1' implementation(platform('org.jetbrains.kotlin:kotlin-bom:2.1.10')) implementation 'androidx.annotation:annotation:1.9.1' implementation 'androidx.appcompat:appcompat:1.7.0' diff --git a/android/app/src/main/java/app/organicmaps/SplashActivity.java b/android/app/src/main/java/app/organicmaps/SplashActivity.java index 7f4ae291a9..b7be384ac8 100644 --- a/android/app/src/main/java/app/organicmaps/SplashActivity.java +++ b/android/app/src/main/java/app/organicmaps/SplashActivity.java @@ -7,6 +7,7 @@ import static app.organicmaps.api.Const.EXTRA_PICK_POINT; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.util.Log; @@ -17,6 +18,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 +59,27 @@ public class SplashActivity extends AppCompatActivity @Override protected void onCreate(@Nullable Bundle savedInstanceState) { + SplashScreen splashScreen = SplashScreen.installSplashScreen(this); 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); + + final int theme = getSplashTheme(context); + // use new splashscreen api for >= 31 + // maybe doesn't work for android auto? + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + getSplashScreen().setSplashScreenTheme(theme); + //always keep splash while in SplashActivity + splashScreen.setKeepOnScreenCondition(() -> true ); + } + // use old splashscreen method for below 31 else - throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme); + { + setTheme(theme); + setContentView(R.layout.activity_splash); + } UiThread.cancelDelayedTasks(mInitCoreDelayedTask); - setContentView(R.layout.activity_splash); + mPermissionRequest = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), result -> Config.setLocationRequested()); mApiRequest = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { @@ -214,4 +224,15 @@ public class SplashActivity extends AppCompatActivity return manageSpaceActivityName.equals(component.getClassName()); } + + private int getSplashTheme(Context context) + { + final String theme = Config.getCurrentUiTheme(context); + if (ThemeUtils.isDefaultTheme(context, theme)) + return R.style.MwmTheme_Splash; + else if (ThemeUtils.isNightTheme(context, theme)) + return R.style.MwmTheme_Night_Splash; + else + throw new IllegalArgumentException("Attempt to apply unsupported theme: " + theme); + } } diff --git a/android/app/src/main/res/drawable/ic_splash.xml b/android/app/src/main/res/drawable/ic_splash.xml index 3a8431c890..4551c46f10 100644 --- a/android/app/src/main/res/drawable/ic_splash.xml +++ b/android/app/src/main/res/drawable/ic_splash.xml @@ -1,5 +1,10 @@ - - + + diff --git a/android/app/src/main/res/drawable/ic_splash_padded.xml b/android/app/src/main/res/drawable/ic_splash_padded.xml new file mode 100644 index 0000000000..42a2d01f53 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_splash_padded.xml @@ -0,0 +1,5 @@ + + + \ No newline at end of file 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 index 94da3281a2..3afd188389 100644 --- a/android/app/src/main/res/layout/activity_splash.xml +++ b/android/app/src/main/res/layout/activity_splash.xml @@ -1,18 +1,20 @@ @@ -30,6 +32,7 @@ android:layout_marginBottom="@dimen/margin_eighth" android:text="@string/app_name" android:gravity="center_horizontal" + tools:textColor="@color/white_primary" android:textAppearance="@style/MwmTextAppearance.Title.Splash" /> diff --git a/android/app/src/main/res/values-v31/themes.xml b/android/app/src/main/res/values-v31/themes.xml new file mode 100644 index 0000000000..0095a91b1e --- /dev/null +++ b/android/app/src/main/res/values-v31/themes.xml @@ -0,0 +1,21 @@ + + + + + + +