mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-05 01:47:24 +00:00
Fixed gestures to work with component names and started work on viewing hidden apps when selecting a shortcut.
This commit is contained in:
parent
cf2a7542c9
commit
4af86da1e1
6 changed files with 31 additions and 14 deletions
|
|
@ -951,7 +951,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun setupSearch() {
|
private fun setupSearch() {
|
||||||
binding.appView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
binding.appView.addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||||
|
|
||||||
if (bottom - top > oldBottom - oldTop) {
|
if (bottom - top > oldBottom - oldTop) {
|
||||||
|
|
@ -1173,6 +1173,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
|
||||||
|
|
||||||
// Swipe left
|
// Swipe left
|
||||||
else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){
|
else if (deltaX < 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("left")){
|
||||||
|
println(leftSwipeActivity)
|
||||||
if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
|
if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
|
||||||
canLaunchShortcut = false
|
canLaunchShortcut = false
|
||||||
launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null)
|
launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class GestureAppsFragment(private val direction: String) : Fragment(),
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
adapter = GestureAppsAdapter(
|
adapter = GestureAppsAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
appUtils.getInstalledApps().toMutableList(),
|
appUtils.getInstalledApps(true).toMutableList(),
|
||||||
this@GestureAppsFragment
|
this@GestureAppsFragment
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ class GestureAppsFragment(private val direction: String) : Fragment(),
|
||||||
|
|
||||||
val cleanQuery = stringUtils.cleanString(query)
|
val cleanQuery = stringUtils.cleanString(query)
|
||||||
val newFilteredApps = mutableListOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
val newFilteredApps = mutableListOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
||||||
val updatedApps = appUtils.getInstalledApps()
|
val updatedApps = appUtils.getInstalledApps(true)
|
||||||
|
|
||||||
getFilteredApps(cleanQuery, newFilteredApps, updatedApps)
|
getFilteredApps(cleanQuery, newFilteredApps, updatedApps)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,11 @@ class SharedPreferenceManager (private val context: Context) {
|
||||||
return preferences.getBoolean("lockShortcuts", false)
|
return preferences.getBoolean("lockShortcuts", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show hidden apps in shortcut selection
|
||||||
|
fun showHiddenShortcuts(): Boolean {
|
||||||
|
return preferences.getBoolean("showHiddenShortcuts", true)
|
||||||
|
}
|
||||||
|
|
||||||
fun setPinnedApp(componentName: String, profile: Int) {
|
fun setPinnedApp(componentName: String, profile: Int) {
|
||||||
val editor = preferences.edit()
|
val editor = preferences.edit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,16 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA
|
||||||
|
|
||||||
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
private val sharedPreferenceManager = SharedPreferenceManager(context)
|
||||||
|
|
||||||
suspend fun getInstalledApps(): List<Triple<LauncherActivityInfo, UserHandle, Int>> {
|
suspend fun getInstalledApps(showApps: Boolean = false): List<Triple<LauncherActivityInfo, UserHandle, Int>> {
|
||||||
val allApps = mutableListOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
val allApps = mutableListOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
||||||
var sortedApps = listOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
var sortedApps = listOf<Triple<LauncherActivityInfo, UserHandle, Int>>()
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
for (i in launcherApps.profiles.indices) { // Check apps on both, normal and work profiles
|
for (i in launcherApps.profiles.indices) { // Check apps on both, normal and work profiles
|
||||||
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
launcherApps.getActivityList(null, launcherApps.profiles[i]).forEach { app ->
|
||||||
if (!sharedPreferenceManager.isAppHidden( // Only include the app if it isn't set as hidden
|
if ((!sharedPreferenceManager.isAppHidden( // Only include the app if it isn't set as hidden or in shortcut selection with the appropriate option enabled
|
||||||
app.componentName.flattenToString(),
|
app.componentName.flattenToString(),
|
||||||
i
|
i
|
||||||
) && app.applicationInfo.packageName != context.applicationInfo.packageName // Hide the launcher itself
|
) or showApps)&& app.applicationInfo.packageName != context.applicationInfo.packageName // Hide the launcher itself
|
||||||
) {
|
) {
|
||||||
allApps.add(Triple(app, launcherApps.profiles[i], i)) // The i variable gets used to determine whether an app is in the personal profile or work profile
|
allApps.add(Triple(app, launcherApps.profiles[i], i)) // The i variable gets used to determine whether an app is in the personal profile or work profile
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package eu.ottop.yamlauncher.utils
|
||||||
import android.accessibilityservice.AccessibilityService
|
import android.accessibilityservice.AccessibilityService
|
||||||
import android.accessibilityservice.AccessibilityServiceInfo
|
import android.accessibilityservice.AccessibilityServiceInfo
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.LauncherActivityInfo
|
import android.content.pm.LauncherActivityInfo
|
||||||
|
|
@ -20,16 +21,20 @@ class GestureUtils(private val context: Context) {
|
||||||
|
|
||||||
fun getSwipeInfo(launcherApps: LauncherApps, direction: String): Pair<LauncherActivityInfo?, Int?> {
|
fun getSwipeInfo(launcherApps: LauncherApps, direction: String): Pair<LauncherActivityInfo?, Int?> {
|
||||||
val app = sharedPreferenceManager.getGestureInfo(direction)
|
val app = sharedPreferenceManager.getGestureInfo(direction)
|
||||||
|
println(app)
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
if (app.size >= 3)
|
if (app.size >= 3) {
|
||||||
|
val componentName = ComponentName.unflattenFromString(app[1])
|
||||||
|
if (componentName != null) {
|
||||||
return Pair(
|
return Pair(
|
||||||
launcherApps.getActivityList(
|
launcherApps.resolveActivity(
|
||||||
app[1], launcherApps.profiles[app[2]
|
Intent().setComponent(componentName), launcherApps.profiles[app[2]
|
||||||
.toInt()]
|
.toInt()]
|
||||||
).firstOrNull(), app[2].toInt()
|
), app[2].toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Pair(null, null)
|
return Pair(null, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,12 @@
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:title="@string/lock_shortcuts"
|
android:title="@string/lock_shortcuts"
|
||||||
app:key="lockShortcuts" />
|
app:key="lockShortcuts" />
|
||||||
|
<SwitchPreference
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:title="@string/lock_shortcuts"
|
||||||
|
app:key="showHiddenShortcuts" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue