mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Added accessibility actions for the contact menu
This commit is contained in:
parent
2dc161e080
commit
fdc8fad134
4 changed files with 58 additions and 26 deletions
|
|
@ -188,6 +188,13 @@ class AppMenuAdapter(
|
||||||
activity.backToHome()
|
activity.backToHome()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sharedPreferenceManager.areContactsEnabled()) {
|
||||||
|
ViewCompat.addAccessibilityAction(holder.textView, activity.getString(R.string.switch_to_contacts)) { _, _ ->
|
||||||
|
activity.switchMenus()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
package eu.ottop.yamlauncher
|
package eu.ottop.yamlauncher
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
|
||||||
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.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
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 eu.ottop.yamlauncher.settings.SharedPreferenceManager
|
import eu.ottop.yamlauncher.settings.SharedPreferenceManager
|
||||||
import eu.ottop.yamlauncher.utils.UIUtils
|
import eu.ottop.yamlauncher.utils.UIUtils
|
||||||
|
|
||||||
class ContactsAdapter(
|
class ContactsAdapter(
|
||||||
private val context: Context,
|
private val activity: MainActivity,
|
||||||
private var contacts: MutableList<Pair<String, Int>>,
|
private var contacts: MutableList<Pair<String, Int>>,
|
||||||
private val contactClickListener: OnContactClickListener
|
private val contactClickListener: OnContactClickListener
|
||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<ContactsAdapter.AppViewHolder>() {
|
RecyclerView.Adapter<ContactsAdapter.AppViewHolder>() {
|
||||||
|
|
||||||
private val uiUtils = UIUtils(context)
|
private val uiUtils = UIUtils(activity)
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(activity)
|
||||||
|
|
||||||
interface OnContactClickListener {
|
interface OnContactClickListener {
|
||||||
fun onContactClick(contactId: Int)
|
fun onContactClick(contactId: Int)
|
||||||
|
|
@ -49,7 +49,7 @@ class ContactsAdapter(
|
||||||
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: AppViewHolder, position: Int) {
|
||||||
val contact = contacts[position]
|
val contact = contacts[position]
|
||||||
holder.textView.setCompoundDrawablesWithIntrinsicBounds(
|
holder.textView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null),null, ResourcesCompat.getDrawable(context.resources, R.drawable.ic_empty, null),null)
|
ResourcesCompat.getDrawable(activity.resources, R.drawable.ic_empty, null),null, ResourcesCompat.getDrawable(activity.resources, R.drawable.ic_empty, null),null)
|
||||||
|
|
||||||
uiUtils.setAppAlignment(holder.textView)
|
uiUtils.setAppAlignment(holder.textView)
|
||||||
|
|
||||||
|
|
@ -63,6 +63,18 @@ class ContactsAdapter(
|
||||||
holder.textView.text = contact.first
|
holder.textView.text = contact.first
|
||||||
|
|
||||||
holder.textView.visibility = View.VISIBLE
|
holder.textView.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
ViewCompat.addAccessibilityAction(holder.textView, "Close App Menu") { _, _ ->
|
||||||
|
activity.backToHome()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedPreferenceManager.areContactsEnabled()) {
|
||||||
|
ViewCompat.addAccessibilityAction(holder.textView, activity.getString(R.string.switch_to_apps)) { _, _ ->
|
||||||
|
activity.switchMenus()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
|
|
|
||||||
|
|
@ -742,29 +742,41 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
setupRecyclerListener(contactRecycler, contactMenuLinearLayoutManager)
|
setupRecyclerListener(contactRecycler, contactMenuLinearLayoutManager)
|
||||||
|
|
||||||
searchSwitcher.setOnClickListener {
|
searchSwitcher.setOnClickListener {
|
||||||
menuView.showNext()
|
switchMenus()
|
||||||
when (menuView.displayedChild) {
|
}
|
||||||
0 -> {
|
}
|
||||||
searchSwitcher.setImageDrawable(
|
|
||||||
ResourcesCompat.getDrawable(
|
fun switchMenus() {
|
||||||
resources,
|
menuView.showNext()
|
||||||
R.drawable.contacts_24px,
|
when (menuView.displayedChild) {
|
||||||
null
|
0 -> {
|
||||||
)
|
setAppViewDetails()
|
||||||
)
|
}
|
||||||
searchSwitcher.contentDescription = getString(R.string.switch_to_contacts)
|
1 -> {
|
||||||
}
|
setContactViewDetails()
|
||||||
1 -> {
|
|
||||||
lifecycleScope.launch(Dispatchers.Default) {
|
|
||||||
filterItems(searchView.text.toString())
|
|
||||||
}
|
|
||||||
searchSwitcher.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.apps_24px, null))
|
|
||||||
searchSwitcher.contentDescription = getString(R.string.switch_to_apps)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setAppViewDetails() {
|
||||||
|
searchSwitcher.setImageDrawable(
|
||||||
|
ResourcesCompat.getDrawable(
|
||||||
|
resources,
|
||||||
|
R.drawable.contacts_24px,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
)
|
||||||
|
searchSwitcher.contentDescription = getString(R.string.switch_to_contacts)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setContactViewDetails() {
|
||||||
|
lifecycleScope.launch(Dispatchers.Default) {
|
||||||
|
filterItems(searchView.text.toString())
|
||||||
|
}
|
||||||
|
searchSwitcher.setImageDrawable(ResourcesCompat.getDrawable(resources, R.drawable.apps_24px, null))
|
||||||
|
searchSwitcher.contentDescription = getString(R.string.switch_to_apps)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getContacts(filterString: String): MutableList<Pair<String, Int>> {
|
private fun getContacts(filterString: String): MutableList<Pair<String, Int>> {
|
||||||
val contacts = mutableListOf<Pair<String, Int>>()
|
val contacts = mutableListOf<Pair<String, Int>>()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
<string name="search">Search…</string>
|
<string name="search">Search…</string>
|
||||||
|
|
||||||
|
<string name="switch_to_contacts">Switch to Contacts</string>
|
||||||
|
<string name="switch_to_apps">Switch to Apps</string>
|
||||||
|
|
||||||
<!--Action Menu Items-->
|
<!--Action Menu Items-->
|
||||||
<string name="reset">Reset</string>
|
<string name="reset">Reset</string>
|
||||||
<string name="info">Info</string>
|
<string name="info">Info</string>
|
||||||
|
|
@ -44,6 +47,4 @@
|
||||||
<string name="region_text">%1$s%2$s</string>
|
<string name="region_text">%1$s%2$s</string>
|
||||||
|
|
||||||
<string name="accessibility_service_description">The permission is required for double tap to work for locking the screen.\n\nIt is only needed if you want to use the double tap to lock screen feature in YAM Launcher.</string>
|
<string name="accessibility_service_description">The permission is required for double tap to work for locking the screen.\n\nIt is only needed if you want to use the double tap to lock screen feature in YAM Launcher.</string>
|
||||||
<string name="switch_to_contacts">Switch to Contacts</string>
|
|
||||||
<string name="switch_to_apps">Switch to Apps</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue