add case insensitive sort; add version number in-app

This commit is contained in:
Kieran W 2024-08-25 15:11:58 +01:00
parent 906078776f
commit 08e141b134
7 changed files with 64 additions and 4 deletions

View File

@ -56,7 +56,9 @@ android {
}
buildTypes {
getByName("debug") { versionNameSuffix = "-debug" }
getByName("debug") {
versionNameSuffix = "-debug"
}
getByName("release") {
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
isMinifyEnabled = false

View File

@ -53,6 +53,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
private var vibrate = false
private var iconsPerX = 0
private var iconSize = 0
private var insensitiveSort = false
// Constants
private lateinit var internalDir: File
@ -110,6 +111,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
this.vertical = this.sharedPreferences.getBoolean("vertical", false)
this.scroll = this.sharedPreferences.getBoolean("scroll", false)
this.vibrate = this.sharedPreferences.getBoolean("vibrate", true)
this.insensitiveSort = this.sharedPreferences.getBoolean("insensitiveSort", false)
this.iconsPerX = this.sharedPreferences.getInt("iconsPerX", 3)
this.totalIconPadding =
@ -439,7 +441,15 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
recentButton.load(getDrawable(R.drawable.time))
recentButton.setOnClickListener { switchPackLayout(recentPackName) }
// Packs
val sortedPackNames = this.loadedPacks.keys.sorted().toTypedArray()
val sortedPackNames = if (this.insensitiveSort) {
this.loadedPacks.keys.sortedWith(String.CASE_INSENSITIVE_ORDER)
} else {
this.loadedPacks.keys.sorted()
}.toTypedArray()
for (sortedPackName in sortedPackNames) {
val packButton = addPackButton(sortedPackName)
packButton.load(this.loadedPacks[sortedPackName]?.thumbSticker)

View File

@ -3,6 +3,7 @@ package com.fredhappyface.ewesticker
import android.app.Activity
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.os.Bundle
import android.provider.Settings
import android.view.View
@ -63,6 +64,15 @@ class MainActivity : AppCompatActivity() {
}
toggle(findViewById(R.id.restoreOnClose), "restoreOnClose", false) {}
toggle(findViewById(R.id.scroll), "scroll", false) {}
toggle(findViewById(R.id.insensitive_sort), "insensitiveSort", false) {}
val versionText: TextView = findViewById(R.id.versionText)
try {
val packageInfo = packageManager.getPackageInfo(packageName, 0)
versionText.text = packageInfo.versionName
} catch (e: PackageManager.NameNotFoundException) {
versionText.text = getString(R.string.version_text)
}
}
/**

View File

@ -245,6 +245,20 @@
android:text="@string/options_scroll" />
</LinearLayout>
<LinearLayout
style="@style/widthMatchHeightWrap"
android:orientation="horizontal">
<CheckBox
android:id="@+id/insensitive_sort"
style="@style/checkbox" />
<TextView
style="@style/body_text"
android:paddingBottom="@dimen/content_margin"
android:text="@string/options_insensitive_sort" />
</LinearLayout>
<LinearLayout
style="@style/widthMatchHeightWrap"
android:orientation="horizontal">
@ -372,6 +386,26 @@
android:text="@string/links_text" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<!-- Version -->
<com.google.android.material.card.MaterialCardView style="@style/card">
<LinearLayout
style="@style/cardchild"
android:orientation="vertical">
<TextView
style="@style/heading"
android:text="@string/version_heading" />
<TextView
style="@style/body_text"
android:autoLink="web"
android:linksClickable="true"
android:id="@+id/versionText"
android:text="@string/version_text" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -25,6 +25,7 @@
<string name="options_vertical">Use vertical layout</string>
<string name="options_restore_on_close">Restore previous keyboard on keyboard close</string>
<string name="options_scroll">Enable swipe between packs (perpendicular to scroll direction)</string>
<string name="options_insensitive_sort">Enable case-insensitive search</string>
<string name="options_icons_per_x_lbl">"Number of Rows: "</string>
<string name="options_icon_size_status_lbl">"Icon size: "</string>
<!-- Info -->
@ -67,6 +68,9 @@ Copyright © Randy Zhou</string>
- MIT License
(See the license for more information https://github.com/FredHappyface/Android.EweSticker/blob/main/LICENSE.md )</string>
<string name="version_heading">Version Info</string>
<string name="version_text">[debug]</string>
<!-- Interactive Messages -->
<string name="pref_000">Preferences changed. Reload the keyboard for settings to apply</string>
<string name="imported_010">Starting import. This might take some time!</string>

View File

@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.3.0" apply false
id("com.android.application") version "8.5.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("org.jetbrains.dokka") version "1.9.20"
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"

View File

@ -1,6 +1,6 @@
#Thu Mar 21 23:12:37 GMT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists