Automatic keyboard opening implemented and regex improved to include non-english alphabet letters

This commit is contained in:
ottoptj 2024-08-06 04:45:18 +03:00
commit e1fc3420dd
5 changed files with 34 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package eu.ottop.yamlauncher
import android.app.Activity import android.app.Activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context
import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherActivityInfo
import android.os.Bundle import android.os.Bundle
import android.os.UserHandle import android.os.UserHandle
@ -11,7 +12,9 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
class HiddenAppsFragment : Fragment(), HiddenAppsAdapter.OnItemClickListener { 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?) { private fun filterItems(query: String?) {

View file

@ -1,6 +1,7 @@
package eu.ottop.yamlauncher package eu.ottop.yamlauncher
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.text.Editable import android.text.Editable
import android.text.TextWatcher import android.text.TextWatcher
@ -8,9 +9,11 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import androidx.fragment.app.setFragmentResult import androidx.fragment.app.setFragmentResult
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers 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?) { private fun showConfirmationDialog(appName: String?, latitude: String?, longitude: String?) {

View file

@ -671,6 +671,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
private fun toAppMenu() { private fun toAppMenu() {
animations.showApps(binding) animations.showApps(binding)
animations.backgroundIn(this@MainActivity, Color.parseColor(preferences.getString("bgColor", "#00000000"))) 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) { override fun onItemClick(appInfo: LauncherActivityInfo, userHandle: UserHandle) {

View file

@ -15,7 +15,7 @@ class StringUtils {
} }
fun cleanString(string: String?) : String? { 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) { fun setLink(view: TextView, link: String) {

View file

@ -119,7 +119,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:allowDividerAbove="false" app:allowDividerAbove="false"
app:title="System bars"> app:title="System Bars">
<SwitchPreference <SwitchPreference
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -158,6 +158,12 @@
app:key="rightSwipeApp" app:key="rightSwipeApp"
app:selectable="true" app:selectable="true"
app:title="Right Swipe App" /> app:title="Right Swipe App" />
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="false"
android:title="Automatically Open Keyboard"
app:key="autoKeyboard" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:layout_width="wrap_content" android:layout_width="wrap_content"