Rename "badges" to "dots" where appropriate

This will reduce confusion with the other "badging" concept we use for,
e.g. work profiles. It is also consistent with the external name
"notification dots".

Change-Id: I2a2c9d96dc0d6284eb0c48adc78a856271caad4d
This commit is contained in:
Tony Wickham committed 2018-12-04 10:46:40 -08:00
1 parent de78d7ca78
commit f34bee819c
111 files changed
+685 -687

No files matched your search

@@ -21,7 +21,6 @@ import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.StrictMode;
@@ -32,13 +31,10 @@ import android.view.View;
import android.widget.Toast;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.uioverrides.DisplayRotationListener;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.views.ActivityContext;
/**
* Extension of BaseActivity allowing support for drag-n-drop
+47 -47
View File
@@ -42,7 +42,7 @@ import android.view.ViewDebug;
import android.widget.TextView;
import com.android.launcher3.Launcher.OnResumeCallback;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.graphics.DrawableFactory;
import com.android.launcher3.graphics.IconPalette;
@@ -69,8 +69,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
private static final int[] STATE_PRESSED = new int[] {android.R.attr.state_pressed};
private static final Property<BubbleTextView, Float> BADGE_SCALE_PROPERTY
= new Property<BubbleTextView, Float>(Float.TYPE, "badgeScale") {
private static final Property<BubbleTextView, Float> DOT_SCALE_PROPERTY
= new Property<BubbleTextView, Float>(Float.TYPE, "dotScale") {
@Override
public Float get(BubbleTextView bubbleTextView) {
return bubbleTextView.mDotParams.scale;
@@ -115,12 +115,12 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
private float mTextAlpha = 1;
@ViewDebug.ExportedProperty(category = "launcher")
private BadgeInfo mBadgeInfo;
private DotInfo mDotInfo;
private DotRenderer mDotRenderer;
@ViewDebug.ExportedProperty(category = "launcher", deepExport = true)
private DotRenderer.DrawParams mDotParams;
private Animator mBadgeScaleAnim;
private boolean mForceHideBadge;
private Animator mDotScaleAnim;
private boolean mForceHideDot;
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mStayPressed;
@@ -190,29 +190,29 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
* Resets the view so it can be recycled.
*/
public void reset() {
mBadgeInfo = null;
mDotInfo = null;
mDotParams.color = Color.TRANSPARENT;
cancelBadgeScaleAnim();
cancelDotScaleAnim();
mDotParams.scale = 0f;
mForceHideBadge = false;
mForceHideDot = false;
}
private void cancelBadgeScaleAnim() {
if (mBadgeScaleAnim != null) {
mBadgeScaleAnim.cancel();
private void cancelDotScaleAnim() {
if (mDotScaleAnim != null) {
mDotScaleAnim.cancel();
}
}
private void animateBadgeScale(float... badgeScales) {
cancelBadgeScaleAnim();
mBadgeScaleAnim = ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, badgeScales);
mBadgeScaleAnim.addListener(new AnimatorListenerAdapter() {
private void animateDotScale(float... dotScales) {
cancelDotScaleAnim();
mDotScaleAnim = ObjectAnimator.ofFloat(this, DOT_SCALE_PROPERTY, dotScales);
mDotScaleAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mBadgeScaleAnim = null;
mDotScaleAnim = null;
}
});
mBadgeScaleAnim.start();
mDotScaleAnim.start();
}
public void applyFromShortcutInfo(ShortcutInfo info) {
@@ -226,7 +226,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
applyPromiseState(promiseStateChanged);
}
applyBadgeState(info, false /* animate */);
applyDotState(info, false /* animate */);
}
public void applyFromApplicationInfo(AppInfo info) {
@@ -242,7 +242,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info;
applyProgressLevel(promiseAppInfo.level);
}
applyBadgeState(info, false /* animate */);
applyDotState(info, false /* animate */);
}
public void applyFromPackageItemInfo(PackageItemInfo info) {
@@ -366,22 +366,22 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
}
@SuppressWarnings("wrongcall")
protected void drawWithoutBadge(Canvas canvas) {
protected void drawWithoutDot(Canvas canvas) {
super.onDraw(canvas);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
drawBadgeIfNecessary(canvas);
drawDotIfNecessary(canvas);
}
/**
* Draws the icon badge in the top right corner of the icon bounds.
* Draws the notification dot in the top right corner of the icon bounds.
* @param canvas The canvas to draw to.
*/
protected void drawBadgeIfNecessary(Canvas canvas) {
if (!mForceHideBadge && (hasBadge() || mDotParams.scale > 0)) {
protected void drawDotIfNecessary(Canvas canvas) {
if (!mForceHideDot && (hasDot() || mDotParams.scale > 0)) {
getIconBounds(mDotParams.iconBounds);
mDotParams.spaceForOffset.set((getWidth() - mIconSize) / 2, getPaddingTop());
final int scrollX = getScrollX();
@@ -392,21 +392,21 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
}
}
public void forceHideBadge(boolean forceHideBadge) {
if (mForceHideBadge == forceHideBadge) {
public void forceHideDot(boolean forceHideDot) {
if (mForceHideDot == forceHideDot) {
return;
}
mForceHideBadge = forceHideBadge;
mForceHideDot = forceHideDot;
if (forceHideBadge) {
if (forceHideDot) {
invalidate();
} else if (hasBadge()) {
animateBadgeScale(0, 1);
} else if (hasDot()) {
animateDotScale(0, 1);
}
}
private boolean hasBadge() {
return mBadgeInfo != null;
private boolean hasDot() {
return mDotInfo != null;
}
public void getIconBounds(Rect outBounds) {
@@ -536,28 +536,28 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
return null;
}
public void applyBadgeState(ItemInfo itemInfo, boolean animate) {
public void applyDotState(ItemInfo itemInfo, boolean animate) {
if (mIcon instanceof FastBitmapDrawable) {
boolean wasBadged = mBadgeInfo != null;
mBadgeInfo = mActivity.getBadgeInfoForItem(itemInfo);
boolean isBadged = mBadgeInfo != null;
float newBadgeScale = isBadged ? 1f : 0;
boolean wasDotted = mDotInfo != null;
mDotInfo = mActivity.getDotInfoForItem(itemInfo);
boolean isDotted = mDotInfo != null;
float newDotScale = isDotted ? 1f : 0;
mDotRenderer = mActivity.getDeviceProfile().mDotRenderer;
if (wasBadged || isBadged) {
// Animate when a badge is first added or when it is removed.
if (animate && (wasBadged ^ isBadged) && isShown()) {
animateBadgeScale(newBadgeScale);
if (wasDotted || isDotted) {
// Animate when a dot is first added or when it is removed.
if (animate && (wasDotted ^ isDotted) && isShown()) {
animateDotScale(newDotScale);
} else {
cancelBadgeScaleAnim();
mDotParams.scale = newBadgeScale;
cancelDotScaleAnim();
mDotParams.scale = newDotScale;
invalidate();
}
}
if (itemInfo.contentDescription != null) {
if (hasBadge()) {
int count = mBadgeInfo.getNotificationCount();
if (hasDot()) {
int count = mDotInfo.getNotificationCount();
setContentDescription(getContext().getResources().getQuantityString(
R.plurals.badged_app_label, count, itemInfo.contentDescription, count));
R.plurals.dotted_app_label, count, itemInfo.contentDescription, count));
} else {
setContentDescription(itemInfo.contentDescription);
}
+1 -1
View File
@@ -128,7 +128,7 @@ public class DeviceProfile {
private final Rect mHotseatPadding = new Rect();
private boolean mIsSeascape;
// Icon badges
// Notification dots
public DotRenderer mDotRenderer;
public DeviceProfile(Context context, InvariantDeviceProfile inv,
+7 -7
View File
@@ -77,7 +77,7 @@ import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherAppsCompatVO;
import com.android.launcher3.config.FeatureFlags;
@@ -473,8 +473,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
@Override
public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
return mPopupDataProvider.getBadgeInfoForItem(info);
public DotInfo getDotInfoForItem(ItemInfo info) {
return mPopupDataProvider.getDotInfoForItem(info);
}
@Override
@@ -1105,13 +1105,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
}
};
public void updateIconBadges(final Set<PackageUserKey> updatedBadges) {
mWorkspace.updateIconBadges(updatedBadges);
mAppsView.getAppsStore().updateIconBadges(updatedBadges);
public void updateNotificationDots(final Set<PackageUserKey> updatedDots) {
mWorkspace.updateNotificationDots(updatedDots);
mAppsView.getAppsStore().updateNotificationDots(updatedDots);
PopupContainerWithArrow popup = PopupContainerWithArrow.getOpen(Launcher.this);
if (popup != null) {
popup.updateNotificationHeader(updatedBadges);
popup.updateNotificationHeader(updatedDots);
}
}
+11 -11
View File
@@ -50,7 +50,7 @@ public class LauncherAppState {
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
private final InvariantDeviceProfile mInvariantDeviceProfile;
private final SecureSettingsObserver mNotificationBadgingObserver;
private final SecureSettingsObserver mNotificationDotsObserver;
public static LauncherAppState getInstance(final Context context) {
return INSTANCE.get(context);
@@ -98,19 +98,19 @@ public class LauncherAppState {
UserManagerCompat.getInstance(mContext).enableAndResetCache();
mInvariantDeviceProfile.addOnChangeListener(this::onIdpChanged);
if (!mContext.getResources().getBoolean(R.bool.notification_badging_enabled)) {
mNotificationBadgingObserver = null;
if (!mContext.getResources().getBoolean(R.bool.notification_dots_enabled)) {
mNotificationDotsObserver = null;
} else {
// Register an observer to rebind the notification listener when badging is re-enabled.
mNotificationBadgingObserver =
// Register an observer to rebind the notification listener when dots are re-enabled.
mNotificationDotsObserver =
newNotificationSettingsObserver(mContext, this::onNotificationSettingsChanged);
mNotificationBadgingObserver.register();
mNotificationBadgingObserver.dispatchOnChange();
mNotificationDotsObserver.register();
mNotificationDotsObserver.dispatchOnChange();
}
}
protected void onNotificationSettingsChanged(boolean isNotificationBadgingEnabled) {
if (isNotificationBadgingEnabled) {
protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
if (areNotificationDotsEnabled) {
NotificationListener.requestRebind(new ComponentName(
mContext, NotificationListener.class));
}
@@ -137,8 +137,8 @@ public class LauncherAppState {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(mContext);
launcherApps.removeOnAppsChangedCallback(mModel);
PackageInstallerCompat.getInstance(mContext).onStop();
if (mNotificationBadgingObserver != null) {
mNotificationBadgingObserver.unregister();
if (mNotificationDotsObserver != null) {
mNotificationDotsObserver.unregister();
}
}
+7 -7
View File
@@ -63,7 +63,7 @@ import com.android.launcher3.accessibility.AccessibleDragListenerAdapter;
import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper;
import com.android.launcher3.anim.AnimatorSetBuilder;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.badge.FolderBadgeInfo;
import com.android.launcher3.dot.FolderDotInfo;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragController;
@@ -3168,7 +3168,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
});
}
public void updateIconBadges(final Set<PackageUserKey> updatedBadges) {
public void updateNotificationDots(final Set<PackageUserKey> updatedDots) {
final PackageUserKey packageUserKey = new PackageUserKey(null, null);
final IntSet folderIds = new IntSet();
mapOverItems(MAP_RECURSE, new ItemOperator() {
@@ -3176,8 +3176,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof ShortcutInfo && v instanceof BubbleTextView
&& packageUserKey.updateFromItemInfo(info)) {
if (updatedBadges.contains(packageUserKey)) {
((BubbleTextView) v).applyBadgeState(info, true /* animate */);
if (updatedDots.contains(packageUserKey)) {
((BubbleTextView) v).applyDotState(info, true /* animate */);
folderIds.add(info.container);
}
}
@@ -3192,11 +3192,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof FolderInfo && folderIds.contains(info.id)
&& v instanceof FolderIcon) {
FolderBadgeInfo folderBadgeInfo = new FolderBadgeInfo();
FolderDotInfo folderDotInfo = new FolderDotInfo();
for (ShortcutInfo si : ((FolderInfo) info).contents) {
folderBadgeInfo.addBadgeInfo(mLauncher.getBadgeInfoForItem(si));
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
}
((FolderIcon) v).setBadgeInfo(folderBadgeInfo);
((FolderIcon) v).setDotInfo(folderDotInfo);
}
// process all the shortcuts
return false;
@@ -121,12 +121,12 @@ public class AllAppsStore {
mIconContainers.remove(container);
}
public void updateIconBadges(Set<PackageUserKey> updatedBadges) {
public void updateNotificationDots(Set<PackageUserKey> updatedDots) {
updateAllIcons((child) -> {
if (child.getTag() instanceof ItemInfo) {
ItemInfo info = (ItemInfo) child.getTag();
if (mTempKey.updateFromItemInfo(info) && updatedBadges.contains(mTempKey)) {
child.applyBadgeState(info, true /* animate */);
if (mTempKey.updateFromItemInfo(info) && updatedDots.contains(mTempKey)) {
child.applyDotState(info, true /* animate */);
}
}
});
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.launcher3.badge;
package com.android.launcher3.dot;
import com.android.launcher3.notification.NotificationInfo;
import com.android.launcher3.notification.NotificationKeyData;
@@ -24,17 +24,17 @@ import java.util.ArrayList;
import java.util.List;
/**
* Contains data to be used in an icon badge.
* Contains data to be used for a notification dot.
*/
public class BadgeInfo {
public class DotInfo {
public static final int MAX_COUNT = 999;
/** Used to link this BadgeInfo to icons on the workspace and all apps */
/** Used to link this DotInfo to icons on the workspace and all apps */
private PackageUserKey mPackageUserKey;
/**
* The keys of the notifications that this badge represents. These keys can later be
* The keys of the notifications that this dot represents. These keys can later be
* used to retrieve {@link NotificationInfo}'s.
*/
private List<NotificationKeyData> mNotificationKeys;
@@ -45,7 +45,7 @@ public class BadgeInfo {
*/
private int mTotalCount;
public BadgeInfo(PackageUserKey packageUserKey) {
public DotInfo(PackageUserKey packageUserKey) {
mPackageUserKey = packageUserKey;
mNotificationKeys = new ArrayList<>();
}
@@ -94,15 +94,16 @@ public class BadgeInfo {
}
/**
* Whether newBadge represents the same PackageUserKey as this badge, and icons with
* TODO: this is outdated now that we only show dots instead of icons/numbers. can remove?
* Whether newDot represents the same PackageUserKey as this badge, and icons with
* this badge should be invalidated. So, for instance, if a badge has 3 notifications
* and one of those notifications is updated, this method should return false because
* the badge still says "3" and the contents of those notifications are only retrieved
* upon long-click. This method always returns true when adding or removing notifications,
* or if the badge has a notification icon to show.
*/
public boolean shouldBeInvalidated(BadgeInfo newBadge) {
return mPackageUserKey.equals(newBadge.mPackageUserKey)
&& (getNotificationCount() != newBadge.getNotificationCount());
public boolean shouldBeInvalidated(DotInfo newDot) {
return mPackageUserKey.equals(newDot.mPackageUserKey)
&& (getNotificationCount() != newDot.getNotificationCount());
}
}
@@ -14,52 +14,51 @@
* limitations under the License.
*/
package com.android.launcher3.badge;
package com.android.launcher3.dot;
import android.view.ViewDebug;
import com.android.launcher3.Utilities;
/**
* Subclass of BadgeInfo that only contains the badge count, which is
* Subclass of DotInfo that only contains the dot count, which is
* the sum of all the Folder's items' notifications (each counts as 1).
*/
public class FolderBadgeInfo extends BadgeInfo {
public class FolderDotInfo extends DotInfo {
private static final int MIN_COUNT = 0;
private int mNumNotifications;
public FolderBadgeInfo() {
public FolderDotInfo() {
super(null);
}
public void addBadgeInfo(BadgeInfo badgeToAdd) {
if (badgeToAdd == null) {
public void addDotInfo(DotInfo dotToAdd) {
if (dotToAdd == null) {
return;
}
mNumNotifications += badgeToAdd.getNotificationKeys().size();
mNumNotifications += dotToAdd.getNotificationKeys().size();
mNumNotifications = Utilities.boundToRange(
mNumNotifications, MIN_COUNT, BadgeInfo.MAX_COUNT);
mNumNotifications, MIN_COUNT, DotInfo.MAX_COUNT);
}
public void subtractBadgeInfo(BadgeInfo badgeToSubtract) {
if (badgeToSubtract == null) {
public void subtractDotInfo(DotInfo dotToSubtract) {
if (dotToSubtract == null) {
return;
}
mNumNotifications -= badgeToSubtract.getNotificationKeys().size();
mNumNotifications -= dotToSubtract.getNotificationKeys().size();
mNumNotifications = Utilities.boundToRange(
mNumNotifications, MIN_COUNT, BadgeInfo.MAX_COUNT);
mNumNotifications, MIN_COUNT, DotInfo.MAX_COUNT);
}
@Override
public int getNotificationCount() {
// This forces the folder badge to always show up as a dot.
return 0;
return mNumNotifications;
}
@ViewDebug.ExportedProperty(category = "launcher")
public boolean hasBadge() {
public boolean hasDot() {
return mNumNotifications > 0;
}
}
@@ -102,7 +102,7 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable {
c.setBitmap(badgeBitmap);
bg.drawShadow(c);
bg.drawBackgroundStroke(c);
icon.drawBadge(c);
icon.drawDot(c);
// Initialize preview
final float sizeScaleFactor = 1 + 2 * AdaptiveIconDrawable.getExtraInsetFraction();
+2 -2
View File
@@ -645,8 +645,8 @@ public class Folder extends AbstractFloatingView implements DragSource,
mFolderIcon.mBackground.fadeInBackgroundShadow();
mFolderIcon.mBackground.animateBackgroundStroke();
mFolderIcon.onFolderClose(mContent.getCurrentPage());
if (mFolderIcon.hasBadge()) {
mFolderIcon.animateBadgeScale(0f, 1f);
if (mFolderIcon.hasDot()) {
mFolderIcon.animateDotScale(0f, 1f);
}
mFolderIcon.requestFocus();
}
@@ -56,7 +56,7 @@ import com.android.launcher3.StylusEventHelper;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.badge.FolderBadgeInfo;
import com.android.launcher3.dot.FolderDotInfo;
import com.android.launcher3.dragndrop.BaseItemDragListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragView;
@@ -109,23 +109,23 @@ public class FolderIcon extends FrameLayout implements FolderListener {
private Alarm mOpenAlarm = new Alarm();
@ViewDebug.ExportedProperty(category = "launcher", deepExport = true)
private FolderBadgeInfo mBadgeInfo = new FolderBadgeInfo();
private FolderDotInfo mDotInfo = new FolderDotInfo();
private DotRenderer mDotRenderer;
@ViewDebug.ExportedProperty(category = "launcher", deepExport = true)
private DotRenderer.DrawParams mDotParams;
private float mBadgeScale;
private Animator mBadgeScaleAnim;
private float mDotScale;
private Animator mDotScaleAnim;
private static final Property<FolderIcon, Float> BADGE_SCALE_PROPERTY
= new Property<FolderIcon, Float>(Float.TYPE, "badgeScale") {
private static final Property<FolderIcon, Float> DOT_SCALE_PROPERTY
= new Property<FolderIcon, Float>(Float.TYPE, "dotScale") {
@Override
public Float get(FolderIcon folderIcon) {
return folderIcon.mBadgeScale;
return folderIcon.mDotScale;
}
@Override
public void set(FolderIcon folderIcon, Float value) {
folderIcon.mBadgeScale = value;
folderIcon.mDotScale = value;
folderIcon.invalidate();
}
};
@@ -382,9 +382,9 @@ public class FolderIcon extends FrameLayout implements FolderListener {
itemReturnedOnFailedDrop);
}
public void setBadgeInfo(FolderBadgeInfo badgeInfo) {
updateBadgeScale(mBadgeInfo.hasBadge(), badgeInfo.hasBadge());
mBadgeInfo = badgeInfo;
public void setDotInfo(FolderDotInfo dotInfo) {
updateDotScale(mDotInfo.hasDot(), dotInfo.hasDot());
mDotInfo = dotInfo;
}
public ClippedFolderIconLayoutRule getLayoutRule() {
@@ -392,41 +392,41 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
/**
* Sets mBadgeScale to 1 or 0, animating if wasBadged or isBadged is false
* (the badge is being added or removed).
* Sets mDotScale to 1 or 0, animating if wasDotted or isDotted is false
* (the dot is being added or removed).
*/
private void updateBadgeScale(boolean wasBadged, boolean isBadged) {
float newBadgeScale = isBadged ? 1f : 0f;
// Animate when a badge is first added or when it is removed.
if ((wasBadged ^ isBadged) && isShown()) {
animateBadgeScale(newBadgeScale);
private void updateDotScale(boolean wasDotted, boolean isDotted) {
float newDotScale = isDotted ? 1f : 0f;
// Animate when a dot is first added or when it is removed.
if ((wasDotted ^ isDotted) && isShown()) {
animateDotScale(newDotScale);
} else {
cancelBadgeScaleAnim();
mBadgeScale = newBadgeScale;
cancelDotScaleAnim();
mDotScale = newDotScale;
invalidate();
}
}
private void cancelBadgeScaleAnim() {
if (mBadgeScaleAnim != null) {
mBadgeScaleAnim.cancel();
private void cancelDotScaleAnim() {
if (mDotScaleAnim != null) {
mDotScaleAnim.cancel();
}
}
public void animateBadgeScale(float... badgeScales) {
cancelBadgeScaleAnim();
mBadgeScaleAnim = ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, badgeScales);
mBadgeScaleAnim.addListener(new AnimatorListenerAdapter() {
public void animateDotScale(float... dotScales) {
cancelDotScaleAnim();
mDotScaleAnim = ObjectAnimator.ofFloat(this, DOT_SCALE_PROPERTY, dotScales);
mDotScaleAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mBadgeScaleAnim = null;
mDotScaleAnim = null;
}
});
mBadgeScaleAnim.start();
mDotScaleAnim.start();
}
public boolean hasBadge() {
return mBadgeInfo != null && mBadgeInfo.hasBadge();
public boolean hasDot() {
return mDotInfo != null && mDotInfo.hasDot();
}
private float getLocalCenterForIndex(int index, int curNumItems, int[] center) {
@@ -487,18 +487,18 @@ public class FolderIcon extends FrameLayout implements FolderListener {
mBackground.drawBackgroundStroke(canvas);
}
drawBadge(canvas);
drawDot(canvas);
}
public void drawBadge(Canvas canvas) {
if ((mBadgeInfo != null && mBadgeInfo.hasBadge()) || mBadgeScale > 0) {
public void drawDot(Canvas canvas) {
if ((mDotInfo != null && mDotInfo.hasDot()) || mDotScale > 0) {
Rect iconBounds = mDotParams.iconBounds;
BubbleTextView.getIconBounds(this, iconBounds, mLauncher.getDeviceProfile().iconSizePx);
// If we are animating to the accepting state, animate the badge out.
mDotParams.scale = Math.max(0, mBadgeScale - mBackground.getScaleProgress());
// If we are animating to the accepting state, animate the dot out.
mDotParams.scale = Math.max(0, mDotScale - mBackground.getScaleProgress());
mDotParams.spaceForOffset.set(getWidth() - iconBounds.right, iconBounds.top);
mDotParams.color = mBackground.getBadgeColor();
mDotParams.color = mBackground.getDotColor();
mDotRenderer.draw(canvas, mDotParams);
}
}
@@ -567,20 +567,20 @@ public class FolderIcon extends FrameLayout implements FolderListener {
@Override
public void onAdd(ShortcutInfo item, int rank) {
boolean wasBadged = mBadgeInfo.hasBadge();
mBadgeInfo.addBadgeInfo(mLauncher.getBadgeInfoForItem(item));
boolean isBadged = mBadgeInfo.hasBadge();
updateBadgeScale(wasBadged, isBadged);
boolean wasDotted = mDotInfo.hasDot();
mDotInfo.addDotInfo(mLauncher.getDotInfoForItem(item));
boolean isDotted = mDotInfo.hasDot();
updateDotScale(wasDotted, isDotted);
invalidate();
requestLayout();
}
@Override
public void onRemove(ShortcutInfo item) {
boolean wasBadged = mBadgeInfo.hasBadge();
mBadgeInfo.subtractBadgeInfo(mLauncher.getBadgeInfoForItem(item));
boolean isBadged = mBadgeInfo.hasBadge();
updateBadgeScale(wasBadged, isBadged);
boolean wasDotted = mDotInfo.hasDot();
mDotInfo.subtractDotInfo(mLauncher.getDotInfoForItem(item));
boolean isDotted = mDotInfo.hasDot();
updateDotScale(wasDotted, isDotted);
invalidate();
requestLayout();
}
@@ -39,7 +39,6 @@ import android.view.View;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -64,7 +63,7 @@ public class PreviewBackground {
float mScale = 1f;
private float mColorMultiplier = 1f;
private int mBgColor;
private int mBadgeColor;
private int mDotColor;
private float mStrokeWidth;
private int mStrokeAlpha = MAX_BG_OPACITY;
private int mShadowAlpha = 255;
@@ -127,7 +126,7 @@ public class PreviewBackground {
int availableSpaceX, int topPadding) {
mInvalidateDelegate = invalidateDelegate;
mBgColor = Themes.getAttrColor(context, android.R.attr.colorPrimary);
mBadgeColor = Themes.getAttrColor(context, R.attr.folderBadgeColor);
mDotColor = Themes.getAttrColor(context, R.attr.folderDotColor);
DeviceProfile grid = activity.getDeviceProfile();
previewSize = grid.folderIconSizePx;
@@ -193,8 +192,8 @@ public class PreviewBackground {
return setColorAlphaBound(mBgColor, alpha);
}
public int getBadgeColor() {
return mBadgeColor;
public int getDotColor() {
return mDotColor;
}
public void drawBackground(Canvas canvas) {
@@ -30,13 +30,14 @@ import android.view.View;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.util.PackageUserKey;
/**
* An object that contains relevant information from a {@link StatusBarNotification}. This should
* only be created when we need to show the notification contents on the UI; until then, a
* {@link com.android.launcher3.badge.BadgeInfo} with only the notification key should
* {@link DotInfo} with only the notification key should
* be passed around, and then this can be constructed using the StatusBarNotification from
* {@link NotificationListener#getNotificationsForKeys(java.util.List)}.
*/
@@ -26,7 +26,7 @@ import androidx.annotation.NonNull;
/**
* The key data associated with the notification, used to determine what to include
* in badges and dummy popup views before they are populated.
* in dots and dummy popup views before they are populated.
*
* @see NotificationInfo for the full data used when populating the dummy views.
*/
@@ -77,7 +77,7 @@ public class NotificationListener extends NotificationListenerService {
/** The last notification key that was dismissed from launcher UI */
private String mLastKeyDismissedByLauncher;
private SecureSettingsObserver mNotificationBadgingObserver;
private SecureSettingsObserver mNotificationDotsObserver;
private final Handler.Callback mWorkerCallback = new Handler.Callback() {
@Override
@@ -169,7 +169,7 @@ public class NotificationListener extends NotificationListenerService {
if (notificationListener != null) {
notificationListener.onNotificationFullRefresh();
} else if (!sIsCreated && sNotificationsChangedListener != null) {
// User turned off badging globally, so we unbound this service;
// User turned off dots globally, so we unbound this service;
// tell the listener that there are no notifications to remove dots.
sNotificationsChangedListener.onNotificationFullRefresh(
Collections.<StatusBarNotification>emptyList());
@@ -194,16 +194,16 @@ public class NotificationListener extends NotificationListenerService {
super.onListenerConnected();
sIsConnected = true;
mNotificationBadgingObserver =
newNotificationSettingsObserver(this, this::onNotificationBadgingChanged);
mNotificationBadgingObserver.register();
mNotificationBadgingObserver.dispatchOnChange();
mNotificationDotsObserver =
newNotificationSettingsObserver(this, this::onNotificationSettingsChanged);
mNotificationDotsObserver.register();
mNotificationDotsObserver.dispatchOnChange();
onNotificationFullRefresh();
}
private void onNotificationBadgingChanged(boolean isNotificationBadgingEnabled) {
if (!isNotificationBadgingEnabled && sIsConnected) {
private void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) {
if (!areNotificationDotsEnabled && sIsConnected) {
requestUnbind();
}
}
@@ -216,7 +216,7 @@ public class NotificationListener extends NotificationListenerService {
public void onListenerDisconnected() {
super.onListenerDisconnected();
sIsConnected = false;
mNotificationBadgingObserver.unregister();
mNotificationDotsObserver.unregister();
}
@Override
@@ -53,7 +53,7 @@ import com.android.launcher3.LauncherModel;
import com.android.launcher3.R;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.dragndrop.DragView;
@@ -279,7 +279,7 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
}
mLauncher.getDragController().addDragListener(this);
mOriginalIcon.forceHideBadge(true);
mOriginalIcon.forceHideDot(true);
// All views are added. Animate layout from now on.
setLayoutTransition(new LayoutTransition());
@@ -462,32 +462,32 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
}
/**
* Updates the notification header if the original icon's badge updated.
* Updates the notification header if the original icon's dot updated.
*/
public void updateNotificationHeader(Set<PackageUserKey> updatedBadges) {
public void updateNotificationHeader(Set<PackageUserKey> updatedDots) {
ItemInfo itemInfo = (ItemInfo) mOriginalIcon.getTag();
PackageUserKey packageUser = PackageUserKey.fromItemInfo(itemInfo);
if (updatedBadges.contains(packageUser)) {
if (updatedDots.contains(packageUser)) {
updateNotificationHeader();
}
}
private void updateNotificationHeader() {
ItemInfoWithIcon itemInfo = (ItemInfoWithIcon) mOriginalIcon.getTag();
BadgeInfo badgeInfo = mLauncher.getBadgeInfoForItem(itemInfo);
if (mNotificationItemView != null && badgeInfo != null) {
DotInfo dotInfo = mLauncher.getDotInfoForItem(itemInfo);
if (mNotificationItemView != null && dotInfo != null) {
mNotificationItemView.updateHeader(
badgeInfo.getNotificationCount(), itemInfo.iconColor);
dotInfo.getNotificationCount(), itemInfo.iconColor);
}
}
public void trimNotifications(Map<PackageUserKey, BadgeInfo> updatedBadges) {
public void trimNotifications(Map<PackageUserKey, DotInfo> updatedDots) {
if (mNotificationItemView == null) {
return;
}
ItemInfo originalInfo = (ItemInfo) mOriginalIcon.getTag();
BadgeInfo badgeInfo = updatedBadges.get(PackageUserKey.fromItemInfo(originalInfo));
if (badgeInfo == null || badgeInfo.getNotificationKeys().size() == 0) {
DotInfo dotInfo = updatedDots.get(PackageUserKey.fromItemInfo(originalInfo));
if (dotInfo == null || dotInfo.getNotificationKeys().size() == 0) {
// No more notifications, remove the notification views and expand all shortcuts.
mNotificationItemView.removeAllViews();
mNotificationItemView = null;
@@ -495,7 +495,7 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
updateDividers();
} else {
mNotificationItemView.trimNotifications(
NotificationKeyData.extractKeysOnly(badgeInfo.getNotificationKeys()));
NotificationKeyData.extractKeysOnly(dotInfo.getNotificationKeys()));
}
}
@@ -540,14 +540,14 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
protected void onCreateCloseAnimation(AnimatorSet anim) {
// Animate original icon's text back in.
anim.play(mOriginalIcon.createTextAlphaAnimator(true /* fadeIn */));
mOriginalIcon.forceHideBadge(false);
mOriginalIcon.forceHideDot(false);
}
@Override
protected void closeComplete() {
super.closeComplete();
mOriginalIcon.setTextVisibility(mOriginalIcon.shouldTextBeVisible());
mOriginalIcon.forceHideBadge(false);
mOriginalIcon.forceHideDot(false);
}
@Override
@@ -23,7 +23,7 @@ import android.util.Log;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.Utilities;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dot.DotInfo;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.notification.NotificationKeyData;
import com.android.launcher3.notification.NotificationListener;
@@ -53,8 +53,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
/** Maps launcher activity components to a count of how many shortcuts they have. */
private HashMap<ComponentKey, Integer> mDeepShortcutMap = new HashMap<>();
/** Maps packages to their BadgeInfo's . */
private Map<PackageUserKey, BadgeInfo> mPackageUserToBadgeInfos = new HashMap<>();
/** Maps packages to their DotInfo's . */
private Map<PackageUserKey, DotInfo> mPackageUserToDotInfos = new HashMap<>();
/** Maps packages to their Widgets */
private ArrayList<WidgetListRowEntry> mAllWidgets = new ArrayList<>();
@@ -65,83 +65,83 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
@Override
public void onNotificationPosted(PackageUserKey postedPackageUserKey,
NotificationKeyData notificationKey, boolean shouldBeFilteredOut) {
BadgeInfo badgeInfo = mPackageUserToBadgeInfos.get(postedPackageUserKey);
boolean badgeShouldBeRefreshed;
if (badgeInfo == null) {
DotInfo dotInfo = mPackageUserToDotInfos.get(postedPackageUserKey);
boolean dotShouldBeRefreshed;
if (dotInfo == null) {
if (!shouldBeFilteredOut) {
BadgeInfo newBadgeInfo = new BadgeInfo(postedPackageUserKey);
newBadgeInfo.addOrUpdateNotificationKey(notificationKey);
mPackageUserToBadgeInfos.put(postedPackageUserKey, newBadgeInfo);
badgeShouldBeRefreshed = true;
DotInfo newDotInfo = new DotInfo(postedPackageUserKey);
newDotInfo.addOrUpdateNotificationKey(notificationKey);
mPackageUserToDotInfos.put(postedPackageUserKey, newDotInfo);
dotShouldBeRefreshed = true;
} else {
badgeShouldBeRefreshed = false;
dotShouldBeRefreshed = false;
}
} else {
badgeShouldBeRefreshed = shouldBeFilteredOut
? badgeInfo.removeNotificationKey(notificationKey)
: badgeInfo.addOrUpdateNotificationKey(notificationKey);
if (badgeInfo.getNotificationKeys().size() == 0) {
mPackageUserToBadgeInfos.remove(postedPackageUserKey);
dotShouldBeRefreshed = shouldBeFilteredOut
? dotInfo.removeNotificationKey(notificationKey)
: dotInfo.addOrUpdateNotificationKey(notificationKey);
if (dotInfo.getNotificationKeys().size() == 0) {
mPackageUserToDotInfos.remove(postedPackageUserKey);
}
}
if (badgeShouldBeRefreshed) {
mLauncher.updateIconBadges(Utilities.singletonHashSet(postedPackageUserKey));
if (dotShouldBeRefreshed) {
mLauncher.updateNotificationDots(Utilities.singletonHashSet(postedPackageUserKey));
}
}
@Override
public void onNotificationRemoved(PackageUserKey removedPackageUserKey,
NotificationKeyData notificationKey) {
BadgeInfo oldBadgeInfo = mPackageUserToBadgeInfos.get(removedPackageUserKey);
if (oldBadgeInfo != null && oldBadgeInfo.removeNotificationKey(notificationKey)) {
if (oldBadgeInfo.getNotificationKeys().size() == 0) {
mPackageUserToBadgeInfos.remove(removedPackageUserKey);
DotInfo oldDotInfo = mPackageUserToDotInfos.get(removedPackageUserKey);
if (oldDotInfo != null && oldDotInfo.removeNotificationKey(notificationKey)) {
if (oldDotInfo.getNotificationKeys().size() == 0) {
mPackageUserToDotInfos.remove(removedPackageUserKey);
}
mLauncher.updateIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
trimNotifications(mPackageUserToBadgeInfos);
mLauncher.updateNotificationDots(Utilities.singletonHashSet(removedPackageUserKey));
trimNotifications(mPackageUserToDotInfos);
}
}
@Override
public void onNotificationFullRefresh(List<StatusBarNotification> activeNotifications) {
if (activeNotifications == null) return;
// This will contain the PackageUserKeys which have updated badges.
HashMap<PackageUserKey, BadgeInfo> updatedBadges = new HashMap<>(mPackageUserToBadgeInfos);
mPackageUserToBadgeInfos.clear();
// This will contain the PackageUserKeys which have updated dots.
HashMap<PackageUserKey, DotInfo> updatedDots = new HashMap<>(mPackageUserToDotInfos);
mPackageUserToDotInfos.clear();
for (StatusBarNotification notification : activeNotifications) {
PackageUserKey packageUserKey = PackageUserKey.fromNotification(notification);
BadgeInfo badgeInfo = mPackageUserToBadgeInfos.get(packageUserKey);
if (badgeInfo == null) {
badgeInfo = new BadgeInfo(packageUserKey);
mPackageUserToBadgeInfos.put(packageUserKey, badgeInfo);
DotInfo dotInfo = mPackageUserToDotInfos.get(packageUserKey);
if (dotInfo == null) {
dotInfo = new DotInfo(packageUserKey);
mPackageUserToDotInfos.put(packageUserKey, dotInfo);
}
badgeInfo.addOrUpdateNotificationKey(NotificationKeyData
dotInfo.addOrUpdateNotificationKey(NotificationKeyData
.fromNotification(notification));
}
// Add and remove from updatedBadges so it contains the PackageUserKeys of updated badges.
for (PackageUserKey packageUserKey : mPackageUserToBadgeInfos.keySet()) {
BadgeInfo prevBadge = updatedBadges.get(packageUserKey);
BadgeInfo newBadge = mPackageUserToBadgeInfos.get(packageUserKey);
if (prevBadge == null) {
updatedBadges.put(packageUserKey, newBadge);
// Add and remove from updatedDots so it contains the PackageUserKeys of updated dots.
for (PackageUserKey packageUserKey : mPackageUserToDotInfos.keySet()) {
DotInfo prevDot = updatedDots.get(packageUserKey);
DotInfo newDot = mPackageUserToDotInfos.get(packageUserKey);
if (prevDot == null) {
updatedDots.put(packageUserKey, newDot);
} else {
if (!prevBadge.shouldBeInvalidated(newBadge)) {
updatedBadges.remove(packageUserKey);
if (!prevDot.shouldBeInvalidated(newDot)) {
updatedDots.remove(packageUserKey);
}
}
}
if (!updatedBadges.isEmpty()) {
mLauncher.updateIconBadges(updatedBadges.keySet());
if (!updatedDots.isEmpty()) {
mLauncher.updateNotificationDots(updatedDots.keySet());
}
trimNotifications(updatedBadges);
trimNotifications(updatedDots);
}
private void trimNotifications(Map<PackageUserKey, BadgeInfo> updatedBadges) {
private void trimNotifications(Map<PackageUserKey, DotInfo> updatedDots) {
PopupContainerWithArrow openContainer = PopupContainerWithArrow.getOpen(mLauncher);
if (openContainer != null) {
openContainer.trimNotifications(updatedBadges);
openContainer.trimNotifications(updatedDots);
}
}
@@ -163,17 +163,17 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
return count == null ? 0 : count;
}
public BadgeInfo getBadgeInfoForItem(ItemInfo info) {
public DotInfo getDotInfoForItem(ItemInfo info) {
if (!DeepShortcutManager.supportsShortcuts(info)) {
return null;
}
return mPackageUserToBadgeInfos.get(PackageUserKey.fromItemInfo(info));
return mPackageUserToDotInfos.get(PackageUserKey.fromItemInfo(info));
}
public @NonNull List<NotificationKeyData> getNotificationKeysForItem(ItemInfo info) {
BadgeInfo badgeInfo = getBadgeInfoForItem(info);
return badgeInfo == null ? Collections.EMPTY_LIST : badgeInfo.getNotificationKeys();
DotInfo dotInfo = getDotInfoForItem(info);
return dotInfo == null ? Collections.EMPTY_LIST : dotInfo.getNotificationKeys();
}
/** This makes a potentially expensive binder call and should be run on a background thread. */
@@ -38,10 +38,10 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
/**
* A {@link Preference} for indicating icon badging status.
* Also has utility methods for updating UI based on badging status changes.
* A {@link Preference} for indicating notification dots status.
* Also has utility methods for updating UI based on dots status changes.
*/
public class IconBadgingPreference extends Preference
public class NotificationDotsPreference extends Preference
implements SecureSettingsObserver.OnChangeListener {
private boolean mWidgetFrameVisible = false;
@@ -49,20 +49,20 @@ public class IconBadgingPreference extends Preference
/** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
private static final String NOTIFICATION_ENABLED_LISTENERS = "enabled_notification_listeners";
public IconBadgingPreference(
public NotificationDotsPreference(
Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public IconBadgingPreference(Context context, AttributeSet attrs, int defStyleAttr) {
public NotificationDotsPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public IconBadgingPreference(Context context, AttributeSet attrs) {
public NotificationDotsPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public IconBadgingPreference(Context context) {
public NotificationDotsPreference(Context context) {
super(context);
}
@@ -85,7 +85,9 @@ public class IconBadgingPreference extends Preference
@Override
public void onSettingsChanged(boolean enabled) {
int summary = enabled ? R.string.icon_badging_desc_on : R.string.icon_badging_desc_off;
int summary = enabled
? R.string.notification_dots_desc_on
: R.string.notification_dots_desc_off;
boolean serviceEnabled = true;
if (enabled) {
@@ -54,7 +54,7 @@ public class SettingsActivity extends Activity
private static final String DEVELOPER_OPTIONS_KEY = "pref_developer_options";
private static final String FLAGS_PREFERENCE_KEY = "flag_toggler";
private static final String ICON_BADGING_PREFERENCE_KEY = "pref_icon_badging";
private static final String NOTIFICATION_DOTS_PREFERENCE_KEY = "pref_icon_badging";
/** Hidden field Settings.Secure.ENABLED_NOTIFICATION_LISTENERS */
private static final String NOTIFICATION_ENABLED_LISTENERS = "enabled_notification_listeners";
@@ -120,7 +120,7 @@ public class SettingsActivity extends Activity
*/
public static class LauncherSettingsFragment extends PreferenceFragment {
private SecureSettingsObserver mIconBadgingObserver;
private SecureSettingsObserver mNotificationDotsObserver;
private String mHighLightKey;
private boolean mPreferenceHighlighted = false;
@@ -165,21 +165,21 @@ public class SettingsActivity extends Activity
*/
protected boolean initPreference(Preference preference) {
switch (preference.getKey()) {
case ICON_BADGING_PREFERENCE_KEY:
case NOTIFICATION_DOTS_PREFERENCE_KEY:
if (!Utilities.ATLEAST_OREO ||
!getResources().getBoolean(R.bool.notification_badging_enabled)) {
!getResources().getBoolean(R.bool.notification_dots_enabled)) {
return false;
}
// Listen to system notification badge settings while this UI is active.
mIconBadgingObserver = newNotificationSettingsObserver(
getActivity(), (IconBadgingPreference) preference);
mIconBadgingObserver.register();
// Listen to system notification dot settings while this UI is active.
mNotificationDotsObserver = newNotificationSettingsObserver(
getActivity(), (NotificationDotsPreference) preference);
mNotificationDotsObserver.register();
// Also listen if notification permission changes
mIconBadgingObserver.getResolver().registerContentObserver(
mNotificationDotsObserver.getResolver().registerContentObserver(
Settings.Secure.getUriFor(NOTIFICATION_ENABLED_LISTENERS), false,
mIconBadgingObserver);
mIconBadgingObserver.dispatchOnChange();
mNotificationDotsObserver);
mNotificationDotsObserver.dispatchOnChange();
return true;
case ADD_ICON_PREFERENCE_KEY:
@@ -245,9 +245,9 @@ public class SettingsActivity extends Activity
@Override
public void onDestroy() {
if (mIconBadgingObserver != null) {
mIconBadgingObserver.unregister();
mIconBadgingObserver = null;
if (mNotificationDotsObserver != null) {
mNotificationDotsObserver.unregister();
mNotificationDotsObserver = null;
}
super.onDestroy();
}
@@ -22,7 +22,7 @@ import android.view.View.AccessibilityDelegate;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.dot.DotInfo;
/**
* An interface to be used along with a context for various activities in Launcher. This allows a
@@ -34,7 +34,7 @@ public interface ActivityContext {
return false;
}
default BadgeInfo getBadgeInfoForItem(ItemInfo info) {
default DotInfo getDotInfoForItem(ItemInfo info) {
return null;
}
@@ -62,7 +62,7 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
getPaint().setShadowLayer(mShadowInfo.ambientShadowBlur, 0, 0,
setColorAlphaBound(mShadowInfo.ambientShadowColor, alpha));
drawWithoutBadge(canvas);
drawWithoutDot(canvas);
canvas.save();
canvas.clipRect(getScrollX(), getScrollY() + getExtendedPaddingTop(),
getScrollX() + getWidth(),
@@ -70,10 +70,10 @@ public class DoubleShadowBubbleTextView extends BubbleTextView {
getPaint().setShadowLayer(mShadowInfo.keyShadowBlur, 0.0f, mShadowInfo.keyShadowOffset,
setColorAlphaBound(mShadowInfo.keyShadowColor, alpha));
drawWithoutBadge(canvas);
drawWithoutDot(canvas);
canvas.restore();
drawBadgeIfNecessary(canvas);
drawDotIfNecessary(canvas);
}
public static class ShadowInfo {