limit search results to 128 + update agp + ktlintCheck passes
This commit is contained in:
parent
92492c934d
commit
cc1535edcd
@ -69,15 +69,15 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.10")
|
dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.20")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23")
|
||||||
implementation("androidx.core:core-ktx:1.12.0")
|
implementation("androidx.core:core-ktx:1.12.0")
|
||||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||||
implementation("com.google.android.material:material:1.11.0")
|
implementation("com.google.android.material:material:1.11.0")
|
||||||
implementation("androidx.preference:preference-ktx:1.2.1")
|
implementation("androidx.preference:preference-ktx:1.2.1")
|
||||||
implementation("io.coil-kt:coil:2.5.0")
|
implementation("io.coil-kt:coil:2.6.0")
|
||||||
implementation("io.coil-kt:coil-gif:2.5.0")
|
implementation("io.coil-kt:coil-gif:2.6.0")
|
||||||
implementation("io.coil-kt:coil-video:2.5.0")
|
implementation("io.coil-kt:coil-video:2.6.0")
|
||||||
implementation("androidx.gridlayout:gridlayout:1.0.0")
|
implementation("androidx.gridlayout:gridlayout:1.0.0")
|
||||||
implementation("io.noties.markwon:core:4.6.2")
|
implementation("io.noties.markwon:core:4.6.2")
|
||||||
androidTestImplementation("junit:junit:4.13.2")
|
androidTestImplementation("junit:junit:4.13.2")
|
||||||
|
@ -2,15 +2,15 @@ package com.fredhappyface.ewesticker
|
|||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.inputmethodservice.InputMethodService
|
import android.inputmethodservice.InputMethodService
|
||||||
|
import android.os.Build
|
||||||
import android.os.Build.VERSION.SDK_INT
|
import android.os.Build.VERSION.SDK_INT
|
||||||
import android.view.GestureDetector
|
import android.view.GestureDetector
|
||||||
import android.view.LayoutInflater
|
import android.view.HapticFeedbackConstants
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
@ -260,8 +260,10 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
packContent.addView(recyclerView)
|
packContent.addView(recyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current tab to the search page/ view
|
||||||
|
*/
|
||||||
private fun searchView() {
|
private fun searchView() {
|
||||||
|
|
||||||
for (packCard in this.packsList) {
|
for (packCard in this.packsList) {
|
||||||
val packButton = packCard.findViewById<ImageButton>(R.id.stickerButton)
|
val packButton = packCard.findViewById<ImageButton>(R.id.stickerButton)
|
||||||
if (packButton.tag == "__search__") {
|
if (packButton.tag == "__search__") {
|
||||||
@ -273,10 +275,9 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
|
|
||||||
qwertyWidth = (resources.displayMetrics.widthPixels / 10.4).toInt()
|
qwertyWidth = (resources.displayMetrics.widthPixels / 10.4).toInt()
|
||||||
|
|
||||||
|
|
||||||
val qwertyLayout = layoutInflater.inflate(R.layout.qwerty_layout, packContent, false)
|
val qwertyLayout = layoutInflater.inflate(R.layout.qwerty_layout, packContent, false)
|
||||||
val searchText = qwertyLayout.findViewById<TextView>(R.id.search_text)
|
val searchText = qwertyLayout.findViewById<TextView>(R.id.search_text)
|
||||||
val search_results = qwertyLayout.findViewById<LinearLayout>(R.id.search_results)
|
val searchResults = qwertyLayout.findViewById<LinearLayout>(R.id.search_results)
|
||||||
|
|
||||||
val searchResultsHeight =
|
val searchResultsHeight =
|
||||||
packContent.layoutParams.height -
|
packContent.layoutParams.height -
|
||||||
@ -285,34 +286,36 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
resources.getDimension(R.dimen.qwerty_row_height) * 4
|
resources.getDimension(R.dimen.qwerty_row_height) * 4
|
||||||
)
|
)
|
||||||
|
|
||||||
search_results.layoutParams.height = searchResultsHeight.toInt()
|
searchResults.layoutParams.height = searchResultsHeight.toInt()
|
||||||
|
|
||||||
fun searchStickers(query: String): List<File> {
|
fun searchStickers(query: String): List<File> {
|
||||||
return this.allStickers.filter { it.name.contains(query, ignoreCase = true) }
|
return this.allStickers.filter { it.name.contains(query, ignoreCase = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to update the search results view with a list of stickers
|
|
||||||
fun updateSearchResults(stickers: List<File>) {
|
fun updateSearchResults(stickers: List<File>) {
|
||||||
val recyclerView = RecyclerView(this)
|
val recyclerView = RecyclerView(baseContext)
|
||||||
val adapter = StickerPackAdapter((searchResultsHeight*.95).toInt(), stickers.toTypedArray(), this, gestureDetector)
|
val adapter = StickerPackAdapter(
|
||||||
val layoutManager = GridLayoutManager(
|
(searchResultsHeight * 0.9).toInt(),
|
||||||
|
stickers.take(128).toTypedArray(),
|
||||||
this,
|
this,
|
||||||
|
gestureDetector,
|
||||||
|
)
|
||||||
|
val layoutManager = GridLayoutManager(
|
||||||
|
baseContext,
|
||||||
1,
|
1,
|
||||||
RecyclerView.HORIZONTAL,
|
RecyclerView.HORIZONTAL,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
recyclerView.layoutManager = layoutManager
|
recyclerView.layoutManager = layoutManager
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
search_results.removeAllViewsInLayout()
|
searchResults.removeAllViewsInLayout()
|
||||||
search_results.addView(recyclerView)
|
searchResults.addView(recyclerView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun searchAppend(char: String) {
|
fun searchAppend(char: String) {
|
||||||
searchText.append(char)
|
searchText.append(char)
|
||||||
val query = searchText.text.toString()
|
val query = searchText.text.toString()
|
||||||
val searchResults = searchStickers(query)
|
updateSearchResults(searchStickers(query))
|
||||||
updateSearchResults(searchResults)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchBack(char: String) {
|
fun searchBack(char: String) {
|
||||||
@ -321,18 +324,20 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
searchText.text = newText
|
searchText.text = newText
|
||||||
}
|
}
|
||||||
val query = searchText.text.toString()
|
val query = searchText.text.toString()
|
||||||
val searchResults = searchStickers(query)
|
updateSearchResults(searchStickers(query))
|
||||||
updateSearchResults(searchResults)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun searchClear(char: String) {
|
fun searchClear(char: String) {
|
||||||
searchText.text = ""
|
searchText.text = ""
|
||||||
search_results.removeAllViews()
|
searchResults.removeAllViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addKey(
|
||||||
|
char: String,
|
||||||
fun _addKey(char: String, secondaryChar: String,tap: (String) -> Unit = ::searchAppend,longTap: (String) -> Unit = ::searchAppend) : RelativeLayout {
|
secondaryChar: String,
|
||||||
|
tap: (String) -> Unit = ::searchAppend,
|
||||||
|
longTap: (String) -> Unit = ::searchAppend,
|
||||||
|
): RelativeLayout {
|
||||||
val buttonView = layoutInflater.inflate(R.layout.qwerty_key, null, false)
|
val buttonView = layoutInflater.inflate(R.layout.qwerty_key, null, false)
|
||||||
val button = buttonView.findViewById<RelativeLayout>(R.id.btn)
|
val button = buttonView.findViewById<RelativeLayout>(R.id.btn)
|
||||||
val layoutParams =
|
val layoutParams =
|
||||||
@ -346,6 +351,9 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
val sText = buttonView.findViewById<TextView>(R.id.secondaryText)
|
val sText = buttonView.findViewById<TextView>(R.id.secondaryText)
|
||||||
sText.text = secondaryChar
|
sText.text = secondaryChar
|
||||||
button.setOnClickListener {
|
button.setOnClickListener {
|
||||||
|
if (SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||||
|
it.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS)
|
||||||
|
}
|
||||||
tap((it.tag as Array<String>)[0])
|
tap((it.tag as Array<String>)[0])
|
||||||
}
|
}
|
||||||
button.setOnLongClickListener {
|
button.setOnLongClickListener {
|
||||||
@ -355,38 +363,40 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
|
|||||||
return button
|
return button
|
||||||
}
|
}
|
||||||
|
|
||||||
fun _addRow(row: LinearLayout, chars: List<String>, secondaryChars: List<String>, ){
|
fun addRow(row: LinearLayout, chars: List<String>, secondaryChars: List<String>) {
|
||||||
for ((index, key) in chars.withIndex()) {
|
for ((index, key) in chars.withIndex()) {
|
||||||
val button = _addKey(key, secondaryChars[index])
|
val button = addKey(key, secondaryChars[index])
|
||||||
row.addView(button)
|
row.addView(button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val row1 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_1)
|
val row1 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_1)
|
||||||
_addRow(row1, "QWERTYUIOP".map { it.toString() }, "1234567890".map { it.toString() })
|
addRow(row1, "QWERTYUIOP".map { it.toString() }, "1234567890".map { it.toString() })
|
||||||
val row2 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_2)
|
val row2 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_2)
|
||||||
_addRow(row2, "ASDFGHJKL".map { it.toString() }, "@#£_&-+()".map { it.toString() })
|
addRow(row2, "ASDFGHJKL".map { it.toString() }, "@#£_&-+()".map { it.toString() })
|
||||||
val row3 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_3)
|
val row3 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_3)
|
||||||
_addRow(row3, "ZXCVBNM".map { it.toString() }, "*\"':;!?".map { it.toString() })
|
addRow(row3, "ZXCVBNM".map { it.toString() }, "*\"':;!?".map { it.toString() })
|
||||||
val row4 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_4)
|
val row4 = qwertyLayout.findViewById<LinearLayout>(R.id.qwerty_row_4)
|
||||||
|
|
||||||
|
val backspace = addKey("←", "", ::searchBack, ::searchClear)
|
||||||
|
backspace.layoutParams.width = qwertyWidth * 2
|
||||||
|
row3.addView(backspace)
|
||||||
|
|
||||||
|
val spacebar = addKey(" ", " ")
|
||||||
row3.addView(_addKey("←", "", ::searchBack, ::searchClear))
|
|
||||||
|
|
||||||
val spacebar = _addKey(" ", " ", )
|
|
||||||
spacebar.layoutParams.width = qwertyWidth * 7
|
spacebar.layoutParams.width = qwertyWidth * 7
|
||||||
row4.addView(spacebar)
|
row4.addView(spacebar)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add the inflated layout to packContent
|
|
||||||
packContent.removeAllViewsInLayout()
|
packContent.removeAllViewsInLayout()
|
||||||
packContent.addView(qwertyLayout)
|
packContent.addView(qwertyLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addPackButton(tag: Any): ImageButton {
|
/**
|
||||||
|
* Adds a pack button to the packsList/ tab bar.
|
||||||
|
*
|
||||||
|
* @param tag The pack name associated with the pack button.
|
||||||
|
* @return The ImageButton representing the added pack button.
|
||||||
|
*/
|
||||||
|
private fun addPackButton(tag: String): ImageButton {
|
||||||
val packCard = layoutInflater.inflate(R.layout.sticker_card, this.packsList, false)
|
val packCard = layoutInflater.inflate(R.layout.sticker_card, this.packsList, false)
|
||||||
val packButton = packCard.findViewById<ImageButton>(R.id.stickerButton)
|
val packButton = packCard.findViewById<ImageButton>(R.id.stickerButton)
|
||||||
packButton.tag = tag
|
packButton.tag = tag
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="200dp" android:viewportHeight="512" android:viewportWidth="512" android:width="200dp">
|
||||||
android:width="512dp"
|
|
||||||
android:height="512dp"
|
<path android:fillColor="@color/fg" android:pathData="M48,256c0,114.87 93.13,208 208,208s208,-93.13 208,-208S370.87,48 256,48 48,141.13 48,256zM260.65,164.64a16,16 0,0 1,0.09 22.63L208.42,240L342,240a16,16 0,0 1,0 32L208.42,272l52.32,52.73A16,16 0,1 1,238 347.27l-79.39,-80a16,16 0,0 1,0 -22.54l79.39,-80a16,16 0,0 1,22.65 -0.09z"/>
|
||||||
android:viewportWidth="512"
|
|
||||||
android:viewportHeight="512">
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/fg"
|
|
||||||
android:pathData="M48,256c0,114.87 93.13,208 208,208s208,-93.13 208,-208S370.87,48 256,48 48,141.13 48,256zM260.65,164.64a16,16 0,0 1,0.09 22.63L208.42,240L342,240a16,16 0,0 1,0 32L208.42,272l52.32,52.73A16,16 0,1 1,238 347.27l-79.39,-80a16,16 0,0 1,0 -22.54l79.39,-80a16,16 0,0 1,22.65 -0.09z" />
|
|
||||||
</vector>
|
</vector>
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="200dp" android:viewportHeight="512" android:viewportWidth="512" android:width="200dp">
|
||||||
android:width="512dp"
|
|
||||||
android:height="512dp"
|
<path android:fillColor="@color/fg" android:pathData="M256,48C141.31,48 48,141.31 48,256 48,370.69 141.31,464 256,464 370.69,464 464,370.69 464,256 464,141.31 370.69,48 256,48ZM354.92,354.92a17.33,17.33 0,0 1,-24.5 0l-46.41,-46.4a95.42,95.42 0,1 1,24.52 -24.52l46.4,46.41a17.33,17.33 0,0 1,0 24.5z"/>
|
||||||
android:viewportWidth="512"
|
|
||||||
android:viewportHeight="512">
|
<path android:fillColor="@color/fg" android:pathData="M230,230m-60.67,0a60.67,60.67 0,1 1,121.33 0a60.67,60.67 0,1 1,-121.33 0"/>
|
||||||
<path
|
|
||||||
android:fillColor="@color/fg"
|
|
||||||
android:pathData="M256,48C141.31,48 48,141.31 48,256 48,370.69 141.31,464 256,464 370.69,464 464,370.69 464,256 464,141.31 370.69,48 256,48ZM354.92,354.92a17.33,17.33 0,0 1,-24.5 0l-46.41,-46.4a95.42,95.42 0,1 1,24.52 -24.52l46.4,46.41a17.33,17.33 0,0 1,0 24.5z"/>
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/fg"
|
|
||||||
android:pathData="M230,230m-60.67,0a60.67,60.67 0,1 1,121.33 0a60.67,60.67 0,1 1,-121.33 0"/>
|
|
||||||
</vector>
|
</vector>
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="200dp" android:viewportHeight="512" android:viewportWidth="512" android:width="200dp">
|
||||||
android:width="512dp"
|
|
||||||
android:height="512dp"
|
<path android:fillColor="@color/fg" android:pathData="M256,48C141.13,48 48,141.13 48,256s93.13,208 208,208 208,-93.13 208,-208S370.87,48 256,48zM352,288h-96a16,16 0,0 1,-16 -16L240,128a16,16 0,0 1,32 0v128h80a16,16 0,0 1,0 32z"/>
|
||||||
android:viewportWidth="512"
|
|
||||||
android:viewportHeight="512">
|
|
||||||
<path
|
|
||||||
android:fillColor="@color/fg"
|
|
||||||
android:pathData="M256,48C141.13,48 48,141.13 48,256s93.13,208 208,208 208,-93.13 208,-208S370.87,48 256,48zM352,288h-96a16,16 0,0 1,-16 -16L240,128a16,16 0,0 1,32 0v128h80a16,16 0,0 1,0 32z" />
|
|
||||||
</vector>
|
</vector>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application") version "8.2.1" apply false
|
id("com.android.application") version "8.3.0" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
|
||||||
id("org.jetbrains.dokka") version "1.8.20"
|
id("org.jetbrains.dokka") version "1.8.20"
|
||||||
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
|
id("org.jlleitschuh.gradle.ktlint") version "11.6.0"
|
||||||
|
@ -21,5 +21,4 @@ kotlin.code.style=official
|
|||||||
# resources declared in the library itself and none from the library's dependencies,
|
# resources declared in the library itself and none from the library's dependencies,
|
||||||
# thereby reducing the size of the R class for that library
|
# thereby reducing the size of the R class for that library
|
||||||
android.nonTransitiveRClass=true
|
android.nonTransitiveRClass=true
|
||||||
android.defaults.buildfeatures.buildconfig=true
|
|
||||||
android.nonFinalResIds=false
|
android.nonFinalResIds=false
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Sun Aug 20 19:56:21 BST 2023
|
#Thu Mar 21 23:12:37 GMT 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user