mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Remove work profile badge from widget previews
Test: Check work profile badge no longer shown on work widget in the
full and bottom widgets pickers.
Bug: 177675123
Change-Id: I0e5e32e18df832c1919749404094d68805c30556
This commit is contained in:
@@ -33,14 +33,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_gravity="fill"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widget_badge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAccessibility="no"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/profile_badge_margin"/>
|
||||
</com.android.launcher3.widget.WidgetCellPreview>
|
||||
|
||||
<!-- The name of the widget. -->
|
||||
|
||||
@@ -21,9 +21,7 @@ import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.CancellationSignal;
|
||||
@@ -35,9 +33,7 @@ import android.util.LongSparseArray;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.icons.GraphicsUtils;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.icons.LauncherIcons;
|
||||
@@ -93,51 +89,6 @@ public class WidgetPreviewLoader {
|
||||
mDb = new CacheDb(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a drawable that can be used as a badge for the user or null.
|
||||
*/
|
||||
@UiThread
|
||||
public Drawable getBadgeForUser(UserHandle user, int badgeSize) {
|
||||
if (mMyUser.equals(user)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bitmap badgeBitmap = getUserBadge(user, badgeSize);
|
||||
FastBitmapDrawable d = new FastBitmapDrawable(badgeBitmap);
|
||||
d.setFilterBitmap(true);
|
||||
d.setBounds(0, 0, badgeBitmap.getWidth(), badgeBitmap.getHeight());
|
||||
return d;
|
||||
}
|
||||
|
||||
private Bitmap getUserBadge(UserHandle user, int badgeSize) {
|
||||
synchronized (mUserBadges) {
|
||||
Bitmap badgeBitmap = mUserBadges.get(user);
|
||||
if (badgeBitmap != null) {
|
||||
return badgeBitmap;
|
||||
}
|
||||
|
||||
final Resources res = mContext.getResources();
|
||||
badgeBitmap = Bitmap.createBitmap(badgeSize, badgeSize, Bitmap.Config.ARGB_8888);
|
||||
|
||||
Drawable drawable = mContext.getPackageManager().getUserBadgedDrawableForDensity(
|
||||
new BitmapDrawable(res, badgeBitmap), user,
|
||||
new Rect(0, 0, badgeSize, badgeSize),
|
||||
0);
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
badgeBitmap = ((BitmapDrawable) drawable).getBitmap();
|
||||
} else {
|
||||
badgeBitmap.eraseColor(Color.TRANSPARENT);
|
||||
Canvas c = new Canvas(badgeBitmap);
|
||||
drawable.setBounds(0, 0, badgeSize, badgeSize);
|
||||
drawable.draw(c);
|
||||
c.setBitmap(null);
|
||||
}
|
||||
|
||||
mUserBadges.put(user, badgeBitmap);
|
||||
return badgeBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the widget preview on {@link AsyncTask#THREAD_POOL_EXECUTOR}. Must be
|
||||
* called on UI thread
|
||||
|
||||
@@ -33,7 +33,6 @@ import android.view.View.OnLayoutChangeListener;
|
||||
import android.view.ViewPropertyAnimator;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
@@ -45,7 +44,6 @@ import com.android.launcher3.CheckLongPressHelper;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.WidgetPreviewLoader;
|
||||
import com.android.launcher3.icons.BaseIconFactory;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
import com.android.launcher3.icons.RoundDrawableWrapper;
|
||||
import com.android.launcher3.model.WidgetItem;
|
||||
@@ -80,7 +78,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
||||
|
||||
private FrameLayout mWidgetImageContainer;
|
||||
private WidgetImageView mWidgetImage;
|
||||
private ImageView mWidgetBadge;
|
||||
private TextView mWidgetName;
|
||||
private TextView mWidgetDims;
|
||||
private TextView mWidgetDescription;
|
||||
@@ -136,7 +133,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
||||
|
||||
mWidgetImageContainer = findViewById(R.id.widget_preview_container);
|
||||
mWidgetImage = findViewById(R.id.widget_preview);
|
||||
mWidgetBadge = findViewById(R.id.widget_badge);
|
||||
mWidgetName = findViewById(R.id.widget_name);
|
||||
mWidgetDims = findViewById(R.id.widget_dims);
|
||||
mWidgetDescription = findViewById(R.id.widget_description);
|
||||
@@ -161,7 +157,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
||||
mWidgetImage.animate().cancel();
|
||||
mWidgetImage.setDrawable(null);
|
||||
mWidgetImage.setVisibility(View.VISIBLE);
|
||||
mWidgetBadge.setImageDrawable(null);
|
||||
mWidgetName.setText(null);
|
||||
mWidgetDims.setText(null);
|
||||
mWidgetDescription.setText(null);
|
||||
@@ -294,15 +289,6 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
||||
mAppWidgetHostViewPreview = null;
|
||||
}
|
||||
}
|
||||
Drawable badge = mWidgetPreviewLoader.getBadgeForUser(mItem.user,
|
||||
BaseIconFactory.getBadgeSizeForIconSize(
|
||||
mActivity.getDeviceProfile().allAppsIconSizePx));
|
||||
if (badge == null) {
|
||||
mWidgetBadge.setVisibility(View.GONE);
|
||||
} else {
|
||||
mWidgetBadge.setVisibility(View.VISIBLE);
|
||||
mWidgetBadge.setImageDrawable(badge);
|
||||
}
|
||||
if (mAnimatePreview) {
|
||||
mWidgetImageContainer.setAlpha(0f);
|
||||
ViewPropertyAnimator anim = mWidgetImageContainer.animate();
|
||||
|
||||
Reference in New Issue
Block a user