Add shortcut as google language (en_US), added subset of settings to backup
This commit is contained in:
parent
a3bfa5a58f
commit
4c88f24af3
@ -1,5 +1,6 @@
|
|||||||
package com.fredhappyface.ewesticker
|
package com.fredhappyface.ewesticker
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.inputmethodservice.InputMethodService
|
import android.inputmethodservice.InputMethodService
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@ -47,6 +48,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
// onCreate
|
// onCreate
|
||||||
// Shared Preferences
|
// Shared Preferences
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private lateinit var backupSharedPreferences: SharedPreferences
|
||||||
private var restoreOnClose = false
|
private var restoreOnClose = false
|
||||||
private var vertical = false
|
private var vertical = false
|
||||||
private var scroll = false
|
private var scroll = false
|
||||||
@ -107,13 +109,14 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
Coil.setImageLoader(imageLoader)
|
Coil.setImageLoader(imageLoader)
|
||||||
// Shared Preferences
|
// Shared Preferences
|
||||||
this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(baseContext)
|
this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(baseContext)
|
||||||
this.restoreOnClose = this.sharedPreferences.getBoolean("restoreOnClose", false)
|
this.backupSharedPreferences = this.getSharedPreferences("backup_prefs", Context.MODE_PRIVATE)
|
||||||
this.vertical = this.sharedPreferences.getBoolean("vertical", false)
|
this.restoreOnClose = this.backupSharedPreferences.getBoolean("restoreOnClose", false)
|
||||||
this.scroll = this.sharedPreferences.getBoolean("scroll", false)
|
this.vertical = this.backupSharedPreferences.getBoolean("vertical", false)
|
||||||
this.vibrate = this.sharedPreferences.getBoolean("vibrate", true)
|
this.scroll = this.backupSharedPreferences.getBoolean("scroll", false)
|
||||||
this.insensitiveSort = this.sharedPreferences.getBoolean("insensitiveSort", false)
|
this.vibrate = this.backupSharedPreferences.getBoolean("vibrate", true)
|
||||||
|
this.insensitiveSort = this.backupSharedPreferences.getBoolean("insensitiveSort", false)
|
||||||
|
|
||||||
this.iconsPerX = this.sharedPreferences.getInt("iconsPerX", 3)
|
this.iconsPerX = this.backupSharedPreferences.getInt("iconsPerX", 3)
|
||||||
this.totalIconPadding =
|
this.totalIconPadding =
|
||||||
(resources.getDimension(R.dimen.sticker_padding) * 2 * (this.iconsPerX + 1)).toInt()
|
(resources.getDimension(R.dimen.sticker_padding) * 2 * (this.iconsPerX + 1)).toInt()
|
||||||
// Constants
|
// Constants
|
||||||
@ -123,7 +126,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
if (this.vertical) {
|
if (this.vertical) {
|
||||||
(resources.displayMetrics.widthPixels - this.totalIconPadding) / this.iconsPerX.toFloat()
|
(resources.displayMetrics.widthPixels - this.totalIconPadding) / this.iconsPerX.toFloat()
|
||||||
} else {
|
} else {
|
||||||
(this.sharedPreferences.getInt("iconSize", 80) * scale)
|
(this.backupSharedPreferences.getInt("iconSize", 80) * scale)
|
||||||
}
|
}
|
||||||
).toInt()
|
).toInt()
|
||||||
this.toaster = Toaster(baseContext)
|
this.toaster = Toaster(baseContext)
|
||||||
@ -419,7 +422,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
private fun createPackIcons() {
|
private fun createPackIcons() {
|
||||||
this.packsList.removeAllViewsInLayout()
|
this.packsList.removeAllViewsInLayout()
|
||||||
// Back button
|
// Back button
|
||||||
if (this.sharedPreferences.getBoolean("showBackButton", true)) {
|
if (this.backupSharedPreferences.getBoolean("showBackButton", true)) {
|
||||||
val backButton = addPackButton("__back__")
|
val backButton = addPackButton("__back__")
|
||||||
backButton.load(getDrawable(R.drawable.arrow_back_circle))
|
backButton.load(getDrawable(R.drawable.arrow_back_circle))
|
||||||
backButton.setOnClickListener {
|
backButton.setOnClickListener {
|
||||||
@ -428,7 +431,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
if (this.sharedPreferences.getBoolean("showSearchButton", true)) {
|
if (this.backupSharedPreferences.getBoolean("showSearchButton", true)) {
|
||||||
val searchButton = addPackButton("__search__")
|
val searchButton = addPackButton("__search__")
|
||||||
searchButton.load(getDrawable(R.drawable.search_circle))
|
searchButton.load(getDrawable(R.drawable.search_circle))
|
||||||
searchButton.setOnClickListener {
|
searchButton.setOnClickListener {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.fredhappyface.ewesticker
|
package com.fredhappyface.ewesticker
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@ -28,6 +29,7 @@ import java.util.Calendar
|
|||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
// onCreate
|
// onCreate
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private lateinit var backupSharedPreferences: SharedPreferences
|
||||||
private lateinit var contextView: View
|
private lateinit var contextView: View
|
||||||
private lateinit var toaster: Toaster
|
private lateinit var toaster: Toaster
|
||||||
|
|
||||||
@ -50,6 +52,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// Set late-init attrs
|
// Set late-init attrs
|
||||||
this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
this.backupSharedPreferences = this.getSharedPreferences("backup_prefs", Context.MODE_PRIVATE)
|
||||||
this.contextView = findViewById(R.id.activityMainRoot)
|
this.contextView = findViewById(R.id.activityMainRoot)
|
||||||
this.toaster = Toaster(baseContext)
|
this.toaster = Toaster(baseContext)
|
||||||
refreshStickerDirPath()
|
refreshStickerDirPath()
|
||||||
@ -194,12 +197,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
callback: (Boolean) -> Unit,
|
callback: (Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
compoundButton.isChecked =
|
compoundButton.isChecked =
|
||||||
this.sharedPreferences.getBoolean(sharedPrefKey, sharedPrefDefault)
|
this.backupSharedPreferences.getBoolean(sharedPrefKey, sharedPrefDefault)
|
||||||
callback(compoundButton.isChecked)
|
callback(compoundButton.isChecked)
|
||||||
compoundButton.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
|
compoundButton.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
|
||||||
showChangedPrefText()
|
showChangedPrefText()
|
||||||
callback(compoundButton.isChecked)
|
callback(compoundButton.isChecked)
|
||||||
val editor = this.sharedPreferences.edit()
|
val editor = this.backupSharedPreferences.edit()
|
||||||
editor.putBoolean(sharedPrefKey, isChecked)
|
editor.putBoolean(sharedPrefKey, isChecked)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
@ -223,9 +226,9 @@ class MainActivity : AppCompatActivity() {
|
|||||||
multiplier: Int = 1,
|
multiplier: Int = 1,
|
||||||
) {
|
) {
|
||||||
seekBarLabel.text =
|
seekBarLabel.text =
|
||||||
this.sharedPreferences.getInt(sharedPrefKey, sharedPrefDefault).toString()
|
this.backupSharedPreferences.getInt(sharedPrefKey, sharedPrefDefault).toString()
|
||||||
seekBar.progress =
|
seekBar.progress =
|
||||||
this.sharedPreferences.getInt(sharedPrefKey, sharedPrefDefault) / multiplier
|
this.backupSharedPreferences.getInt(sharedPrefKey, sharedPrefDefault) / multiplier
|
||||||
seekBar.setOnSeekBarChangeListener(
|
seekBar.setOnSeekBarChangeListener(
|
||||||
object : OnSeekBarChangeListener {
|
object : OnSeekBarChangeListener {
|
||||||
var progressMultiplier = sharedPrefDefault
|
var progressMultiplier = sharedPrefDefault
|
||||||
@ -236,7 +239,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onStartTrackingTouch(seekBar: SeekBar) {}
|
override fun onStartTrackingTouch(seekBar: SeekBar) {}
|
||||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
val editor = sharedPreferences.edit()
|
val editor = backupSharedPreferences.edit()
|
||||||
editor.putInt(sharedPrefKey, progressMultiplier)
|
editor.putInt(sharedPrefKey, progressMultiplier)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
showChangedPrefText()
|
showChangedPrefText()
|
||||||
|
@ -3,9 +3,18 @@
|
|||||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
for details.
|
for details.
|
||||||
-->
|
-->
|
||||||
<data-extraction-rules>
|
<data-extraction-rules>\
|
||||||
<cloud-backup>
|
<cloud-backup>
|
||||||
|
<!-- Include the backup SharedPreferences file -->
|
||||||
|
<include domain="sharedpref" path="backup_prefs.xml"/>
|
||||||
|
</cloud-backup>
|
||||||
|
<device-transfer>
|
||||||
|
<!-- Include the backup SharedPreferences file for device transfer -->
|
||||||
|
<include domain="sharedpref" path="backup_prefs.xml"/>
|
||||||
|
</device-transfer>
|
||||||
<!--
|
<!--
|
||||||
|
<cloud-backup>
|
||||||
|
|
||||||
The domain can be file, database, sharedpref, external or root.
|
The domain can be file, database, sharedpref, external or root.
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -23,8 +32,8 @@
|
|||||||
<exclude domain="external" path="file_to_exclude"/>
|
<exclude domain="external" path="file_to_exclude"/>
|
||||||
<include domain="root" path="file_to_include"/>
|
<include domain="root" path="file_to_include"/>
|
||||||
<exclude domain="root" path="file_to_exclude"/>
|
<exclude domain="root" path="file_to_exclude"/>
|
||||||
-->
|
|
||||||
</cloud-backup>
|
</cloud-backup>
|
||||||
|
-->
|
||||||
<!--
|
<!--
|
||||||
<device-transfer>
|
<device-transfer>
|
||||||
<include .../>
|
<include .../>
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
<!--suppress CheckTagEmptyBody -->
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<full-backup-content></full-backup-content>
|
<full-backup-content>
|
||||||
|
<!-- Include specific files or directories -->
|
||||||
|
<include domain="sharedpref" path="backup_prefs.xml"/>
|
||||||
|
|
||||||
|
</full-backup-content>
|
||||||
|
@ -1,2 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<input-method />
|
<input-method xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<subtype
|
||||||
|
android:icon="@drawable/ic_launcher_mono"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:imeSubtypeLocale="en_US"
|
||||||
|
android:imeSubtypeMode="keyboard"
|
||||||
|
android:imeSubtypeExtraValue="KeyCharacterMap:Special_Symbols"
|
||||||
|
/>
|
||||||
|
</input-method>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user