11package com.fredhappyface.ewesticker
22
3+ import android.content.Context
34import android.content.SharedPreferences
45import android.inputmethodservice.InputMethodService
56import android.os.Build
@@ -47,6 +48,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
4748 // onCreate
4849 // Shared Preferences
4950 private lateinit var sharedPreferences: SharedPreferences
51+ private lateinit var backupSharedPreferences: SharedPreferences
5052 private var restoreOnClose = false
5153 private var vertical = false
5254 private var scroll = false
@@ -107,13 +109,14 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
107109 Coil .setImageLoader(imageLoader)
108110 // Shared Preferences
109111 this .sharedPreferences = PreferenceManager .getDefaultSharedPreferences(baseContext)
110- this .restoreOnClose = this .sharedPreferences.getBoolean(" restoreOnClose" , false )
111- this .vertical = this .sharedPreferences.getBoolean(" vertical" , false )
112- this .scroll = this .sharedPreferences.getBoolean(" scroll" , false )
113- this .vibrate = this .sharedPreferences.getBoolean(" vibrate" , true )
114- this .insensitiveSort = this .sharedPreferences.getBoolean(" insensitiveSort" , false )
115-
116- this .iconsPerX = this .sharedPreferences.getInt(" iconsPerX" , 3 )
112+ this .backupSharedPreferences = this .getSharedPreferences(" backup_prefs" , Context .MODE_PRIVATE )
113+ this .restoreOnClose = this .backupSharedPreferences.getBoolean(" restoreOnClose" , false )
114+ this .vertical = this .backupSharedPreferences.getBoolean(" vertical" , false )
115+ this .scroll = this .backupSharedPreferences.getBoolean(" scroll" , false )
116+ this .vibrate = this .backupSharedPreferences.getBoolean(" vibrate" , true )
117+ this .insensitiveSort = this .backupSharedPreferences.getBoolean(" insensitiveSort" , false )
118+
119+ this .iconsPerX = this .backupSharedPreferences.getInt(" iconsPerX" , 3 )
117120 this .totalIconPadding =
118121 (resources.getDimension(R .dimen.sticker_padding) * 2 * (this .iconsPerX + 1 )).toInt()
119122 // Constants
@@ -123,7 +126,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
123126 if (this .vertical) {
124127 (resources.displayMetrics.widthPixels - this .totalIconPadding) / this .iconsPerX.toFloat()
125128 } else {
126- (this .sharedPreferences .getInt(" iconSize" , 80 ) * scale)
129+ (this .backupSharedPreferences .getInt(" iconSize" , 80 ) * scale)
127130 }
128131 ).toInt()
129132 this .toaster = Toaster (baseContext)
@@ -419,7 +422,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
419422 private fun createPackIcons () {
420423 this .packsList.removeAllViewsInLayout()
421424 // Back button
422- if (this .sharedPreferences .getBoolean(" showBackButton" , true )) {
425+ if (this .backupSharedPreferences .getBoolean(" showBackButton" , true )) {
423426 val backButton = addPackButton(" __back__" )
424427 backButton.load(getDrawable(R .drawable.arrow_back_circle))
425428 backButton.setOnClickListener {
@@ -428,7 +431,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
428431 }
429432
430433 // Search
431- if (this .sharedPreferences .getBoolean(" showSearchButton" , true )) {
434+ if (this .backupSharedPreferences .getBoolean(" showSearchButton" , true )) {
432435 val searchButton = addPackButton(" __search__" )
433436 searchButton.load(getDrawable(R .drawable.search_circle))
434437 searchButton.setOnClickListener {
0 commit comments