Fix icons pack change

This commit is contained in:
J-Jamet
2021-08-09 12:01:24 +02:00
parent f426a78a94
commit 3451135800
6 changed files with 8 additions and 13 deletions

View File

@@ -232,11 +232,6 @@ class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListen
mCurrentGroup?.let { mainGroup ->
// Thrown an exception when sort cannot be performed
mAdapter?.rebuildList(mainGroup)
// To visually change the elements
if (PreferencesUtil.APPEARANCE_CHANGED) {
mAdapter?.notifyDataSetChanged()
PreferencesUtil.APPEARANCE_CHANGED = false
}
}
} catch (e:Exception) {
Log.e(TAG, "Unable to rebuild the list", e)

View File

@@ -3,12 +3,10 @@ package com.kunzisoft.keepass.activities.selection
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.room.Database
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.helpers.EntrySelectionHelper
import com.kunzisoft.keepass.activities.helpers.SpecialMode
import com.kunzisoft.keepass.activities.helpers.TypeMode
import com.kunzisoft.keepass.activities.stylish.StylishActivity
import com.kunzisoft.keepass.model.SearchInfo
import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.view.SpecialModeView

View File

@@ -26,6 +26,7 @@ import android.util.Log
import android.view.WindowManager
import androidx.annotation.StyleRes
import androidx.appcompat.app.AppCompatActivity
import com.kunzisoft.keepass.icons.IconPackChooser.ICONS_PACK_CHANGED
/**
* Stylish Hide Activity that apply a dynamic style and sets FLAG_SECURE to prevent screenshots / from
@@ -79,7 +80,9 @@ abstract class StylishActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
if (customStyle && Stylish.getThemeId(this) != this.themeId) {
if ((customStyle && Stylish.getThemeId(this) != this.themeId)
|| ICONS_PACK_CHANGED) {
ICONS_PACK_CHANGED = false
Log.d(this.javaClass.name, "Theme change detected, restarting activity")
this.recreate()
}

View File

@@ -40,6 +40,8 @@ object IconPackChooser {
private var isIconPackChooserBuilt: Boolean = false
var ICONS_PACK_CHANGED = false
/**
* Built the icon pack chooser based on imports made in *build.gradle*
*
@@ -93,6 +95,8 @@ object IconPackChooser {
fun setSelectedIconPack(iconPackIdString: String?) {
for (iconPack in iconPackList) {
if (iconPack.id == iconPackIdString) {
// To change list items appearance
ICONS_PACK_CHANGED = true
iconPackSelected = iconPack
break
}

View File

@@ -384,9 +384,6 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
private fun onCreateAppearancePreferences(rootKey: String?) {
setPreferencesFromResource(R.xml.preferences_appearance, rootKey)
// To change list items appearance
PreferencesUtil.APPEARANCE_CHANGED = true
activity?.let { activity ->
findPreference<ListPreference>(getString(R.string.setting_style_key))?.setOnPreferenceChangeListener { _, newValue ->
var styleEnabled = true

View File

@@ -37,8 +37,6 @@ import java.util.*
object PreferencesUtil {
var APPEARANCE_CHANGED = false
fun saveDefaultDatabasePath(context: Context, defaultDatabaseUri: Uri?) {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
prefs?.edit()?.apply {