mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Added accessibility actions for choosing a shortcut, opening the app menu and closing the app menu
This commit is contained in:
parent
fc418e6a2c
commit
562e728c69
3 changed files with 36 additions and 8 deletions
|
|
@ -14,6 +14,7 @@ import android.widget.FrameLayout
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.core.content.res.ResourcesCompat
|
import androidx.core.content.res.ResourcesCompat
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import eu.ottop.yamlauncher.databinding.ActivityMainBinding
|
import eu.ottop.yamlauncher.databinding.ActivityMainBinding
|
||||||
|
|
@ -181,6 +182,10 @@ class AppMenuAdapter(
|
||||||
appActivity
|
appActivity
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
ViewCompat.addAccessibilityAction(holder.textView, "Close App Menu") { _, _ ->
|
||||||
|
activity.backToHome()
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,25 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
super.onTouchEvent(event)
|
super.onTouchEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewCompat.addAccessibilityAction(textView, "Set Shortcut App") { _, _ ->
|
||||||
|
uiUtils.setMenuTitleAlignment(binding.menuTitle)
|
||||||
|
binding.menuTitle.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
adapter?.shortcutTextView = textView
|
||||||
|
toAppMenu()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewCompat.addAccessibilityAction(textView, "Launcher Settings") { _, _ ->
|
||||||
|
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewCompat.addAccessibilityAction(textView, "Open App Menu") { _, _ ->
|
||||||
|
openAppMenu()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
textView.setOnLongClickListener {
|
textView.setOnLongClickListener {
|
||||||
uiUtils.setMenuTitleAlignment(binding.menuTitle)
|
uiUtils.setMenuTitleAlignment(binding.menuTitle)
|
||||||
binding.menuTitle.visibility = View.VISIBLE
|
binding.menuTitle.visibility = View.VISIBLE
|
||||||
|
|
@ -314,11 +333,16 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewCompat.addAccessibilityAction(binding.homeView, "Preferences") { _, _ ->
|
ViewCompat.addAccessibilityAction(binding.homeView, "Launcher Settings") { _, _ ->
|
||||||
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
|
startActivity(Intent(this@MainActivity, SettingsActivity::class.java))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewCompat.addAccessibilityAction(binding.homeView, "Open App Menu") { _, _ ->
|
||||||
|
openAppMenu()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
// Return to home on back
|
// Return to home on back
|
||||||
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
|
|
@ -341,6 +365,12 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openAppMenu() {
|
||||||
|
adapter?.shortcutTextView = null
|
||||||
|
binding.menuTitle.visibility = View.GONE
|
||||||
|
toAppMenu()
|
||||||
|
}
|
||||||
|
|
||||||
// Only reload items that have had preferences changed
|
// Only reload items that have had preferences changed
|
||||||
override fun onSharedPreferenceChanged(preferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(preferences: SharedPreferences?, key: String?) {
|
||||||
if (preferences != null) {
|
if (preferences != null) {
|
||||||
|
|
@ -773,12 +803,6 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openAppMenu() {
|
|
||||||
adapter?.shortcutTextView = null
|
|
||||||
binding.menuTitle.visibility = View.GONE
|
|
||||||
toAppMenu()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class TextGestureListener : GestureListener() {
|
inner class TextGestureListener : GestureListener() {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import android.graphics.Color
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import eu.ottop.yamlauncher.R
|
|
||||||
|
|
||||||
class SharedPreferenceManager (private val context: Context) {
|
class SharedPreferenceManager (private val context: Context) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue