فهرست منبع

Splash screen migrated to android 31+ and warning removed.

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
A117870935 2 سال پیش
والد
کامیت
2182f12311

+ 3 - 0
app/build.gradle

@@ -380,6 +380,9 @@ dependencies {
     androidTestImplementation "androidx.room:room-testing:$roomVersion"
 
     implementation "io.coil-kt:coil:2.4.0"
+
+    //splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
+    implementation 'androidx.core:core-splashscreen:1.0.0'
 }
 
 configurations.all {

+ 3 - 3
app/src/main/AndroidManifest.xml

@@ -489,9 +489,9 @@
             android:theme="@style/Theme.ownCloud.Toolbar" />
 
         <activity
-            android:name="com.nmc.android.ui.SplashActivity"
-            android:theme="@style/Theme.ownCloud.Launcher"
-            android:exported="true">
+            android:name="com.nmc.android.ui.LauncherActivity"
+            android:exported="true"
+            android:theme="@style/Theme.App.Starting">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 

+ 2 - 2
app/src/main/java/com/nextcloud/client/di/ComponentsModule.java

@@ -36,7 +36,7 @@ import com.nextcloud.client.widget.DashboardWidgetService;
 import com.nextcloud.ui.ChooseAccountDialogFragment;
 import com.nextcloud.ui.SetStatusDialogFragment;
 import com.nextcloud.ui.fileactions.FileActionsBottomSheet;
-import com.nmc.android.ui.SplashActivity;
+import com.nmc.android.ui.LauncherActivity;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.authentication.DeepLinkLoginActivity;
@@ -469,6 +469,6 @@ abstract class ComponentsModule {
     abstract GroupfolderListFragment groupfolderListFragment();
 
     @ContributesAndroidInjector
-    abstract SplashActivity splashActivity();
+    abstract LauncherActivity launcherActivity();
 
 }

+ 5 - 1
app/src/main/java/com/nmc/android/ui/SplashActivity.kt → app/src/main/java/com/nmc/android/ui/LauncherActivity.kt

@@ -3,6 +3,7 @@ package com.nmc.android.ui
 import android.content.Intent
 import android.os.Bundle
 import android.os.Handler
+import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
 import com.nextcloud.client.preferences.AppPreferences
 import com.owncloud.android.R
 import com.owncloud.android.authentication.AuthenticatorActivity
@@ -12,7 +13,7 @@ import com.owncloud.android.ui.activity.FileDisplayActivity
 import com.owncloud.android.utils.StringUtils
 import javax.inject.Inject
 
-class SplashActivity : BaseActivity() {
+class LauncherActivity : BaseActivity() {
 
     companion object {
         const val SPLASH_DURATION = 1500L
@@ -24,6 +25,9 @@ class SplashActivity : BaseActivity() {
     lateinit var appPreferences: AppPreferences
 
     override fun onCreate(savedInstanceState: Bundle?) {
+        //Mandatory to call this before super method to show system launch screen for api level 31+
+        installSplashScreen()
+
         //flag to avoid redirection to AuthenticatorActivity
         //as we need this activity to be shown
         //Note: Should be kept before super() method

+ 12 - 0
app/src/main/res/values/styles.xml

@@ -486,6 +486,18 @@
         <item name="android:textColor">@color/white</item>
     </style>
 
+    <!-- Splash screen style attributes: https://developer.android.com/develop/ui/views/launch/splash-screen#set-theme -->
+    <style name="Theme.App.Starting" parent="Theme.SplashScreen">
+        <!-- Set the splash screen background color -->
+        <item name="windowSplashScreenBackground">@color/primary</item>
 
+        <!-- Set the splash screen animated icon  -->
+        <!-- Setting a transparent icon because of branding reason, showing icon is not accepted -->
+        <item name="windowSplashScreenAnimatedIcon">@android:color/transparent</item>
+
+        <!-- Set the theme of the Activity that directly follows your splash screen. -->
+        <!-- Required -->
+        <item name="postSplashScreenTheme">@style/Theme.ownCloud.Launcher</item>
+    </style>
 
 </resources>