From e1fc3420dd6ad5fc12f84a0e25d67ccf9fa8b38a Mon Sep 17 00:00:00 2001 From: ottoptj Date: Tue, 6 Aug 2024 04:45:18 +0300 Subject: [PATCH] Automatic keyboard opening implemented and regex improved to include non-english alphabet letters --- .../java/eu/ottop/yamlauncher/HiddenAppsFragment.kt | 10 ++++++++++ .../main/java/eu/ottop/yamlauncher/LocationFragment.kt | 10 ++++++++++ app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt | 6 ++++++ app/src/main/java/eu/ottop/yamlauncher/StringUtils.kt | 2 +- app/src/main/res/xml/root_preferences.xml | 8 +++++++- 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt index a46a156..ef6693d 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/HiddenAppsFragment.kt @@ -2,6 +2,7 @@ package eu.ottop.yamlauncher import android.app.Activity import android.app.AlertDialog +import android.content.Context import android.content.pm.LauncherActivityInfo import android.os.Bundle import android.os.UserHandle @@ -11,7 +12,9 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import android.widget.EditText +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { @@ -64,6 +67,13 @@ class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { } }) + + if (PreferenceManager.getDefaultSharedPreferences(requireContext()).getBoolean("autoKeyboard", false)) { + val imm = + requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + searchView.requestFocus() + imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT) + } } private fun filterItems(query: String?) { diff --git a/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt b/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt index cf73c7d..61e90ab 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/LocationFragment.kt @@ -1,6 +1,7 @@ package eu.ottop.yamlauncher import android.app.AlertDialog +import android.content.Context import android.os.Bundle import android.text.Editable import android.text.TextWatcher @@ -8,9 +9,11 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.inputmethod.InputMethodManager import android.widget.EditText import androidx.fragment.app.setFragmentResult import androidx.preference.Preference +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.RecyclerView import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -87,6 +90,13 @@ class LocationFragment : Fragment(), LocationListAdapter.OnItemClickListener { } }) + + if (PreferenceManager.getDefaultSharedPreferences(requireContext()).getBoolean("autoKeyboard", false)) { + val imm = + requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + searchView.requestFocus() + imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT) + } } private fun showConfirmationDialog(appName: String?, latitude: String?, longitude: String?) { diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt index 30a7e42..09094d3 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt @@ -671,6 +671,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh private fun toAppMenu() { animations.showApps(binding) animations.backgroundIn(this@MainActivity, Color.parseColor(preferences.getString("bgColor", "#00000000"))) + if (preferences.getBoolean("autoKeyboard", false)) { + val imm = + getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager + searchView.requestFocus() + imm.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT) + } } override fun onItemClick(appInfo: LauncherActivityInfo, userHandle: UserHandle) { diff --git a/app/src/main/java/eu/ottop/yamlauncher/StringUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/StringUtils.kt index 3484f41..ca316db 100644 --- a/app/src/main/java/eu/ottop/yamlauncher/StringUtils.kt +++ b/app/src/main/java/eu/ottop/yamlauncher/StringUtils.kt @@ -15,7 +15,7 @@ class StringUtils { } fun cleanString(string: String?) : String? { - return string?.replace("[^a-zA-Z0-9]".toRegex(), "") + return string?.replace("[^\\p{L}0-9]".toRegex(), "") } fun setLink(view: TextView, link: String) { diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index b37ac35..d78cb35 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -119,7 +119,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" app:allowDividerAbove="false" - app:title="System bars"> + app:title="System Bars"> +