增加app在内外显示,支持长按显示隐藏,优化命名,主页app显示还有问题

This commit is contained in:
2025-11-03 08:56:21 +08:00
parent 552ec8dbe9
commit 8dc284c2f3
38 changed files with 1265 additions and 290 deletions

View File

@@ -129,19 +129,31 @@ public class IconCacheManager {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (icon instanceof AdaptiveIconDrawable) {
// 分别获取背景和前景Drawable
Drawable[] layers = new Drawable[2];
layers[0] = ((AdaptiveIconDrawable) icon).getBackground();
layers[1] = ((AdaptiveIconDrawable) icon).getForeground();
LayerDrawable layerDrawable = new LayerDrawable(layers);
// Drawable[] layers = new Drawable[2];
// layers[0] = ((AdaptiveIconDrawable) icon).getBackground();
// layers[1] = ((AdaptiveIconDrawable) icon).getForeground();
// LayerDrawable layerDrawable = new LayerDrawable(layers);
//
// int width = icon.getIntrinsicWidth();
// int height = icon.getIntrinsicHeight();
//
// Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// Canvas canvas = new Canvas(bitmap);
//
// layerDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
// layerDrawable.draw(canvas);
int width = icon.getIntrinsicWidth();
int height = icon.getIntrinsicHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
// 创建一个大小与原始Drawable相同的位图
Bitmap bitmap = Bitmap.createBitmap(
icon.getIntrinsicWidth(),
icon.getIntrinsicHeight(),
Bitmap.Config.ARGB_8888
);
Canvas canvas = new Canvas(bitmap);
// 关键步骤设置Drawable的绘制边界
icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
icon.draw(canvas);
layerDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
layerDrawable.draw(canvas);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, editor.newOutputStream(0));
editor.commit();
}