diff --git a/lawnchair/res/values/config.xml b/lawnchair/res/values/config.xml index 92871b975c..5f0770db50 100644 --- a/lawnchair/res/values/config.xml +++ b/lawnchair/res/values/config.xml @@ -44,6 +44,7 @@ false true + false false false true diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml index 6188a90396..98e9025842 100644 --- a/lawnchair/res/values/strings.xml +++ b/lawnchair/res/values/strings.xml @@ -225,6 +225,7 @@ Open search provider’s website even if their app is installed. Search Provider Status Bar + Show Notification Count Couldn’t load more icons. Reset Custom Icons All custom icons will be reset. Do you want to continue? diff --git a/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt b/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt index 62787dc663..abacf9d0fa 100644 --- a/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt +++ b/lawnchair/src/app/lawnchair/preferences2/PreferenceManager2.kt @@ -78,6 +78,12 @@ class PreferenceManager2(private val context: Context) : PreferenceManager { save = { it.toString() }, ) + val showNotificationCount = preference( + key = booleanPreferencesKey(name = "show_notification_count"), + defaultValue = context.resources.getBoolean(R.bool.config_default_show_notification_count), + onSet = { reloadHelper.reloadGrid() }, + ) + val themedHotseatQsb = preference( key = booleanPreferencesKey(name = "themed_hotseat_qsb"), defaultValue = context.resources.getBoolean(R.bool.config_default_themed_hotseat_qsb), diff --git a/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt index 9782387cba..3c93b806fe 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/GeneralPreferences.kt @@ -21,6 +21,8 @@ import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.navigation.NavGraphBuilder import app.lawnchair.preferences.getAdapter @@ -52,7 +54,6 @@ fun GeneralPreferences() { label = stringResource(id = R.string.home_screen_rotation_label), description = stringResource(id = R.string.home_screen_rotaton_description), ) - NotificationDotsPreference() NavigationActionPreference( label = stringResource(id = R.string.icon_pack), destination = subRoute(name = GeneralRoutes.ICON_PACK), @@ -67,6 +68,18 @@ fun GeneralPreferences() { ) } } + PreferenceGroup(heading = stringResource(id = R.string.notification_dots)) { + val context = LocalContext.current + val enabled by remember { notificationDotsEnabled(context) }.collectAsState(initial = false) + val serviceEnabled = notificationServiceEnabled() + NotificationDotsPreference(enabled = enabled, serviceEnabled = serviceEnabled) + if (enabled && serviceEnabled) { + SwitchPreference( + adapter = prefs2.showNotificationCount.getAdapter(), + label = stringResource(id = R.string.show_notification_count), + ) + } + } PreferenceGroup(heading = stringResource(id = R.string.colors)) { ThemePreference() AccentColorPreference() diff --git a/lawnchair/src/app/lawnchair/ui/preferences/components/NotificationDotsPreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/components/NotificationDotsPreference.kt index f84790a155..6d5bd3ef2f 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/components/NotificationDotsPreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/components/NotificationDotsPreference.kt @@ -48,11 +48,9 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow @Composable -fun NotificationDotsPreference() { +fun NotificationDotsPreference(enabled: Boolean, serviceEnabled: Boolean) { val bottomSheetHandler = bottomSheetHandler val context = LocalContext.current - val enabled by remember { notificationDotsEnabled(context) }.collectAsState(initial = false) - val serviceEnabled = notificationServiceEnabled() val showWarning = enabled && !serviceEnabled val summary = when { showWarning -> R.string.missing_notification_access_description diff --git a/platform_frameworks_libs_systemui b/platform_frameworks_libs_systemui index c4c25f5e56..1498fe9989 160000 --- a/platform_frameworks_libs_systemui +++ b/platform_frameworks_libs_systemui @@ -1 +1 @@ -Subproject commit c4c25f5e561256a34a1cc39ab7c00c9d4e4c2861 +Subproject commit 1498fe9989a59fcd6934439eb62cd12d1541aed4 diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 1995dbb319..689d40ff94 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -571,7 +571,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, final int scrollX = getScrollX(); final int scrollY = getScrollY(); canvas.translate(scrollX, scrollY); - mDotRenderer.draw(canvas, mDotParams); + mDotRenderer.draw(canvas, mDotParams, mDotInfo == null ? -1 : mDotInfo.getNotificationCount()); canvas.translate(-scrollX, -scrollY); } } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 32fe5c61f1..807fc7a0f8 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -31,8 +31,10 @@ import android.graphics.Path; import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; +import android.graphics.Typeface; import android.util.DisplayMetrics; import android.view.Surface; +import androidx.core.content.res.ResourcesCompat; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.DevicePaddings.DevicePadding; @@ -487,11 +489,20 @@ public class DeviceProfile { flingToDeleteThresholdVelocity = res.getDimensionPixelSize( R.dimen.drag_flingToDeleteMinVelocity); + // Check if notification dots should show the notification count + boolean showNotificationCount = PreferenceExtensionsKt.firstBlocking(preferenceManager2.getShowNotificationCount()); + + // Load the default font to use on notification dots + Typeface typeface = null; + if (showNotificationCount) { + typeface = ResourcesCompat.getFont(context, R.font.inter_regular); + } + // This is done last, after iconSizePx is calculated above. Path dotPath = GraphicsUtils.getShapePath(DEFAULT_DOT_SIZE); - mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE); + mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE, showNotificationCount, typeface); mDotRendererAllApps = iconSizePx == allAppsIconSizePx ? mDotRendererWorkSpace : - new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE); + new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE, showNotificationCount, typeface); } private int getHorizontalMarginPx(InvariantDeviceProfile idp, Resources res) { diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 86f4b90b81..e2708773dd 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -640,7 +640,7 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel // If we are animating to the accepting state, animate the dot out. mDotParams.scale = Math.max(0, mDotScale - mBackground.getScaleProgress()); mDotParams.color = mBackground.getDotColor(); - mDotRenderer.draw(canvas, mDotParams); + mDotRenderer.draw(canvas, mDotParams, mDotInfo == null ? -1 : mDotInfo.getNotificationCount()); } }