diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6b3421c..c587d46 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -69,15 +69,15 @@ android { } dependencies { - dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.10") - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22") + dokkaPlugin("org.jetbrains.dokka:android-documentation-plugin:1.9.20") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23") implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.appcompat:appcompat:1.6.1") implementation("com.google.android.material:material:1.11.0") implementation("androidx.preference:preference-ktx:1.2.1") - implementation("io.coil-kt:coil:2.5.0") - implementation("io.coil-kt:coil-gif:2.5.0") - implementation("io.coil-kt:coil-video:2.5.0") + implementation("io.coil-kt:coil:2.6.0") + implementation("io.coil-kt:coil-gif:2.6.0") + implementation("io.coil-kt:coil-video:2.6.0") implementation("androidx.gridlayout:gridlayout:1.0.0") implementation("io.noties.markwon:core:4.6.2") androidTestImplementation("junit:junit:4.13.2") diff --git a/app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt b/app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt index 003529d..4fd808d 100644 --- a/app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt +++ b/app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt @@ -2,15 +2,15 @@ package com.fredhappyface.ewesticker import android.content.SharedPreferences import android.inputmethodservice.InputMethodService +import android.os.Build import android.os.Build.VERSION.SDK_INT import android.view.GestureDetector -import android.view.LayoutInflater +import android.view.HapticFeedbackConstants import android.view.MotionEvent import android.view.View import android.view.ViewGroup import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager -import android.widget.Button import android.widget.ImageButton import android.widget.LinearLayout import android.widget.RelativeLayout @@ -117,11 +117,11 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { this.iconSize = ( if (this.vertical) { - (resources.displayMetrics.widthPixels - this.totalIconPadding) / this.iconsPerX.toFloat() - } else { - (this.sharedPreferences.getInt("iconSize", 80) * scale) - } - ).toInt() + (resources.displayMetrics.widthPixels - this.totalIconPadding) / this.iconsPerX.toFloat() + } else { + (this.sharedPreferences.getInt("iconSize", 80) * scale) + } + ).toInt() this.toaster = Toaster(baseContext) // Load Packs this.loadedPacks = HashMap() @@ -173,11 +173,11 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { this.fullIconSize = ( min( - resources.displayMetrics.widthPixels, - this.keyboardHeight - + resources.displayMetrics.widthPixels, + this.keyboardHeight - resources.getDimensionPixelOffset(R.dimen.text_size_body) * 2, - ) * 0.95 - ) + ) * 0.95 + ) .toInt() createPackIcons() return keyboardLayout @@ -260,8 +260,10 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { packContent.addView(recyclerView) } + /** + * Set the current tab to the search page/ view + */ private fun searchView() { - for (packCard in this.packsList) { val packButton = packCard.findViewById(R.id.stickerButton) if (packButton.tag == "__search__") { @@ -273,66 +275,69 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { qwertyWidth = (resources.displayMetrics.widthPixels / 10.4).toInt() - val qwertyLayout = layoutInflater.inflate(R.layout.qwerty_layout, packContent, false) val searchText = qwertyLayout.findViewById(R.id.search_text) - val search_results = qwertyLayout.findViewById(R.id.search_results) + val searchResults = qwertyLayout.findViewById(R.id.search_results) val searchResultsHeight = packContent.layoutParams.height - ( resources.getDimension(R.dimen.qwerty_row_height) + - 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 { 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) { - val recyclerView = RecyclerView(this) - val adapter = StickerPackAdapter((searchResultsHeight*.95).toInt(), stickers.toTypedArray(), this, gestureDetector) - val layoutManager = GridLayoutManager( + val recyclerView = RecyclerView(baseContext) + val adapter = StickerPackAdapter( + (searchResultsHeight * 0.9).toInt(), + stickers.take(128).toTypedArray(), this, + gestureDetector, + ) + val layoutManager = GridLayoutManager( + baseContext, 1, RecyclerView.HORIZONTAL, false, ) recyclerView.layoutManager = layoutManager recyclerView.adapter = adapter - search_results.removeAllViewsInLayout() - search_results.addView(recyclerView) + searchResults.removeAllViewsInLayout() + searchResults.addView(recyclerView) } - - fun searchAppend(char:String){ + fun searchAppend(char: String) { searchText.append(char) val query = searchText.text.toString() - val searchResults = searchStickers(query) - updateSearchResults(searchResults) + updateSearchResults(searchStickers(query)) } - fun searchBack(char:String){ + fun searchBack(char: String) { if (searchText.text.isNotEmpty()) { val newText = searchText.text.substring(0, searchText.text.length - 1) searchText.text = newText } val query = searchText.text.toString() - val searchResults = searchStickers(query) - updateSearchResults(searchResults) + updateSearchResults(searchStickers(query)) } - fun searchClear(char:String){ - searchText.text = "" - search_results.removeAllViews() - } + fun searchClear(char: String) { + searchText.text = "" + searchResults.removeAllViews() + } - - - fun _addKey(char: String, secondaryChar: String,tap: (String) -> Unit = ::searchAppend,longTap: (String) -> Unit = ::searchAppend) : RelativeLayout { + fun addKey( + char: String, + secondaryChar: String, + tap: (String) -> Unit = ::searchAppend, + longTap: (String) -> Unit = ::searchAppend, + ): RelativeLayout { val buttonView = layoutInflater.inflate(R.layout.qwerty_key, null, false) val button = buttonView.findViewById(R.id.btn) val layoutParams = @@ -346,6 +351,9 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { val sText = buttonView.findViewById(R.id.secondaryText) sText.text = secondaryChar button.setOnClickListener { + if (SDK_INT >= Build.VERSION_CODES.O_MR1) { + it.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS) + } tap((it.tag as Array)[0]) } button.setOnLongClickListener { @@ -355,38 +363,40 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { return button } - fun _addRow(row: LinearLayout, chars: List, secondaryChars: List, ){ + fun addRow(row: LinearLayout, chars: List, secondaryChars: List) { for ((index, key) in chars.withIndex()) { - val button = _addKey(key, secondaryChars[index]) + val button = addKey(key, secondaryChars[index]) row.addView(button) } } val row1 = qwertyLayout.findViewById(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(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(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(R.id.qwerty_row_4) + val backspace = addKey("←", "", ::searchBack, ::searchClear) + backspace.layoutParams.width = qwertyWidth * 2 + row3.addView(backspace) - - row3.addView(_addKey("←", "", ::searchBack, ::searchClear)) - - val spacebar = _addKey(" ", " ", ) + val spacebar = addKey(" ", " ") spacebar.layoutParams.width = qwertyWidth * 7 row4.addView(spacebar) - - - - // Add the inflated layout to packContent packContent.removeAllViewsInLayout() 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 packButton = packCard.findViewById(R.id.stickerButton) packButton.tag = tag @@ -438,8 +448,8 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { } else { ( baseContext.getSystemService(INPUT_METHOD_SERVICE) as - InputMethodManager - ).showInputMethodPicker() + InputMethodManager + ).showInputMethodPicker() } } @@ -471,8 +481,8 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { this.keyboardHeight + ( resources.getDimension(R.dimen.pack_dimens) + - resources.getDimension(R.dimen.sticker_padding) * 4 - ).toInt() + resources.getDimension(R.dimen.sticker_padding) * 4 + ).toInt() val fSticker = fullStickerLayout.findViewById(R.id.stickerButton) fSticker.layoutParams.height = this.fullIconSize fSticker.layoutParams.width = this.fullIconSize @@ -550,7 +560,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener { * @return String */ fun trimString(str: String?): String { - if (str == null){ + if (str == null) { return "null" } if (str.length > 32) { diff --git a/app/src/main/res/drawable/arrow_back_circle.xml b/app/src/main/res/drawable/arrow_back_circle.xml index a572bcc..d82f003 100644 --- a/app/src/main/res/drawable/arrow_back_circle.xml +++ b/app/src/main/res/drawable/arrow_back_circle.xml @@ -1,9 +1,5 @@ - - + + + + diff --git a/app/src/main/res/drawable/search_circle.xml b/app/src/main/res/drawable/search_circle.xml index 474c0f4..78aace2 100644 --- a/app/src/main/res/drawable/search_circle.xml +++ b/app/src/main/res/drawable/search_circle.xml @@ -1,12 +1,7 @@ - - - + + + + + + diff --git a/app/src/main/res/drawable/time.xml b/app/src/main/res/drawable/time.xml index dfc6ed7..d3b12e0 100644 --- a/app/src/main/res/drawable/time.xml +++ b/app/src/main/res/drawable/time.xml @@ -1,9 +1,5 @@ - - + + + + diff --git a/build.gradle.kts b/build.gradle.kts index 21b0651..42adcf2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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.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.dokka") version "1.8.20" id("org.jlleitschuh.gradle.ktlint") version "11.6.0" diff --git a/gradle.properties b/gradle.properties index 022338b..2a7ec69 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,5 +21,4 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true -android.defaults.buildfeatures.buildconfig=true android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6be5ead..526f83d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Aug 20 19:56:21 BST 2023 +#Thu Mar 21 23:12:37 GMT 2024 distributionBase=GRADLE_USER_HOME 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 zipStorePath=wrapper/dists