From 981a0e2cf38a110a4958438d98ce79f80fe2481d Mon Sep 17 00:00:00 2001 From: ErdbeerbaerLP Date: Sat, 1 Jul 2023 16:17:35 +0200 Subject: [PATCH] Fix app glitching when rotating screen --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 2 +- .../velociraptor/settings/SettingsActivity.kt | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2f95343..169a4e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ android { minSdkVersion 21 targetSdkVersion 29 versionCode 59 - versionName "1.7.3" + versionName "1.7.4" vectorDrawables.useSupportLibrary = true manifestPlaceholders = [appName: "@string/app_name"] diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 63f3c90..0bc8a0d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,7 @@ @@ -79,6 +80,5 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/pluscubed/velociraptor/settings/SettingsActivity.kt b/app/src/main/java/com/pluscubed/velociraptor/settings/SettingsActivity.kt index bd25773..3dd79e0 100644 --- a/app/src/main/java/com/pluscubed/velociraptor/settings/SettingsActivity.kt +++ b/app/src/main/java/com/pluscubed/velociraptor/settings/SettingsActivity.kt @@ -1,6 +1,7 @@ package com.pluscubed.velociraptor.settings import android.content.Intent +import android.content.res.Configuration import android.os.Build import android.os.Bundle import android.provider.Settings @@ -39,6 +40,7 @@ class SettingsActivity : AppCompatActivity() { private val generalFragment = GeneralFragment() private val advancedFragment = AdvancedFragment() private var active: Fragment = permissionsFragment + private var bottomNavigationSelectedItemId = R.id.action_permissions override fun onCreate(savedInstanceState: Bundle?) { @@ -100,6 +102,12 @@ class SettingsActivity : AppCompatActivity() { PrefUtils.setFirstRun(this, false) PrefUtils.setVersionCode(this, BuildConfig.VERSION_CODE) + // Zustand der BottomNavigationView wiederherstellen + if (savedInstanceState != null) { + bottomNavigationSelectedItemId = savedInstanceState.getInt("selectedItemId", R.id.action_advanced) + } + bottomNavigationView.selectedItemId = bottomNavigationSelectedItemId + } fun showSupportDialog() { @@ -110,11 +118,20 @@ class SettingsActivity : AppCompatActivity() { super.onPause() startLimitService(false) } - override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_settings, menu) return true } + override fun onSaveInstanceState(outState: Bundle) { + // Zustand der BottomNavigationView speichern + outState.putInt("selectedItemId", bottomNavigationView.selectedItemId) + + super.onSaveInstanceState(outState) + } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + + } override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) {