Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Treat a square banner as no banner, so the tile shows the icon instead of a blur

tumise1009ae586da190d
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
index a6efcb7c2..e79aad605 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/AppAdapter.java
@@ -289,16 +289,27 @@ public class AppAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Drawable loadBanner(PackageManager pm, ResolveInfo ri) {
int id = ri.activityInfo.banner;
if (id == 0) id = ri.activityInfo.applicationInfo.banner;
+ Drawable banner = null;
if (id != 0) {
try {
Resources resources = pm.getResourcesForApplication(ri.activityInfo.applicationInfo);
// Keep at least xhdpi detail rather than downsampling artwork before the focus zoom.
int density = Math.max(DisplayMetrics.DENSITY_XHIGH, ctx.getResources().getDisplayMetrics().densityDpi);
- return resources.getDrawableForDensity(id, density, null);
+ banner = resources.getDrawableForDensity(id, density, null);
} catch (PackageManager.NameNotFoundException | Resources.NotFoundException ignored) {
}
}
- return ri.activityInfo.loadBanner(pm);
+ if (banner == null) banner = ri.activityInfo.loadBanner(pm);
+ // A square "banner" counts as none: the tile shows the app's icon and name instead of a blur.
+ return banner != null && isBannerShaped(banner.getIntrinsicWidth(), banner.getIntrinsicHeight()) ? banner : null;
+ }
+
+ /**
+ * Some apps declare a small square image as their banner (Rockchip's Media Center ships a 64 px one). Cropped
+ * over a 16:9 tile it is a blur. A drawable with no intrinsic size (a colour, a shape) still fills the tile.
+ */
+ static boolean isBannerShaped(int width, int height) {
+ return width <= 0 || height <= 0 || width >= height * 1.4f;
}
@NonNull
diff --git a/launcher/app/src/test/java/com/gathin/tvhome/BannerShapeTest.java b/launcher/app/src/test/java/com/gathin/tvhome/BannerShapeTest.java
new file mode 100644
index 000000000..0231b7722
--- /dev/null
+++ b/launcher/app/src/test/java/com/gathin/tvhome/BannerShapeTest.java
@@ -0,0 +1,27 @@
+package com.gathin.tvhome;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class BannerShapeTest {
+ @Test
+ public void wideBannersAreKept() {
+ assertTrue(AppAdapter.isBannerShaped(320, 180));
+ assertTrue(AppAdapter.isBannerShaped(1920, 1080));
+ }
+
+ @Test
+ public void squareAndTallPicturesAreNotBanners() {
+ assertFalse(AppAdapter.isBannerShaped(64, 64));
+ assertFalse(AppAdapter.isBannerShaped(256, 256));
+ assertFalse(AppAdapter.isBannerShaped(100, 160));
+ }
+
+ @Test
+ public void drawablesWithoutAnIntrinsicSizeStillFillTheTile() {
+ assertTrue(AppAdapter.isBannerShaped(-1, -1));
+ assertTrue(AppAdapter.isBannerShaped(0, 0));
+ }
+}