Skip to content

Commit d6feeee

Browse files
authored
fix: crash on orientation change by adding to configChanges (#181)
Closes #179 properly
1 parent f9e8012 commit d6feeee

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ android {
2626
applicationId = "dev.yashgarg.qbit"
2727
minSdk = 24
2828
targetSdk = 33
29-
versionCode = 6
29+
versionCode = 7
3030
versionName = "v0.1.$versionCode-$commitHash"
3131

3232
multiDexEnabled = true

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
<activity
2828
android:name=".MainActivity"
29+
android:configChanges="orientation|screenSize"
2930
android:exported="true"
3031
android:theme="@style/Theme.Qbit">
3132
<intent-filter>

app/src/main/kotlin/dev/yashgarg/qbit/MainActivity.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.yashgarg.qbit
22

33
import android.content.Context
4-
import android.content.pm.ActivityInfo
54
import android.os.Build
65
import android.os.Bundle
76
import android.util.Log
@@ -13,7 +12,7 @@ import androidx.core.os.bundleOf
1312
import androidx.core.view.WindowCompat
1413
import androidx.datastore.core.DataStore
1514
import androidx.lifecycle.lifecycleScope
16-
import androidx.lifecycle.whenStarted
15+
import androidx.lifecycle.whenResumed
1716
import androidx.navigation.Navigation.findNavController
1817
import androidx.work.ExistingWorkPolicy
1918
import androidx.work.OneTimeWorkRequestBuilder
@@ -39,7 +38,6 @@ class MainActivity : AppCompatActivity() {
3938
@Inject lateinit var serverPrefsStore: DataStore<ServerPreferences>
4039

4140
override fun onCreate(savedInstanceState: Bundle?) {
42-
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
4341
WindowCompat.setDecorFitsSystemWindows(window, false)
4442
super.onCreate(savedInstanceState)
4543

@@ -48,14 +46,12 @@ class MainActivity : AppCompatActivity() {
4846
binding = ActivityMainBinding.inflate(layoutInflater)
4947
setContentView(binding.root)
5048

51-
Log.i(this.javaClass.simpleName, "SavedInstanceState: $savedInstanceState")
52-
5349
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
5450
checkPermissions(applicationContext)
5551
}
5652

5753
lifecycleScope.launch {
58-
whenStarted {
54+
whenResumed {
5955
clientManager.configStatus.collect { status ->
6056
when (status) {
6157
ConfigStatus.EXISTS -> {

0 commit comments

Comments
 (0)