Skip to content

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

Launcher: crop the clock wallpaper like Home instead of stretching it

benny1170abcd7cd8254
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java b/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java
index 111304c61..dd324c91f 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/ClockScene.java
@@ -14,6 +14,7 @@ import android.os.Handler;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.View;
+import android.widget.ImageView;
import java.io.File;
import java.util.Random;
@@ -35,7 +36,7 @@ final class ClockScene {
private final Handler handler = new Handler(Looper.getMainLooper());
private final Random random = new Random();
private final View content;
- private final View ambient;
+ private final ImageView ambient;
private final GradientDrawable glow;
private int colorIndex;
private int glowColor;
@@ -129,7 +130,10 @@ final class ClockScene {
return;
}
wallpaperShown = true;
- ambient.setBackground(new LayerDrawable(new Drawable[]{
+ // As the image, not the background: a background is stretched to the view, so a picture of
+ // another shape than the screen would be distorted. centerCrop scales and crops it like Home.
+ ambient.setBackground(null);
+ ambient.setImageDrawable(new LayerDrawable(new Drawable[]{
new BitmapDrawable(res, bmp), new ColorDrawable(shade)}));
});
}, "clock-wallpaper").start();
diff --git a/launcher/app/src/main/res/layout-iw/dream_clock.xml b/launcher/app/src/main/res/layout-iw/dream_clock.xml
index 02867dfe5..fb4cd781e 100644
--- a/launcher/app/src/main/res/layout-iw/dream_clock.xml
+++ b/launcher/app/src/main/res/layout-iw/dream_clock.xml
@@ -5,10 +5,13 @@
android:layout_height="match_parent"
android:background="#FF000000">
- <View
+ <!-- The glow is its background; clock_wallpaper puts the picture in it, cropped like Home's. -->
+ <ImageView
android:id="@+id/dreamAmbient"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"
+ android:importantForAccessibility="no" />
<LinearLayout
android:id="@+id/dreamContent"
diff --git a/launcher/app/src/main/res/layout/dream_clock.xml b/launcher/app/src/main/res/layout/dream_clock.xml
index 540a2b73b..b059bfa0d 100644
--- a/launcher/app/src/main/res/layout/dream_clock.xml
+++ b/launcher/app/src/main/res/layout/dream_clock.xml
@@ -5,10 +5,13 @@
android:layout_height="match_parent"
android:background="#FF000000">
- <View
+ <!-- The glow is its background; clock_wallpaper puts the picture in it, cropped like Home's. -->
+ <ImageView
android:id="@+id/dreamAmbient"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:scaleType="centerCrop"
+ android:importantForAccessibility="no" />
<LinearLayout
android:id="@+id/dreamContent"