mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
Fixed an issue with shortcuts and gestures with apps that have a dash on the name.
This commit is contained in:
parent
e1fc3420dd
commit
914c7a0ed4
7 changed files with 129 additions and 84 deletions
|
|
@ -143,7 +143,7 @@ class GestureAppsFragment : Fragment(), GestureAppsAdapter.OnItemClickListener {
|
||||||
|
|
||||||
private fun performConfirmedAction(appInfo: LauncherActivityInfo, appName: String, profile: Int) {
|
private fun performConfirmedAction(appInfo: LauncherActivityInfo, appName: String, profile: Int) {
|
||||||
val result = Bundle().apply {
|
val result = Bundle().apply {
|
||||||
putString("gesture_app", "$appName-${appInfo.applicationInfo.packageName}-$profile")
|
putString("gesture_app", "$appName§splitter§${appInfo.applicationInfo.packageName}§splitter§$profile")
|
||||||
}
|
}
|
||||||
setFragmentResult("request_key", result)
|
setFragmentResult("request_key", result)
|
||||||
requireActivity().supportFragmentManager.popBackStack()
|
requireActivity().supportFragmentManager.popBackStack()
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,10 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"shortcutNo" -> {
|
||||||
|
handleListItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -432,14 +436,14 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSwipeInfo(direction: String): Pair<LauncherActivityInfo?, Int?> {
|
private fun getSwipeInfo(direction: String): Pair<LauncherActivityInfo?, Int?> {
|
||||||
val app = preferences.getString("${direction}SwipeApp", "")?.split("-")
|
val app = preferences.getString("${direction}SwipeApp", "")?.split("§splitter§")
|
||||||
|
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
if (app.size >= 3)
|
if (app.size >= 3)
|
||||||
|
|
||||||
return Pair(
|
return Pair(
|
||||||
launcherApps.getActivityList(
|
launcherApps.getActivityList(
|
||||||
app?.get(1), launcherApps.profiles[app.get(2)!!
|
app[1], launcherApps.profiles[app[2]
|
||||||
.toInt()]
|
.toInt()]
|
||||||
).firstOrNull(), app[2].toInt()
|
).firstOrNull(), app[2].toInt()
|
||||||
)
|
)
|
||||||
|
|
@ -461,9 +465,20 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleListItems() {
|
private fun handleListItems() {
|
||||||
for (i in arrayOf(R.id.app1, R.id.app2, R.id.app3, R.id.app4, R.id.app5, R.id.app6, R.id.app7, R.id.app8)) {
|
val shortcuts = arrayOf(R.id.app1, R.id.app2, R.id.app3, R.id.app4, R.id.app5, R.id.app6, R.id.app7, R.id.app8)
|
||||||
|
|
||||||
val textView = findViewById<TextView>(i)
|
for (i in shortcuts.indices) {
|
||||||
|
|
||||||
|
val textView = findViewById<TextView>(shortcuts[i])
|
||||||
|
|
||||||
|
val shortcutNo = preferences.getString("shortcutNo", "4")?.toInt()
|
||||||
|
|
||||||
|
if (i >= shortcutNo!!) {
|
||||||
|
textView.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
textView.visibility = View.VISIBLE
|
||||||
|
|
||||||
unselectedSetup(textView)
|
unselectedSetup(textView)
|
||||||
|
|
||||||
|
|
@ -473,6 +488,9 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
selectedSetup(textView, savedView)
|
selectedSetup(textView, savedView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setShortcutAlignment(preferences.getString("shortcutAlignment", "left"), binding.homeView)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -702,6 +720,35 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_empty, null),null,null,null)
|
shortcutView.setCompoundDrawablesWithIntrinsicBounds(ResourcesCompat.getDrawable(resources, R.drawable.ic_empty, null),null,null,null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when (preferences.getString("shortcutAlignment", "left")) {
|
||||||
|
"left" -> {
|
||||||
|
shortcutView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
textView.compoundDrawables.filterNotNull().first(), null, null, null
|
||||||
|
)
|
||||||
|
shortcutView.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
|
}
|
||||||
|
|
||||||
|
"center" -> {
|
||||||
|
shortcutView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
shortcutView.compoundDrawables.filterNotNull().first(),
|
||||||
|
null,
|
||||||
|
shortcutView.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
shortcutView.gravity = Gravity.CENTER
|
||||||
|
}
|
||||||
|
|
||||||
|
"right" -> {
|
||||||
|
shortcutView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
shortcutView.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
|
shortcutView.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
shortcutView.text = textView.text.toString()
|
shortcutView.text = textView.text.toString()
|
||||||
shortcutView.setOnClickListener {
|
shortcutView.setOnClickListener {
|
||||||
val mainActivity = launcherApps.getActivityList(appInfo.applicationInfo.packageName, userHandle).firstOrNull()
|
val mainActivity = launcherApps.getActivityList(appInfo.applicationInfo.packageName, userHandle).firstOrNull()
|
||||||
|
|
@ -808,22 +855,36 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
if (it is TextView) {
|
if (it is TextView) {
|
||||||
|
|
||||||
|
try {
|
||||||
when (alignment) {
|
when (alignment) {
|
||||||
"left" -> {
|
"left" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(it.compoundDrawables.filterNotNull().first(),null, null, null)
|
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
it.compoundDrawables.filterNotNull().first(), null, null, null
|
||||||
|
)
|
||||||
it.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
it.gravity = Gravity.CENTER_VERTICAL or Gravity.START
|
||||||
}
|
}
|
||||||
|
|
||||||
"center" -> {
|
"center" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(it.compoundDrawables.filterNotNull().first(),null,it.compoundDrawables.filterNotNull().first(), null)
|
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
it.compoundDrawables.filterNotNull().first(),
|
||||||
|
null,
|
||||||
|
it.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
it.gravity = Gravity.CENTER
|
it.gravity = Gravity.CENTER
|
||||||
}
|
}
|
||||||
|
|
||||||
"right" -> {
|
"right" -> {
|
||||||
it.setCompoundDrawablesWithIntrinsicBounds(null,null, it.compoundDrawables.filterNotNull().first(), null)
|
it.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
it.compoundDrawables.filterNotNull().first(),
|
||||||
|
null
|
||||||
|
)
|
||||||
it.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
it.gravity = Gravity.CENTER_VERTICAL or Gravity.END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(_: Exception) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,16 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
.replace(R.id.settings_layout, GestureAppsFragment())
|
.replace(R.id.settings_layout, GestureAppsFragment())
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit()
|
.commit()
|
||||||
setFragmentResultListener("request_key") { requestKey, bundle ->
|
setFragmentResultListener("request_key") { _, bundle ->
|
||||||
clearFragmentResultListener("request_key")
|
clearFragmentResultListener("request_key")
|
||||||
val result = bundle.getString("gesture_app")
|
val result = bundle.getString("gesture_app")
|
||||||
val appDetails = result?.split("-")
|
val appDetails = result?.split("§splitter§")
|
||||||
if (leftSwipePref != null && result != null) {
|
if (leftSwipePref != null && result != null) {
|
||||||
setPreference("leftSwipeApp", result)
|
setPreference("leftSwipeApp", result)
|
||||||
}
|
}
|
||||||
sharedPreferenceManager.setGestures(requireContext(), "left",
|
sharedPreferenceManager.setGestures(
|
||||||
appDetails?.get(0), appDetails?.get(1), appDetails?.get(2)
|
requireContext(), "left",
|
||||||
|
appDetails?.get(0)
|
||||||
)
|
)
|
||||||
val appName = appDetails?.get(0)
|
val appName = appDetails?.get(0)
|
||||||
leftSwipePref?.summary = appName
|
leftSwipePref?.summary = appName
|
||||||
|
|
@ -92,15 +93,16 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
.replace(R.id.settings_layout, GestureAppsFragment())
|
.replace(R.id.settings_layout, GestureAppsFragment())
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit()
|
.commit()
|
||||||
setFragmentResultListener("request_key") { requestKey, bundle ->
|
setFragmentResultListener("request_key") { _, bundle ->
|
||||||
clearFragmentResultListener("request_key")
|
clearFragmentResultListener("request_key")
|
||||||
val result = bundle.getString("gesture_app")
|
val result = bundle.getString("gesture_app")
|
||||||
val appDetails = result?.split("-")
|
val appDetails = result?.split("§splitter§")
|
||||||
if (rightSwipePref != null && result != null) {
|
if (rightSwipePref != null && result != null) {
|
||||||
setPreference("rightSwipeApp", result)
|
setPreference("rightSwipeApp", result)
|
||||||
}
|
}
|
||||||
sharedPreferenceManager.setGestures(requireContext(), "right",
|
sharedPreferenceManager.setGestures(
|
||||||
appDetails?.get(0), appDetails?.get(1), appDetails?.get(2)
|
requireContext(), "right",
|
||||||
|
appDetails?.get(0)
|
||||||
)
|
)
|
||||||
val appName = appDetails?.get(0)
|
val appName = appDetails?.get(0)
|
||||||
rightSwipePref?.summary = appName
|
rightSwipePref?.summary = appName
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,15 @@ class SharedPreferenceManager {
|
||||||
fun setShortcut(cont: Context, textView: TextView, packageName: String, profile: Int) {
|
fun setShortcut(cont: Context, textView: TextView, packageName: String, profile: Int) {
|
||||||
val editor = cont.getSharedPreferences("shortcuts", AppCompatActivity.MODE_PRIVATE).edit()
|
val editor = cont.getSharedPreferences("shortcuts", AppCompatActivity.MODE_PRIVATE).edit()
|
||||||
val key = textView.id.toString()
|
val key = textView.id.toString()
|
||||||
editor.putString(key, "$packageName-$profile-${textView.text}")
|
editor.putString(key, "$packageName§splitter§$profile§splitter§${textView.text}")
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getShortcut(cont: Context, textView: TextView): List<String>? {
|
fun getShortcut(cont: Context, textView: TextView): List<String>? {
|
||||||
val sharedPref = cont.getSharedPreferences("shortcuts", AppCompatActivity.MODE_PRIVATE)
|
val sharedPref = cont.getSharedPreferences("shortcuts", AppCompatActivity.MODE_PRIVATE)
|
||||||
val key = textView.id.toString()
|
val key = textView.id.toString()
|
||||||
val value = sharedPref.getString(key, "e-e")
|
val value = sharedPref.getString(key, "e§splitter§e")
|
||||||
return value?.split("-")
|
return value?.split("§splitter§")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAppHidden(cont: Context, packageName: String, profile: Int, hidden: Boolean) {
|
fun setAppHidden(cont: Context, packageName: String, profile: Int, hidden: Boolean) {
|
||||||
|
|
@ -81,20 +81,14 @@ class SharedPreferenceManager {
|
||||||
return sharedPreferences.getString(key, "")
|
return sharedPreferences.getString(key, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setGestures(cont: Context, direction: String, appName: String?, packageName: String?, profile: String?) {
|
fun setGestures(cont: Context, direction: String, appName: String?) {
|
||||||
val editor = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE).edit()
|
val editor = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE).edit()
|
||||||
val nameKey = "$direction-name"
|
val nameKey = "$direction-name"
|
||||||
editor.putString(direction, "$packageName-$profile")
|
|
||||||
editor.putString(nameKey, appName)
|
editor.putString(nameKey, appName)
|
||||||
editor.apply()
|
editor.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getGestureApp(cont: Context, direction: String) : String? {
|
|
||||||
val sharedPreferences = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE)
|
|
||||||
return sharedPreferences.getString(direction, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getGestureName(cont: Context, direction: String) : String? {
|
fun getGestureName(cont: Context, direction: String) : String? {
|
||||||
val sharedPreferences = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE)
|
val sharedPreferences = cont.getSharedPreferences("gestures", AppCompatActivity.MODE_PRIVATE)
|
||||||
val key = "$direction-name"
|
val key = "$direction-name"
|
||||||
|
|
|
||||||
|
|
@ -144,12 +144,7 @@
|
||||||
android:text="@string/shortcut_default"
|
android:text="@string/shortcut_default"
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textColor="#F3F3F3"
|
android:textColor="#F3F3F3"
|
||||||
android:visibility="visible" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app2"
|
android:id="@+id/app2"
|
||||||
|
|
@ -167,12 +162,7 @@
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textColor="#F3F3F3"
|
android:textColor="#F3F3F3"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="visible" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app3"
|
android:id="@+id/app3"
|
||||||
|
|
@ -190,12 +180,7 @@
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textColor="#F3F3F3"
|
android:textColor="#F3F3F3"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="visible" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app4"
|
android:id="@+id/app4"
|
||||||
|
|
@ -213,12 +198,6 @@
|
||||||
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
android:textAppearance="@android:style/TextAppearance.DeviceDefault"
|
||||||
android:textColor="#F3F3F3"
|
android:textColor="#F3F3F3"
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="visible" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01"
|
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
@ -239,12 +218,6 @@
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app6"
|
android:id="@+id/app6"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -263,12 +236,6 @@
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app7"
|
android:id="@+id/app7"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -287,12 +254,6 @@
|
||||||
android:textSize="28sp"
|
android:textSize="28sp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="0.01"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/app8"
|
android:id="@+id/app8"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
||||||
|
|
@ -67,4 +67,16 @@
|
||||||
<item>#FFF3F3F3</item>
|
<item>#FFF3F3F3</item>
|
||||||
<item>#FF0C0C0C</item>
|
<item>#FF0C0C0C</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="shortcut_options">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
<item>2</item>
|
||||||
|
<item>3</item>
|
||||||
|
<item>4</item>
|
||||||
|
<item>5</item>
|
||||||
|
<item>6</item>
|
||||||
|
<item>7</item>
|
||||||
|
<item>8</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,6 +1,21 @@
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:allowDividerAbove="false"
|
||||||
|
app:title="Shortcuts">
|
||||||
|
<ListPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:defaultValue="4"
|
||||||
|
app:entries="@array/shortcut_options"
|
||||||
|
app:entryValues="@array/shortcut_options"
|
||||||
|
app:key="shortcutNo"
|
||||||
|
app:title="Number of Shortcuts"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -43,7 +58,7 @@
|
||||||
app:entries="@array/h_alignment_options"
|
app:entries="@array/h_alignment_options"
|
||||||
app:entryValues="@array/h_alignment_values"
|
app:entryValues="@array/h_alignment_values"
|
||||||
app:key="shortcutAlignment"
|
app:key="shortcutAlignment"
|
||||||
app:title="Home App Alignment"
|
app:title="Shortcut Alignment"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue