mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-22 22:11:27 +01:00
implemented #67 - option to hide apps that are bound to gestures
This commit is contained in:
parent
c1dcc0fe4e
commit
acbcef5827
8 changed files with 48 additions and 15 deletions
|
@ -16,7 +16,7 @@ import de.jrpie.android.launcher.apps.DetailedAppInfo
|
|||
import de.jrpie.android.launcher.getIntent
|
||||
import de.jrpie.android.launcher.openAppSettings
|
||||
|
||||
class AppAction(private var appInfo: AppInfo) : Action {
|
||||
class AppAction(val appInfo: AppInfo) : Action {
|
||||
|
||||
override fun invoke(context: Context, rect: Rect?): Boolean {
|
||||
val packageName = appInfo.packageName.toString()
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.jrpie.android.launcher.actions
|
|||
|
||||
import android.content.Context
|
||||
import de.jrpie.android.launcher.R
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
||||
/**
|
||||
* @param id internal id to serialize the action. Used as a key in shared preferences.
|
||||
|
@ -32,14 +33,18 @@ enum class Gesture(
|
|||
R.string.settings_gesture_description_vol_down,
|
||||
R.array.default_volume_down, 0, 0
|
||||
),
|
||||
TIME("action.time",
|
||||
TIME(
|
||||
"action.time",
|
||||
R.string.settings_gesture_time,
|
||||
R.string.settings_gesture_description_time,
|
||||
R.array.default_time),
|
||||
DATE("action.date",
|
||||
R.array.default_time
|
||||
),
|
||||
DATE(
|
||||
"action.date",
|
||||
R.string.settings_gesture_date,
|
||||
R.string.settings_gesture_description_date,
|
||||
R.array.default_date),
|
||||
R.array.default_date
|
||||
),
|
||||
LONG_CLICK(
|
||||
"action.long_click",
|
||||
R.string.settings_gesture_long_click,
|
||||
|
@ -52,11 +57,13 @@ enum class Gesture(
|
|||
R.string.settings_gesture_description_double_click,
|
||||
R.array.default_double_click, 0, 0
|
||||
),
|
||||
SWIPE_UP("action.up",
|
||||
SWIPE_UP(
|
||||
"action.up",
|
||||
R.string.settings_gesture_up,
|
||||
R.string.settings_gesture_description_up,
|
||||
R.array.default_up,
|
||||
R.anim.bottom_up),
|
||||
R.anim.bottom_up
|
||||
),
|
||||
SWIPE_UP_LEFT_EDGE(
|
||||
"action.up_left",
|
||||
R.string.settings_gesture_up_left_edge,
|
||||
|
@ -170,6 +177,7 @@ enum class Gesture(
|
|||
fun getLabel(context: Context): String {
|
||||
return context.resources.getString(this.labelResource)
|
||||
}
|
||||
|
||||
fun getDescription(context: Context): String {
|
||||
return context.resources.getString(this.descriptionResource)
|
||||
}
|
||||
|
@ -242,6 +250,16 @@ enum class Gesture(
|
|||
}
|
||||
}
|
||||
|
||||
fun isEnabled(): Boolean {
|
||||
if (isEdgeVariant()) {
|
||||
return LauncherPreferences.enabled_gestures().edgeSwipe()
|
||||
}
|
||||
if (isDoubleVariant()) {
|
||||
return LauncherPreferences.enabled_gestures().doubleSwipe()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
operator fun invoke(context: Context) {
|
||||
val action = Action.forGesture(this)
|
||||
Action.launch(action, context, this.animationIn, this.animationOut)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package de.jrpie.android.launcher.apps
|
||||
|
||||
import de.jrpie.android.launcher.actions.Action
|
||||
import de.jrpie.android.launcher.actions.AppAction
|
||||
import de.jrpie.android.launcher.actions.Gesture
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
import java.util.Locale
|
||||
import kotlin.text.Regex.Companion.escapeReplacement
|
||||
|
@ -14,20 +17,29 @@ class AppFilter(
|
|||
|
||||
val hidden = LauncherPreferences.apps().hidden() ?: setOf()
|
||||
val favorites = LauncherPreferences.apps().favorites() ?: setOf()
|
||||
|
||||
apps = apps.filter { info ->
|
||||
favoritesVisibility.predicate(favorites, info)
|
||||
&& hiddenVisibility.predicate(hidden, info)
|
||||
}
|
||||
|
||||
if (LauncherPreferences.apps().hideBoundApps()) {
|
||||
val boundApps = Gesture.entries
|
||||
.filter(Gesture::isEnabled)
|
||||
.mapNotNull { g -> (Action.forGesture(g) as? AppAction)?.appInfo }
|
||||
.toSet()
|
||||
apps = apps.filterNot { info -> boundApps.contains(info.app) }
|
||||
}
|
||||
|
||||
// normalize text for search
|
||||
var allowedSpecialCharacters = search
|
||||
val allowedSpecialCharacters = search
|
||||
.lowercase(Locale.ROOT)
|
||||
.toCharArray()
|
||||
.distinct()
|
||||
.filter { c -> !c.isLetter() }
|
||||
.map { c -> escapeReplacement(c.toString()) }
|
||||
.fold("") { x, y -> x + y }
|
||||
var disallowedCharsRegex = "[^\\p{L}$allowedSpecialCharacters]".toRegex()
|
||||
val disallowedCharsRegex = "[^\\p{L}$allowedSpecialCharacters]".toRegex()
|
||||
|
||||
fun normalize(text: String): String {
|
||||
return text.lowercase(Locale.ROOT).replace(disallowedCharsRegex, "")
|
||||
|
|
|
@ -28,6 +28,7 @@ import eu.jonahbauer.android.preference.annotations.serializer.PreferenceSeriali
|
|||
@PreferenceGroup(name = "apps", prefix = "settings_apps_", suffix = "_key", value = {
|
||||
@Preference(name = "favorites", type = Set.class, serializer = LauncherPreferences$Config.AppInfoSetSerializer.class),
|
||||
@Preference(name = "hidden", type = Set.class, serializer = LauncherPreferences$Config.AppInfoSetSerializer.class),
|
||||
@Preference(name = "hide_bound_apps", type = boolean.class, defaultValue = "false"),
|
||||
}),
|
||||
@PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = {
|
||||
}),
|
||||
|
|
|
@ -155,12 +155,7 @@ class ActionsRecyclerAdapter(val activity: Activity) :
|
|||
}
|
||||
|
||||
init {
|
||||
val doubleActions = LauncherPreferences.enabled_gestures().doubleSwipe()
|
||||
val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe()
|
||||
gesturesList = Gesture.entries.filter {
|
||||
(doubleActions || !it.isDoubleVariant())
|
||||
&& (edgeActions || !it.isEdgeVariant())
|
||||
} as ArrayList<Gesture>
|
||||
gesturesList = Gesture.entries.filter(Gesture::isEnabled) as ArrayList<Gesture>
|
||||
}
|
||||
|
||||
fun updateActions() {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<string name="settings_internal_version_code_key" translatable="false">internal.version_code</string>
|
||||
<string name="settings_apps_favorites_key" translatable="false">apps.favorites</string>
|
||||
<string name="settings_apps_hidden_key" translatable="false">apps.hidden</string>
|
||||
<string name="settings_apps_hide_bound_apps_key" translatable="false">apps.hide_bound_apps</string>
|
||||
|
||||
<string name="settings_general_choose_home_screen_key" translatable="false">general.select_launcher</string>
|
||||
<!--
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
|
||||
<string name="settings_launcher_section_apps">Apps</string>
|
||||
<string name="settings_apps_hidden">Hidden apps</string>
|
||||
<string name="settings_apps_hide_bound_apps">Don\'t show apps that are bound to a gesture in the app list</string>
|
||||
|
||||
<!--
|
||||
-
|
||||
|
|
|
@ -124,6 +124,11 @@
|
|||
android:title="@string/settings_apps_hidden"
|
||||
/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="@string/settings_apps_hide_bound_apps_key"
|
||||
android:title="@string/settings_apps_hide_bound_apps"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/settings_launcher_section_display"
|
||||
|
|
Loading…
Add table
Reference in a new issue