enh : add option hide assigned apps in folder

This commit is contained in:
MrSluffy
2025-01-23 08:27:06 +08:00
parent 04a8c05426
commit 792d7ed29a
4 changed files with 25 additions and 3 deletions

View File

@@ -104,6 +104,9 @@
<string name="delete_label">Delete</string>
<string name="folder_list_note">Swipe left to edit, swipe right to delete, or tap to update items</string>
<string name="apps_in_folder_label">Hide folder apps</string>
<string name="apps_in_folder_description">Apps assigned to folders are excluded from app lists</string>
<!-- A11y description -->
<string name="accessibility_service_description">To lock your phone when performing a gesture, and to open Recents via gesture, Lawnchair requires accessibility access.\n\nLawnchair doesn\'t watch any user action, though the privilege to do so is required for all accessibility services. Lawnchair discards any event sent by the system.\n\nIn order to lock your phone, or to open Recents, Lawnchair uses the performGlobalAction Accessibility service.</string>

View File

@@ -41,6 +41,7 @@ class LawnchairAlphabeticalAppsList<T>(
private var viewModel: FolderViewModel
private var folderList = mutableListOf<FolderInfo>()
private val filteredList = mutableListOf<AppInfo>()
init {
context.launcher.deviceProfile.inv.addOnChangeListener(this)
@@ -77,8 +78,8 @@ class LawnchairAlphabeticalAppsList<T>(
override fun addAppsWithSections(appList: List<AppInfo?>?, startPosition: Int): Int {
if (appList.isNullOrEmpty()) return startPosition
val drawerListDefault = prefs.drawerList.get()
filteredList.clear()
var position = startPosition
val filteredList = mutableListOf<AppInfo>()
if (!drawerListDefault) {
val categorizedApps = categorizeApps(context, appList)
@@ -103,13 +104,13 @@ class LawnchairAlphabeticalAppsList<T>(
folder.contents.forEach { app ->
(appsStore.getApp(app.componentKey) as? AppInfo)?.let {
folderInfo.add(it)
filteredList.add(it)
if (prefs.folderApps.get()) filteredList.add(it)
}
}
}
position++
}
val remainingApps = appList.filterNot { app -> filteredList.contains(app) }
val remainingApps = appList.filterNot { app -> filteredList.contains(app) && prefs.folderApps.get() }
position = super.addAppsWithSections(remainingApps, position)
}

View File

@@ -116,6 +116,7 @@ class PreferenceManager private constructor(private val context: Context) :
val wallpaperBlurFactorThreshold = FloatPref("pref_wallpaperBlurFactor", 3.0F, recreate)
val drawerList = BoolPref("pref_drawerList", true, recreate)
val folderApps = BoolPref("pref_hideFolderApps", true, reloadGrid)
val recentsActionScreenshot = BoolPref("pref_recentsActionScreenshot", !isOnePlusStock)
val recentsActionShare = BoolPref("pref_recentsActionShare", isOnePlusStock)

View File

@@ -17,6 +17,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import app.lawnchair.LawnchairLauncher
@@ -24,14 +25,19 @@ import app.lawnchair.data.factory.ViewModelFactory
import app.lawnchair.data.folder.model.FolderViewModel
import app.lawnchair.launcher
import app.lawnchair.launcherNullable
import app.lawnchair.preferences.getAdapter
import app.lawnchair.preferences.preferenceManager
import app.lawnchair.preferences2.ReloadHelper
import app.lawnchair.ui.preferences.LocalIsExpandedScreen
import app.lawnchair.ui.preferences.components.AppItem
import app.lawnchair.ui.preferences.components.AppItemPlaceholder
import app.lawnchair.ui.preferences.components.controls.SwitchPreference
import app.lawnchair.ui.preferences.components.layout.ExpandAndShrink
import app.lawnchair.ui.preferences.components.layout.PreferenceLazyColumn
import app.lawnchair.ui.preferences.components.layout.PreferenceScaffold
import app.lawnchair.ui.preferences.components.layout.preferenceGroupItems
import app.lawnchair.util.sortedBySelection
import com.android.launcher3.R
import com.android.launcher3.model.data.AppInfo
import com.android.launcher3.model.data.ItemInfo
@@ -44,6 +50,7 @@ fun AppListToFolderPreferences(
if (folderInfoId == null) return
val context = LocalContext.current
val prefs = preferenceManager()
val launcher = context.launcherNullable ?: LawnchairLauncher.instance?.launcher
if (launcher == null) return
@@ -115,6 +122,16 @@ fun AppListToFolderPreferences(
reloadHelper.reloadGrid()
}
item {
ExpandAndShrink(visible = selectedAppsState.value.isNotEmpty()) {
SwitchPreference(
adapter = prefs.folderApps.getAdapter(),
label = stringResource(id = R.string.apps_in_folder_label),
description = stringResource(id = R.string.apps_in_folder_description),
)
}
}
preferenceGroupItems(apps, isFirstChild = true, dividerStartIndent = 40.dp) { _, app ->
key(app.toString()) {
AppItem(app, onClick = { updateFolderApp(app) }) {