diff --git a/AnkiDroid/src/main/AndroidManifest.xml b/AnkiDroid/src/main/AndroidManifest.xml index 964bd51b5bd6..0df77b15a3de 100644 --- a/AnkiDroid/src/main/AndroidManifest.xml +++ b/AnkiDroid/src/main/AndroidManifest.xml @@ -114,7 +114,7 @@ diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt b/AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt index e4fd584028df..baae215f7055 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/IntentHandler.kt @@ -19,7 +19,10 @@ package com.ichi2.anki import android.app.Activity import android.content.Context import android.content.Intent +import android.os.Build import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.os.Message import androidx.annotation.CheckResult import androidx.annotation.VisibleForTesting @@ -31,6 +34,7 @@ import com.ichi2.anki.preferences.sharedPrefs import com.ichi2.anki.servicelayer.ScopedStorageService import com.ichi2.anki.services.ReminderService import com.ichi2.annotations.NeedsTest +import com.ichi2.libanki.utils.TimeManager import com.ichi2.themes.Themes import com.ichi2.themes.Themes.disableXiaomiForceDarkMode import com.ichi2.utils.FileUtil @@ -44,6 +48,8 @@ import com.ichi2.utils.copyToClipboard import com.ichi2.utils.trimToLength import timber.log.Timber import java.io.File +import java.time.Duration +import java.time.Instant import java.util.function.Consumer import kotlin.math.max import kotlin.math.min @@ -56,32 +62,61 @@ import kotlin.math.min */ class IntentHandler : Activity() { override fun onCreate(savedInstanceState: Bundle?) { - // Note: This is our entry point from the launcher with intent: android.intent.action.MAIN - super.onCreate(savedInstanceState) - Themes.setTheme(this) - disableXiaomiForceDarkMode(this) - setContentView(R.layout.progress_bar) - val intent = intent - Timber.v(intent.toString()) - val reloadIntent = Intent(this, DeckPicker::class.java) - reloadIntent.setDataAndType(getIntent().data, getIntent().type) - val action = intent.action - // #6157 - We want to block actions that need permissions we don't have, but not the default case - // as this requires nothing - val runIfStoragePermissions = Consumer { runnable: Runnable -> performActionIfStorageAccessible(runnable, reloadIntent, action) } - when (getLaunchType(intent)) { - LaunchType.FILE_IMPORT -> runIfStoragePermissions.accept(Runnable { handleFileImport(intent, reloadIntent, action) }) - LaunchType.SYNC -> runIfStoragePermissions.accept(Runnable { handleSyncIntent(reloadIntent, action) }) - LaunchType.REVIEW -> runIfStoragePermissions.accept(Runnable { handleReviewIntent(intent) }) - LaunchType.DEFAULT_START_APP_IF_NEW -> { - Timber.d("onCreate() performing default action") - launchDeckPickerIfNoOtherTasks(reloadIntent) - } - LaunchType.COPY_DEBUG_INFO -> { - copyDebugInfoToClipboard(intent) - finish() + val init = { +// setContentView(R.layout.progress_bar) + } + val handleScreen = { delay: Long -> + Handler(Looper.getMainLooper()).postDelayed({ + Themes.setTheme(this) + disableXiaomiForceDarkMode(this) + val intent = intent + Timber.v(intent.toString()) + val reloadIntent = Intent(this, DeckPicker::class.java) + reloadIntent.setDataAndType(getIntent().data, getIntent().type) + val action = intent.action + // #6157 - We want to block actions that need permissions we don't have, but not the default case + // as this requires nothing + val runIfStoragePermissions = Consumer { runnable: Runnable -> + performActionIfStorageAccessible(runnable, reloadIntent, action) + } + when (getLaunchType(intent)) { + LaunchType.FILE_IMPORT -> runIfStoragePermissions.accept(Runnable { handleFileImport(intent, reloadIntent, action) }) + LaunchType.SYNC -> runIfStoragePermissions.accept(Runnable { handleSyncIntent(reloadIntent, action) }) + LaunchType.REVIEW -> runIfStoragePermissions.accept(Runnable { handleReviewIntent(intent) }) + LaunchType.DEFAULT_START_APP_IF_NEW -> { + Timber.d("onCreate() performing default action") + launchDeckPickerIfNoOtherTasks(reloadIntent) + } + LaunchType.COPY_DEBUG_INFO -> { + copyDebugInfoToClipboard(intent) + finish() + } + } + }, delay) + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + splashScreen.setOnExitAnimationListener { splashScreenView -> + val animationDuration = splashScreenView.iconAnimationDuration + val animationStart = splashScreenView.iconAnimationStart + + Timber.v("duration :${animationDuration?.toMillis()} start $animationStart") + val remainingDuration = if (animationDuration != null && animationStart != null) { + (animationDuration - Duration.between(animationStart, Instant.ofEpochMilli(TimeManager.time.intTimeMS()))) + .toMillis() + .coerceAtLeast(0L) + } else { + 0L + } + Timber.v("remainDuration :$remainingDuration") + handleScreen(remainingDuration) } + init() + super.onCreate(savedInstanceState) + } else { + handleScreen(1000L) + super.onCreate(savedInstanceState) } + // Note: This is our entry point from the launcher with intent: android.intent.action.MAIN } private fun copyDebugInfoToClipboard(intent: Intent) { diff --git a/AnkiDroid/src/main/res/drawable/launch_screen.xml b/AnkiDroid/src/main/res/drawable/launch_screen.xml index 1857646f9a4a..c13dbe667d88 100644 --- a/AnkiDroid/src/main/res/drawable/launch_screen.xml +++ b/AnkiDroid/src/main/res/drawable/launch_screen.xml @@ -1,15 +1,16 @@ - - - + - - - - + diff --git a/AnkiDroid/src/main/res/drawable/splash_branding.xml b/AnkiDroid/src/main/res/drawable/splash_branding.xml new file mode 100644 index 000000000000..da5325e323eb --- /dev/null +++ b/AnkiDroid/src/main/res/drawable/splash_branding.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/AnkiDroid/src/main/res/drawable/splash_icon.xml b/AnkiDroid/src/main/res/drawable/splash_icon.xml new file mode 100644 index 000000000000..25548589195e --- /dev/null +++ b/AnkiDroid/src/main/res/drawable/splash_icon.xml @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AnkiDroid/src/main/res/values-v31/styles.xml b/AnkiDroid/src/main/res/values-v31/styles.xml new file mode 100644 index 000000000000..54f3b8bdb20a --- /dev/null +++ b/AnkiDroid/src/main/res/values-v31/styles.xml @@ -0,0 +1,9 @@ + + + + diff --git a/AnkiDroid/src/main/res/values/styles.xml b/AnkiDroid/src/main/res/values/styles.xml index b82d285469ed..c8dd646643ce 100644 --- a/AnkiDroid/src/main/res/values/styles.xml +++ b/AnkiDroid/src/main/res/values/styles.xml @@ -5,11 +5,6 @@ @drawable/launch_screen - -