Skip to content

Commit 9040b27

Browse files
committed
[Debloater] Display unsafe bloatware
Unsafe bloatware are filtered out by default in the Debloater page. Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
1 parent c72b468 commit 9040b27

11 files changed

Lines changed: 34 additions & 10 deletions

File tree

app/src/main/assets/debloat.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

app/src/main/java/io/github/muntashirakon/AppManager/debloat/BloatwareDetailsDialog.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void updateDialog(@NonNull DebloatObject debloatObject) {
142142
if (warning != null) {
143143
mWarningView.setVisibility(View.VISIBLE);
144144
mWarningView.setText(warning);
145-
if (debloatObject.getRemoval() != DebloatObject.REMOVAL_CAUTION) {
145+
if (debloatObject.getRemoval() >= DebloatObject.REMOVAL_CAUTION) {
146146
mWarningView.setAlertType(MaterialAlertView.ALERT_TYPE_INFO);
147147
} else mWarningView.setAlertType(MaterialAlertView.ALERT_TYPE_WARN);
148148
} else mWarningView.setVisibility(View.GONE);
@@ -165,6 +165,10 @@ private void updateDialog(@NonNull DebloatObject debloatObject) {
165165
removalColor = ColorCodes.getRemovalReplaceIndicatorColor(requireContext());
166166
removalRes = R.string.debloat_removal_replace_short_description;
167167
break;
168+
case DebloatObject.REMOVAL_UNSAFE:
169+
removalColor = ColorCodes.getRemovalUnsafeIndicatorColor(requireContext());
170+
removalRes = R.string.debloat_removal_unsafe;
171+
break;
168172
}
169173
mFlowLayout.removeAllViews();
170174
addTag(mFlowLayout, debloatObject.type);

app/src/main/java/io/github/muntashirakon/AppManager/debloat/DebloatObject.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
import io.github.muntashirakon.AppManager.utils.ArrayUtils;
2929

3030
public class DebloatObject {
31-
@IntDef({REMOVAL_SAFE, REMOVAL_REPLACE, REMOVAL_CAUTION})
31+
@IntDef({REMOVAL_SAFE, REMOVAL_REPLACE, REMOVAL_CAUTION, REMOVAL_UNSAFE})
3232
@Retention(RetentionPolicy.SOURCE)
3333
public @interface Removal {
3434
}
3535

3636
public static final int REMOVAL_SAFE = 1;
3737
public static final int REMOVAL_REPLACE = 1 << 1;
3838
public static final int REMOVAL_CAUTION = 1 << 2;
39+
public static final int REMOVAL_UNSAFE = 1 << 3;
3940

4041
@SerializedName("id")
4142
public String packageName;
@@ -100,6 +101,8 @@ public int getRemoval() {
100101
return REMOVAL_REPLACE;
101102
case "caution":
102103
return REMOVAL_CAUTION;
104+
case "unsafe":
105+
return REMOVAL_UNSAFE;
103106
}
104107
}
105108

app/src/main/java/io/github/muntashirakon/AppManager/debloat/DebloaterListOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class DebloaterListOptions extends CapsuleBottomSheetDialogFragment {
3737
FILTER_REMOVAL_SAFE,
3838
FILTER_REMOVAL_REPLACE,
3939
FILTER_REMOVAL_CAUTION,
40+
FILTER_REMOVAL_UNSAFE,
4041

4142
FILTER_USER_APPS,
4243
FILTER_SYSTEM_APPS,
@@ -58,7 +59,7 @@ public class DebloaterListOptions extends CapsuleBottomSheetDialogFragment {
5859
public static final int FILTER_REMOVAL_SAFE = 1 << 6;
5960
public static final int FILTER_REMOVAL_REPLACE = 1 << 7;
6061
public static final int FILTER_REMOVAL_CAUTION = 1 << 8;
61-
// public static final int FILTER_DEPRECATED_9 = 1 << 9;
62+
public static final int FILTER_REMOVAL_UNSAFE = 1 << 9;
6263

6364
public static final int FILTER_USER_APPS = 1 << 10;
6465
public static final int FILTER_SYSTEM_APPS = 1 << 11;
@@ -77,6 +78,7 @@ public class DebloaterListOptions extends CapsuleBottomSheetDialogFragment {
7778
put(FILTER_REMOVAL_SAFE, R.string.debloat_removal_safe);
7879
put(FILTER_REMOVAL_REPLACE, R.string.debloat_removal_replace);
7980
put(FILTER_REMOVAL_CAUTION, R.string.debloat_removal_caution);
81+
put(FILTER_REMOVAL_UNSAFE, R.string.debloat_removal_unsafe);
8082
}};
8183

8284
private static final SparseIntArray NORMAL_FILTER_MAP = new SparseIntArray() {{

app/src/main/java/io/github/muntashirakon/AppManager/debloat/DebloaterRecyclerViewAdapter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class DebloaterRecyclerViewAdapter extends MultiSelectionView.Adapter<Deb
3939
@ColorInt
4040
private final int mRemovalReplaceColor;
4141
@ColorInt
42+
private final int mRemovalUnsafeColor;
43+
@ColorInt
4244
private final int mRemovalCautionColor;
4345
@ColorInt
4446
private final int mColorSurface;
@@ -53,6 +55,7 @@ public DebloaterRecyclerViewAdapter(DebloaterActivity activity) {
5355
mRemovalSafeColor = ColorCodes.getRemovalSafeIndicatorColor(activity);
5456
mRemovalReplaceColor = ColorCodes.getRemovalReplaceIndicatorColor(activity);
5557
mRemovalCautionColor = ColorCodes.getRemovalCautionIndicatorColor(activity);
58+
mRemovalUnsafeColor = ColorCodes.getRemovalUnsafeIndicatorColor(activity);
5659
mColorSurface = MaterialColors.getColor(activity, com.google.android.material.R.attr.colorSurface,
5760
DebloaterRecyclerViewAdapter.class.getCanonicalName());
5861
mViewModel = activity.viewModel;
@@ -99,6 +102,10 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
99102
removalColor = mRemovalReplaceColor;
100103
removalRes = R.string.debloat_removal_replace_short_description;
101104
break;
105+
case DebloatObject.REMOVAL_UNSAFE:
106+
removalColor = mRemovalUnsafeColor;
107+
removalRes = R.string.debloat_removal_unsafe;
108+
break;
102109
}
103110
sb.append(getColoredText(context.getString(removalRes), removalColor));
104111
if (!TextUtils.isEmpty(warning)) {

app/src/main/java/io/github/muntashirakon/AppManager/debloat/DebloaterViewModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ public void loadPackages() {
156156
if ((mFilterFlags & DebloaterListOptions.FILTER_REMOVAL_CAUTION) == 0 && removalType == DebloatObject.REMOVAL_CAUTION) {
157157
continue;
158158
}
159+
if ((mFilterFlags & DebloaterListOptions.FILTER_REMOVAL_UNSAFE) == 0 && removalType == DebloatObject.REMOVAL_UNSAFE) {
160+
continue;
161+
}
159162
// Filter others
160163
if ((mFilterFlags & DebloaterListOptions.FILTER_INSTALLED_APPS) != 0 && !debloatObject.isInstalled()) {
161164
continue;

app/src/main/java/io/github/muntashirakon/AppManager/filters/options/BloatwareOption.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static io.github.muntashirakon.AppManager.debloat.DebloatObject.REMOVAL_CAUTION;
66
import static io.github.muntashirakon.AppManager.debloat.DebloatObject.REMOVAL_REPLACE;
77
import static io.github.muntashirakon.AppManager.debloat.DebloatObject.REMOVAL_SAFE;
8+
import static io.github.muntashirakon.AppManager.debloat.DebloatObject.REMOVAL_UNSAFE;
89
import static io.github.muntashirakon.AppManager.debloat.DebloaterListOptions.FILTER_LIST_AOSP;
910
import static io.github.muntashirakon.AppManager.debloat.DebloaterListOptions.FILTER_LIST_CARRIER;
1011
import static io.github.muntashirakon.AppManager.debloat.DebloaterListOptions.FILTER_LIST_GOOGLE;
@@ -42,6 +43,7 @@ public class BloatwareOption extends FilterOption {
4243
put(REMOVAL_SAFE, "Safe");
4344
put(REMOVAL_REPLACE, "Replace");
4445
put(REMOVAL_CAUTION, "Caution");
46+
put(REMOVAL_UNSAFE, "Unsafe");
4547
}};
4648

4749
public BloatwareOption() {

app/src/main/java/io/github/muntashirakon/AppManager/utils/appearance/ColorCodes.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ public static int getBloatwareIndicatorColor(@NonNull Context context, @DebloatO
7878
case DebloatObject.REMOVAL_SAFE:
7979
return getRemovalSafeIndicatorColor(context);
8080
case DebloatObject.REMOVAL_CAUTION:
81-
default:
8281
return getRemovalCautionIndicatorColor(context);
82+
case DebloatObject.REMOVAL_UNSAFE:
83+
default:
84+
return getRemovalUnsafeIndicatorColor(context);
8385
}
8486
}
8587

@@ -147,6 +149,10 @@ public static int getRemovalCautionIndicatorColor(@NonNull Context context) {
147149
return ContextCompat.getColor(context, R.color.pumpkin_orange);
148150
}
149151

152+
public static int getRemovalUnsafeIndicatorColor(@NonNull Context context) {
153+
return getFailureColor(context);
154+
}
155+
150156
public static int getScannerNoTrackerIndicatorColor(@NonNull Context context) {
151157
return getSuccessColor(context);
152158
}

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,4 +1522,5 @@
15221522
<string name="filters">Filters</string>
15231523
<string name="icon">icon</string>
15241524
<string name="preview">Preview</string>
1525+
<string name="debloat_removal_unsafe">Unsafe</string>
15251526
</resources>

0 commit comments

Comments
 (0)