Browse Source

Add splash for android < 12 so app is not completely blank during process creation

feature/jme/update_rust_sdk
ganfra 2 years ago
parent
commit
4b010e01df
  1. 2
      app/build.gradle.kts
  2. 1
      app/src/main/AndroidManifest.xml
  3. 4
      app/src/main/kotlin/io/element/android/x/MainActivity.kt
  4. 8
      app/src/main/res/drawable/splash_icon.xml
  5. 26
      app/src/main/res/values-night/themes.xml
  6. 6
      app/src/main/res/values/themes.xml
  7. 1
      gradle/libs.versions.toml

2
app/build.gradle.kts

@ -171,7 +171,7 @@ dependencies { @@ -171,7 +171,7 @@ dependencies {
// https://developer.android.com/studio/write/java8-support#library-desugaring-versions
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.2.2")
implementation(libs.appyx.core)
implementation(libs.androidx.splash)
implementation(libs.androidx.corektx)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.activity.compose)

1
app/src/main/AndroidManifest.xml

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
tools:targetApi="33">
<activity
android:name=".MainActivity"
android:theme="@style/Theme.ElementX.Splash"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
android:exported="true"
android:windowSoftInputMode="adjustResize"

4
app/src/main/kotlin/io/element/android/x/MainActivity.kt

@ -22,18 +22,20 @@ import androidx.compose.foundation.layout.fillMaxSize @@ -22,18 +22,20 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.bumble.appyx.core.integration.NodeHost
import com.bumble.appyx.core.integrationpoint.NodeComponentActivity
import io.element.android.libraries.architecture.bindings
import io.element.android.libraries.di.DaggerComponentOwner
import io.element.android.libraries.designsystem.ElementXTheme
import io.element.android.libraries.di.DaggerComponentOwner
import io.element.android.x.di.AppBindings
import io.element.android.x.node.RootFlowNode
class MainActivity : NodeComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
val appBindings = bindings<AppBindings>()
appBindings.matrixClientsHolder().restore(savedInstanceState)

8
app/src/main/res/drawable/splash_icon.xml

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@mipmap/ic_launcher_round"
android:insetTop="80dp"
android:insetRight="80dp"
android:insetBottom="80dp"
android:insetLeft="80dp" />

26
app/src/main/res/values-night/themes.xml

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (c) 2023 New Vector Ltd
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<resources>
<style name="Theme.ElementX.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/Theme.ElementX</item>
</style>
<style name="Theme.ElementX" parent="Theme.ElementAndroid" />
</resources>

6
app/src/main/res/values/themes.xml

@ -16,6 +16,10 @@ @@ -16,6 +16,10 @@
-->
<resources>
<style name="Theme.ElementX.Splash" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenBackground">@color/white</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/Theme.ElementX</item>
</style>
<style name="Theme.ElementX" parent="Theme.ElementAndroid" />
</resources>

1
gradle/libs.versions.toml

@ -66,6 +66,7 @@ androidx_recyclerview = { module = "androidx.recyclerview:recyclerview", version @@ -66,6 +66,7 @@ androidx_recyclerview = { module = "androidx.recyclerview:recyclerview", version
androidx_lifecycle_runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
androidx_lifecycle_compose = { module = "androidx.lifecycle:compose", version.ref = "lifecycle" }
androidx_lifecycle_process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle" }
androidx_splash = "androidx.core:core-splashscreen:1.0.0"
androidx_activity_compose = { module = "androidx.activity:activity-compose", version.ref = "activity_compose" }
androidx_startup = { module = "androidx.startup:startup-runtime", version.ref = "startup" }

Loading…
Cancel
Save