Skip to content

Commit

Permalink
Disable activity recreation on most of the config changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kamerok committed Oct 13, 2024
1 parent 490be52 commit d8dff0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builder/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
Expand All @@ -29,6 +29,7 @@

<activity
android:name=".ShareActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported="true"
android:theme="@style/AppTheme">
<intent-filter>
Expand All @@ -40,6 +41,7 @@

<activity
android:name=".TransparentActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:excludeFromRecents="true"
android:exported="true"
android:launchMode="singleInstance"
Expand Down
6 changes: 6 additions & 0 deletions builder/src/main/java/com/kamer/builder/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import android.view.View
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalConfiguration
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import easydone.coreui.design.AppTheme
Expand All @@ -25,6 +27,10 @@ class MainActivity : AppCompatActivity() {
val mainNavigationScreenHolder = MainNavigationScreenHolder(this)
setContent {
AppTheme {
// this is needed to update system colors when compose handles configuration changes without activity recreation
LaunchedEffect(LocalConfiguration.current) {
enableEdgeToEdge()
}
mainNavigationScreenHolder.MainScreen()
}
}
Expand Down
6 changes: 6 additions & 0 deletions builder/src/main/java/com/kamer/builder/ShareActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.LocalConfiguration
import easydone.core.domain.DomainRepository
import easydone.coreui.design.AppTheme
import easydone.feature.edittask.EditTaskArgs
Expand All @@ -23,6 +25,10 @@ class ShareActivity : AppCompatActivity() {

setContent {
AppTheme {
// this is needed to update system colors when compose handles configuration changes without activity recreation
LaunchedEffect(LocalConfiguration.current) {
enableEdgeToEdge()
}
EditTaskRoute(
args = EditTaskArgs.Create(
text = intent.getStringExtra(Intent.EXTRA_TEXT).orEmpty()
Expand Down

0 comments on commit d8dff0a

Please sign in to comment.