Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
addons: Photo Prints, your photos as a screensaver and a Home card
Shivam Singhf310e897ff81
diff --git a/addons/README.md b/addons/README.mdindex 9d4953652..1e989f826 100644--- a/addons/README.md+++ b/addons/README.md@@ -12,6 +12,7 @@ the core bigger or change how it behaves. You install an add-on only if you want| [Frigate Glance](frigate-glance/) | Frigate camera pop-ups over whatever is playing | NickLD | TCL 65Q650G | overlay, accessibility (card keys), network, foreground service || [Capacity Stats](capacity-stats/) | Available/total and used/total RAM; available/total storage | [lionlev21](https://github.com/lionlev21) | Android TV 12 (model private) | None || [Weather](weather/) | The weather for one city: now, US air quality and the next three days, from Open-Meteo (no key) | [@Sumyabazar1](https://github.com/Sumyabazar1) | Hisense SmartTV 4K FFM (lushan), Google TV 12 | `INTERNET` |+| [Photo Prints](photo-screensaver/) | Your own photos as a screensaver: dated prints dealt in on a time-of-day sky, and a card that starts the slideshow | [@shivamsingh262](https://github.com/shivamsingh262) | Sony BRAVIA KD-65X82L (Google TV 12), test pending | None |A widget, an info tile, a storage or smart-home card: if it can live as its own small app, it can livehere. See the rules below.diff --git a/addons/photo-screensaver/.gitignore b/addons/photo-screensaver/.gitignorenew file mode 100644index 000000000..a7e04a21b--- /dev/null+++ b/addons/photo-screensaver/.gitignore@@ -0,0 +1,4 @@+.gradle/+build/+app/build/+local.propertiesdiff --git a/addons/photo-screensaver/FONT-LICENSE-OFL.txt b/addons/photo-screensaver/FONT-LICENSE-OFL.txtnew file mode 100644index 000000000..723cd447e--- /dev/null+++ b/addons/photo-screensaver/FONT-LICENSE-OFL.txt@@ -0,0 +1,93 @@+Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+https://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/addons/photo-screensaver/README.md b/addons/photo-screensaver/README.mdnew file mode 100644index 000000000..a94f5a4c4--- /dev/null+++ b/addons/photo-screensaver/README.md@@ -0,0 +1,63 @@+# Photo Prints++Your own photos as a screensaver: three prints on a time-of-day sky, each the whole photo (never cropped) with+rounded corners and the month and year it was taken. Every 15 seconds they slide off to the left one after+another and three new ones are dealt in from the right, each at a slight tilt. A line along the bottom shows the+time and the date, and moves a little at each sweep so it does not burn in.++On cleanyourtv's Home it is also a module card, **Photo Prints**: press OK on it to start the same slideshow at+once, and Back to leave.++- Package: `io.github.shivamsingh262.photoprints`+- Author: [@shivamsingh262](https://github.com/shivamsingh262)+- Tested on: Sony BRAVIA KD-65X82L (Google TV 12), test pending++## Permissions++None. The app reads photos from its own folder on the TV, which needs no permission, and has no network access+(no `INTERNET` permission): nothing leaves the TV. No background service: it runs only while the screensaver or+the slideshow is on screen.++## Build and install++JDK 17 and Android SDK 34, as for the launcher. From the repo root:++```bash+cd addons/photo-screensaver && ./gradlew assembleRelease && cd ../..+TV_HOST=<tv ip> tools/venv/bin/python -I tools/tv.py --push addons/photo-screensaver/app/build/outputs/apk/release/app-release.apk /data/local/tmp/addon.apk+TV_HOST=<tv ip> tools/venv/bin/python -I tools/tv.py 'pm install -r /data/local/tmp/addon.apk; rm -f /data/local/tmp/addon.apk'+```++Press Home: the launcher asks once whether to show the card.++## Add your photos++The photos live in the app's own folder on the TV:+`/sdcard/Android/data/io.github.shivamsingh262.photoprints/files/photos`. On a Mac, `photos.sh` fills it from a+folder, resizing each photo to 1280 px first (HEIC included) and writing the date it was taken into the name:++```bash+TV_HOST=<tv ip> addons/photo-screensaver/photos.sh ~/Pictures/TV+TV_HOST=<tv ip> addons/photo-screensaver/photos.sh --clear # remove them all+```++Any `jpg`, `jpeg`, `png` or `webp` copied into that folder by other means works too. A name ending in the date,+`something-20231202.jpg`, gives the print its date; otherwise the camera's own date is used when the photo has+one, and the print shows no date when it has neither. Photos added while the TV is on show up at the next sweep.+With no photos, the screen shows the folder to copy them into.++## Use it as the screensaver++Settings > System > Ambient mode or Screen saver > **Photo Prints** (the menu's name depends on the TV), or:++```bash+TV_HOST=<tv ip> tools/venv/bin/python -I tools/tv.py 'settings put secure screensaver_components io.github.shivamsingh262.photoprints/.PrintsDream'+```++## Remove++```bash+TV_HOST=<tv ip> tools/venv/bin/python -I tools/tv.py 'pm uninstall io.github.shivamsingh262.photoprints'+```++This removes the photos folder with it. If it was the screensaver, pick another one in Settings.diff --git a/addons/photo-screensaver/app/build.gradle b/addons/photo-screensaver/app/build.gradlenew file mode 100644index 000000000..cffa88eb6--- /dev/null+++ b/addons/photo-screensaver/app/build.gradle@@ -0,0 +1,36 @@+plugins {+ id 'com.android.application'+}++android {+ namespace 'io.github.shivamsingh262.photoprints'+ compileSdk 34++ defaultConfig {+ applicationId 'io.github.shivamsingh262.photoprints'+ minSdk 26+ targetSdk 34+ versionCode 1+ versionName '1.0'+ }++ buildTypes {+ release {+ minifyEnabled true+ shrinkResources true+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')+ // Sideloaded over ADB, never published: sign with the debug key, as the launcher does.+ signingConfig signingConfigs.debug+ }+ }++ compileOptions {+ sourceCompatibility JavaVersion.VERSION_17+ targetCompatibility JavaVersion.VERSION_17+ }+}++dependencies {+ // Test only (never in the APK): plain JVM tests for the date on each print.+ testImplementation 'junit:junit:4.13.2'+}diff --git a/addons/photo-screensaver/app/src/main/AndroidManifest.xml b/addons/photo-screensaver/app/src/main/AndroidManifest.xmlnew file mode 100644index 000000000..4110f00a3--- /dev/null+++ b/addons/photo-screensaver/app/src/main/AndroidManifest.xml@@ -0,0 +1,43 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- No permissions: the photos are read from this app's own folder, and nothing goes over the network. -->+<manifest xmlns:android="http://schemas.android.com/apk/res/android">++ <uses-feature android:name="android.software.leanback" android:required="false" />+ <uses-feature android:name="android.hardware.touchscreen" android:required="false" />++ <application+ android:label="@string/app_name"+ android:icon="@drawable/icon"+ android:banner="@drawable/banner"+ android:allowBackup="false"+ android:theme="@style/Prints">++ <!-- The tile, and the card on cleanyourtv's Home (docs/modules.md): the slideshow, at once. -->+ <activity+ android:name=".SlideshowActivity"+ android:exported="true"+ android:screenOrientation="landscape">+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="android.intent.category.LEANBACK_LAUNCHER" />+ </intent-filter>+ <intent-filter>+ <action android:name="android.intent.action.MAIN" />+ <category android:name="com.gathin.tvhome.category.DOCK_CARD" />+ </intent-filter>+ <meta-data android:name="com.gathin.tvhome.card" android:resource="@xml/module_card" />+ </activity>++ <!-- The screensaver: Settings > Screen saver > Photo Prints. -->+ <service+ android:name=".PrintsDream"+ android:exported="true"+ android:label="@string/app_name"+ android:permission="android.permission.BIND_DREAM_SERVICE">+ <intent-filter>+ <action android:name="android.service.dreams.DreamService" />+ <category android:name="android.intent.category.DEFAULT" />+ </intent-filter>+ </service>+ </application>+</manifest>diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Photos.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Photos.javanew file mode 100644index 000000000..3de71251a--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Photos.java@@ -0,0 +1,126 @@+package io.github.shivamsingh262.photoprints;++import android.content.Context;+import android.graphics.Bitmap;+import android.graphics.BitmapFactory;+import android.graphics.Matrix;+import android.media.ExifInterface;++import java.io.File;+import java.text.DateFormatSymbols;+import java.util.ArrayList;+import java.util.List;+import java.util.regex.Matcher;+import java.util.regex.Pattern;++/**+ * The owner's photos: the files in this app's own folder on the TV, where photos.sh (or adb push) puts them,+ * /sdcard/Android/data/io.github.shivamsingh262.photoprints/files/photos. Writing there needs no permission, and+ * the app reads its own folder without one.+ */+final class Photos {++ static final String DIR = "photos";++ private static final Pattern IMAGE = Pattern.compile("[A-Za-z0-9_. -]+\\.(jpg|jpeg|png|webp)",+ Pattern.CASE_INSENSITIVE);+ /**+ * The date photos.sh writes into the name: photo-0007-20231202.jpg, or only the month, photo-0007-202312.jpg.+ */+ private static final Pattern NAME_DATE = Pattern.compile("-(\\d{4})(\\d{2})(\\d{2})?\\.[A-Za-z]+$");++ private Photos() {+ }++ static File folder(Context c) {+ return new File(c.getExternalFilesDir(null), DIR);+ }++ /** The photo files, read again on every call so photos pushed while the TV is on show up. */+ static List<File> list(Context c) {+ List<File> out = new ArrayList<>();+ File[] files = folder(c).listFiles();+ if (files == null) return out;+ for (File f : files) {+ if (f.isFile() && isImage(f.getName())) out.add(f);+ }+ return out;+ }++ static boolean isImage(String name) {+ return name != null && !name.startsWith(".") && IMAGE.matcher(name).matches();+ }++ /** {year, month} from a name photos.sh gave, or null. */+ static int[] dateFromName(String name) {+ Matcher m = NAME_DATE.matcher(name);+ if (!m.find()) return null;+ int year = Integer.parseInt(m.group(1)), month = Integer.parseInt(m.group(2));+ return year >= 1900 && month >= 1 && month <= 12 ? new int[]{year, month} : null;+ }++ /** "Dec 2023": from the file name, else from when the camera says it was taken; else "". */+ static String dateOf(File file) {+ int[] ym = dateFromName(file.getName());+ if (ym == null) {+ try {+ String taken = new ExifInterface(file.getPath()).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL);+ if (taken != null && taken.length() >= 7) { // "2023:12:02 09:22:30"+ int year = Integer.parseInt(taken.substring(0, 4)), month = Integer.parseInt(taken.substring(5, 7));+ if (year >= 1900 && month >= 1 && month <= 12) ym = new int[]{year, month};+ }+ } catch (Exception ignored) {+ // No date: the print shows none.+ }+ }+ if (ym == null) return "";+ return new DateFormatSymbols().getShortMonths()[ym[1] - 1] + " " + ym[0];+ }++ /** The EXIF rotation that turns the photo upright: 0, 90, 180 or 270. */+ private static int rotation(File file) {+ try {+ int o = new ExifInterface(file.getPath()).getAttributeInt(+ ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);+ if (o == ExifInterface.ORIENTATION_ROTATE_90) return 90;+ if (o == ExifInterface.ORIENTATION_ROTATE_180) return 180;+ if (o == ExifInterface.ORIENTATION_ROTATE_270) return 270;+ } catch (Exception ignored) {+ // PNG and WebP carry no EXIF here; show them as they are.+ }+ return 0;+ }++ /** The photo's {width, height} once upright, read from its header only; null if it is not an image. */+ static int[] size(File file) {+ BitmapFactory.Options bounds = new BitmapFactory.Options();+ bounds.inJustDecodeBounds = true;+ BitmapFactory.decodeFile(file.getPath(), bounds);+ if (bounds.outWidth <= 0 || bounds.outHeight <= 0) return null;+ return rotation(file) % 180 == 0 ? new int[]{bounds.outWidth, bounds.outHeight}+ : new int[]{bounds.outHeight, bounds.outWidth};+ }++ /** Decodes at the smallest power-of-two size that still covers w x h, upright per EXIF; null on failure. */+ static Bitmap decode(File file, int w, int h) {+ try {+ int rotation = rotation(file);+ int[] size = size(file);+ if (size == null) return null;+ int sample = 1;+ while (size[0] / (sample * 2) >= w && size[1] / (sample * 2) >= h) sample *= 2;+ BitmapFactory.Options opts = new BitmapFactory.Options();+ opts.inSampleSize = sample;+ opts.inPreferredConfig = Bitmap.Config.RGB_565; // half the memory of ARGB_8888; photos have no alpha+ Bitmap bitmap = BitmapFactory.decodeFile(file.getPath(), opts);+ if (bitmap == null || rotation == 0) return bitmap;+ Matrix m = new Matrix();+ m.postRotate(rotation);+ Bitmap rotated = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);+ if (rotated != bitmap) bitmap.recycle();+ return rotated;+ } catch (OutOfMemoryError | RuntimeException e) {+ return null;+ }+ }+}diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Prints.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Prints.javanew file mode 100644index 000000000..b75ee061a--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Prints.java@@ -0,0 +1,275 @@+package io.github.shivamsingh262.photoprints;++import android.content.Context;+import android.graphics.Bitmap;+import android.graphics.drawable.BitmapDrawable;+import android.graphics.drawable.Drawable;+import android.os.Handler;+import android.os.Looper;+import android.view.LayoutInflater;+import android.view.View;+import android.view.ViewGroup;+import android.view.animation.AccelerateInterpolator;+import android.view.animation.DecelerateInterpolator;+import android.widget.FrameLayout;+import android.widget.ImageView;+import android.widget.TextView;++import java.io.File;+import java.util.ArrayList;+import java.util.Collections;+import java.util.List;+import java.util.Random;+import java.util.concurrent.ExecutorService;+import java.util.concurrent.Executors;++/**+ * The scene both the screensaver (PrintsDream) and the card's slideshow (SlideshowActivity) show: the owner's+ * photos as three prints on a time-of-day sky, each the whole photo with rounded corners and its month and year+ * written on it, above a line with the time and the date. Every 15 seconds the three slide off to the left one+ * after another and three new ones are dealt in from the right, each at a slight tilt. With no photos it shows+ * where to put them. No network: nothing leaves the TV.+ */+final class Prints {++ private static final int PRINTS = 3;+ private static final long SHOW_MS = 15_000L;+ private static final long OUT_MS = 700L, OUT_STAGGER_MS = 120L;+ private static final long IN_MS = 800L, IN_STAGGER_MS = 180L;+ /** Decode size, in dp: a landscape photo's width, a portrait one's height. deal() then fits it to its column. */+ private static final int LANDSCAPE_W_DP = 300, PORTRAIT_H_DP = 320;+ /** Each print's resting tilt in degrees; the middle one lies on top. */+ private static final int[] TILT = {-5, 3, -2};+ /** The gap at the screen's left and right edges and at its top; between two prints; above the clock line. */+ private static final int SIDE_DP = 48, TOP_DP = 20, COLUMN_GAP_DP = 24, STRIP_GAP_DP = 4;+ /** Random play around the rest position, so no two sets lie the same way. */+ private static final int JITTER_DP = 14, JITTER_Y_DP = 6, JITTER_DEG = 2;+ /** The most any print tilts: the steepest TILT plus JITTER_DEG. */+ private static final int MAX_TILT_DEG = 7;+ /** How far the clock line may wander so it does not burn in: sideways, and up (the room above is the photos'). */+ private static final int NUDGE_DP = 20, NUDGE_UP_DP = 6;++ private final Context context;+ private final Handler handler = new Handler(Looper.getMainLooper());+ private final Random random = new Random();+ private final float density;+ private final int screenW;+ private final SkyView sky;+ private final View clock;+ private final View empty;+ private final View[] cards = new View[PRINTS];+ private final ImageView[] photoViews = new ImageView[PRINTS];+ private final TextView[] dateViews = new TextView[PRINTS];+ private ExecutorService loader;+ /** Loader thread only. */+ private final List<File> queue = new ArrayList<>();+ private boolean dealt;+ /** Bumped on stop, so a decode that finishes afterwards is dropped instead of shown. */+ private int generation;++ /** A photo ready for a print. */+ private static final class Print {+ Bitmap bitmap;+ String date;+ }++ private final Runnable next = this::loadNext;++ /** {@code root} is R.layout.prints, already inflated. */+ Prints(Context context, View root) {+ this.context = context;+ density = context.getResources().getDisplayMetrics().density;+ screenW = context.getResources().getDisplayMetrics().widthPixels;+ sky = root.findViewById(R.id.sky);+ clock = root.findViewById(R.id.clockLine);+ empty = root.findViewById(R.id.empty);+ ((TextView) root.findViewById(R.id.emptyPath)).setText(Photos.folder(context).getPath());+ ViewGroup stage = root.findViewById(R.id.stage);+ LayoutInflater inflater = LayoutInflater.from(context);+ for (int i = 0; i < PRINTS; i++) {+ cards[i] = inflater.inflate(R.layout.print, stage, false);+ // Drawn into a layer with a clear margin, the tilted print is filtered as one image: smooth edges.+ cards[i].setLayerType(View.LAYER_TYPE_HARDWARE, null);+ cards[i].findViewById(R.id.printCard).setClipToOutline(true); // the photo takes the rounded corners+ photoViews[i] = cards[i].findViewById(R.id.printPhoto);+ dateViews[i] = cards[i].findViewById(R.id.printDate);+ cards[i].setTranslationX(screenW * 2f); // off screen until the first deal+ stage.addView(cards[i]);+ }+ cards[1].bringToFront(); // the middle print lies on top of its neighbours+ }++ void start() {+ if (loader == null) loader = Executors.newSingleThreadExecutor();+ handler.post(next);+ }++ void stop() {+ generation++;+ handler.removeCallbacksAndMessages(null);+ }++ /** stop(), and the photos' memory freed now; the scene is not started again after this. */+ void release() {+ stop();+ if (loader != null) loader.shutdownNow();+ loader = null;+ for (ImageView v : photoViews) release(v);+ }++ private void loadNext() {+ int gen = generation;+ ExecutorService l = loader;+ if (l == null) return;+ l.execute(() -> {+ Print[] batch = new Print[PRINTS];+ for (int i = 0; i < PRINTS; i++) {+ try {+ batch[i] = nextPrint();+ } catch (OutOfMemoryError e) {+ batch[i] = null;+ }+ }+ handler.post(() -> {+ if (gen != generation) {+ for (Print p : batch) if (p != null && p.bitmap != null) p.bitmap.recycle();+ return;+ }+ sweep(batch);+ handler.postDelayed(next, SHOW_MS);+ });+ });+ }++ /** Loader thread only (it owns the queue): the next photo in a shuffled round, decoded near its print size. */+ private Print nextPrint() {+ for (int tries = 0; tries < 4; tries++) {+ if (queue.isEmpty()) {+ queue.addAll(Photos.list(context));+ Collections.shuffle(queue, random);+ }+ if (queue.isEmpty()) return null;+ File file = queue.remove(0);+ int[] size = Photos.size(file);+ if (size == null) continue;+ int w, h;+ if (size[1] > size[0]) {+ h = Math.round(PORTRAIT_H_DP * density);+ w = h * size[0] / size[1];+ } else {+ w = Math.round(LANDSCAPE_W_DP * density);+ h = w * size[1] / size[0];+ }+ Bitmap bitmap = Photos.decode(file, w, h);+ if (bitmap == null) continue;+ Print p = new Print();+ p.bitmap = bitmap;+ p.date = Photos.dateOf(file);+ return p;+ }+ return null;+ }++ /** Slides the prints on screen off to the left, one after another, then deals the new ones in from the right. */+ private void sweep(Print[] batch) {+ boolean none = true;+ for (Print p : batch) none &= p == null;+ empty.setVisibility(none ? View.VISIBLE : View.GONE);+ long dealAt = 0;+ if (dealt) {+ for (int i = 0; i < PRINTS; i++) {+ View card = cards[i];+ card.animate().translationX(-(screenW + card.getWidth() + 200f))+ .rotation(card.getRotation() - 12f)+ .setStartDelay(i * OUT_STAGGER_MS).setDuration(OUT_MS)+ .setInterpolator(new AccelerateInterpolator(1.6f)).start();+ }+ dealAt = OUT_MS + (PRINTS - 1) * OUT_STAGGER_MS + 60;+ }+ dealt = true;+ handler.postDelayed(() -> deal(batch), dealAt);+ nudgeClock();+ sky.update(); // a new colour at most once a minute; the sweep comes round every 15 seconds+ }++ /** The top of the clock line, px, less how far nudgeClock() can lift it. */+ private int stripTop() {+ int screenH = context.getResources().getDisplayMetrics().heightPixels;+ if (clock.getHeight() == 0) return screenH - Math.round(120 * density);+ return clock.getTop() - Math.round(NUDGE_UP_DP * density);+ }++ /**+ * Lays the set out in three equal columns above the clock line: each print is as large as its column allows,+ * tilted as far as it may be, and sits in the middle of it with a little play.+ */+ private void deal(Print[] batch) {+ float side = SIDE_DP * density, jitter = JITTER_DP * density, jitterY = JITTER_Y_DP * density;+ float colGap = COLUMN_GAP_DP * density;+ int shadowRoom = context.getResources().getDimensionPixelSize(R.dimen.print_shadow_room);+ float areaTop = TOP_DP * density, areaBottom = stripTop() - STRIP_GAP_DP * density;+ float colW = (screenW - 2 * side - (PRINTS - 1) * colGap) / PRINTS;+ // The box a tilted print must fit, leaving room for the play either way.+ float boxW = colW - 2 * jitter, boxH = areaBottom - areaTop - 2 * jitterY;+ double rad = Math.toRadians(MAX_TILT_DEG);+ float cos = (float) Math.cos(rad), sin = (float) Math.sin(rad);+ for (int i = 0; i < PRINTS; i++) {+ Print p = batch[i];+ View card = cards[i];+ ImageView photo = photoViews[i];+ release(photo);+ if (p == null) {+ card.setVisibility(View.INVISIBLE);+ continue;+ }+ // A photo h tall and a*h wide, tilted, spans a*h*cos + h*sin across and a*h*sin + h*cos down: the+ // largest h that fits both ways.+ float a = (float) p.bitmap.getWidth() / p.bitmap.getHeight();+ float h = Math.min(boxW / (a * cos + sin), boxH / (a * sin + cos));+ int ph = Math.max(1, Math.round(h)), pw = Math.max(1, Math.round(h * a));+ float cx = side + colW / 2f + i * (colW + colGap) + (random.nextFloat() * 2 - 1) * jitter;+ float cy = (areaTop + areaBottom) / 2f + (random.nextFloat() * 2 - 1) * jitterY;+ float tilt = TILT[i] + (random.nextFloat() * 2 - 1) * JITTER_DEG;+ card.setVisibility(View.VISIBLE);+ photo.setImageBitmap(p.bitmap);+ ViewGroup.LayoutParams lp = photo.getLayoutParams();+ lp.width = pw;+ lp.height = ph;+ photo.setLayoutParams(lp);+ dateViews[i].setText(p.date);+ dateViews[i].setVisibility(p.date.isEmpty() ? View.GONE : View.VISIBLE);+ // The caption's fade spans the photo: set outright, since a FrameLayout with one match_parent child+ // keeps that child's width from the last measure, the previous photo's.+ ViewGroup.LayoutParams dp = dateViews[i].getLayoutParams();+ dp.width = pw;+ dateViews[i].setLayoutParams(dp);+ FrameLayout.LayoutParams cp = (FrameLayout.LayoutParams) card.getLayoutParams();+ cp.leftMargin = Math.round(cx - pw / 2f) - shadowRoom;+ cp.topMargin = Math.round(cy - ph / 2f) - shadowRoom;+ card.setLayoutParams(cp);+ card.animate().cancel();+ card.setTranslationX(screenW + 200f);+ card.setRotation(tilt + 12f);+ card.animate().translationX(0f).rotation(tilt)+ .setStartDelay(i * IN_STAGGER_MS).setDuration(IN_MS)+ .setInterpolator(new DecelerateInterpolator(2f)).start();+ }+ clock.bringToFront();+ }++ private void nudgeClock() {+ float d = density * NUDGE_DP;+ clock.animate().translationX((random.nextFloat() * 2 - 1) * d)+ .translationY(random.nextFloat() * -NUDGE_UP_DP * density).setStartDelay(0).setDuration(1500).start();+ }++ /** Drops the view's photo and frees its pixels now rather than at the next GC. */+ private static void release(ImageView view) {+ Drawable d = view.getDrawable();+ view.setImageDrawable(null);+ if (d instanceof BitmapDrawable) {+ Bitmap b = ((BitmapDrawable) d).getBitmap();+ if (b != null && !b.isRecycled()) b.recycle();+ }+ }+}diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/PrintsDream.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/PrintsDream.javanew file mode 100644index 000000000..416bec82a--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/PrintsDream.java@@ -0,0 +1,37 @@+package io.github.shivamsingh262.photoprints;++import android.service.dreams.DreamService;++/** The screensaver: Prints, until any key wakes the TV back to where it was. */+public class PrintsDream extends DreamService {++ private Prints prints;++ @Override+ public void onAttachedToWindow() {+ super.onAttachedToWindow();+ setInteractive(false);+ setFullscreen(true);+ setScreenBright(false);+ setContentView(R.layout.prints);+ prints = new Prints(this, getWindow().getDecorView());+ }++ @Override+ public void onDreamingStarted() {+ super.onDreamingStarted();+ prints.start();+ }++ @Override+ public void onDreamingStopped() {+ prints.stop();+ super.onDreamingStopped();+ }++ @Override+ public void onDetachedFromWindow() {+ if (prints != null) prints.release();+ super.onDetachedFromWindow();+ }+}diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Sky.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Sky.javanew file mode 100644index 000000000..c3cf6829c--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/Sky.java@@ -0,0 +1,136 @@+package io.github.shivamsingh262.photoprints;++/**+ * Time-of-day sky palette, the same one the cleanyourtv launcher paints behind Home, so the screensaver looks like+ * part of it.+ *+ * Pure maths, no Android types and no clock of its own: the caller passes minutes since midnight. The colours are+ * interpolated between a handful of anchor points through the day, so the sky drifts from night to dawn to sunset+ * instead of switching at fixed hours. Every colour stays dark enough for white text on top.+ */+final class Sky {++ /** One anchor: a minute of the day and the values the palette takes exactly there. */+ static final class Stop {+ final int minute;+ final int top;+ final int mid;+ final int bottom;+ /** Alpha of the sun/moon glow near the horizon, 0 to 255. */+ final int sun;+ /** Horizontal position of the glow, 0 = left edge, 1 = right edge. */+ final float sunX;++ Stop(int minute, int top, int mid, int bottom, int sun, float sunX) {+ this.minute = minute;+ this.top = top;+ this.mid = mid;+ this.bottom = bottom;+ this.sun = sun;+ this.sunX = sunX;+ }+ }++ /** The palette at one instant: the three gradient colours plus the glow. */+ static final class Palette {+ final int top;+ final int mid;+ final int bottom;+ final int sun;+ final float sunX;++ Palette(int top, int mid, int bottom, int sun, float sunX) {+ this.top = top;+ this.mid = mid;+ this.bottom = bottom;+ this.sun = sun;+ this.sunX = sunX;+ }+ }++ private static final int NIGHT_TOP = 0xFF04060E;+ private static final int NIGHT_MID = 0xFF070C1A;+ private static final int NIGHT_BOTTOM = 0xFF0B1326;++ // Anchors were picked around a temperate evening: full night until half past five, dawn before+ // seven, the warmest glow between seven in the evening and a quarter to eight. With a location+ // set, at(minute, sunrise, sunset) stretches this reference day onto the real one.+ static final int REF_SUNRISE = 450;+ static final int REF_SUNSET = 1140;+ private static final Stop[] STOPS = {+ new Stop(0, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(320, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(390, 0xFF160F2E, 0xFF3B2352, 0xFF8A4A6B, 100, 0.24f),+ new Stop(450, 0xFF12203F, 0xFF5C3A63, 0xFFD3674F, 160, 0.30f),+ new Stop(570, 0xFF0E1A33, 0xFF1F3557, 0xFF43648B, 90, 0.38f),+ new Stop(780, 0xFF0B1524, 0xFF17304F, 0xFF31587F, 60, 0.50f),+ new Stop(1020, 0xFF0D1526, 0xFF20395C, 0xFF4C5470, 90, 0.62f),+ new Stop(1140, 0xFF1B1030, 0xFF6C2E52, 0xFFE2704A, 190, 0.76f),+ new Stop(1185, 0xFF140C27, 0xFF4A2049, 0xFFA54A5C, 130, 0.82f),+ new Stop(1260, 0xFF0A0A1C, 0xFF191230, 0xFF3A1F49, 60, 0.86f),+ new Stop(1350, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ new Stop(1440, NIGHT_TOP, NIGHT_MID, NIGHT_BOTTOM, 0, 0.30f),+ };++ private Sky() {+ }++ /**+ * The palette at {@code minuteOfDay} on a day whose sun rises at {@code sunrise} and sets at+ * {@code sunset} (minutes of the day): night, day and evening are each stretched piecewise so+ * the reference sunrise and sunset glows land on the real ones.+ */+ static Palette at(int minuteOfDay, int sunrise, int sunset) {+ if (sunrise <= 0 || sunset >= 1440 || sunrise >= sunset) return at(minuteOfDay);+ int m = Math.max(0, Math.min(1440, minuteOfDay));+ float ref;+ if (m < sunrise) ref = m * REF_SUNRISE / (float) sunrise;+ else if (m < sunset) ref = REF_SUNRISE + (m - sunrise) * (REF_SUNSET - REF_SUNRISE) / (float) (sunset - sunrise);+ else ref = REF_SUNSET + (m - sunset) * (1440 - REF_SUNSET) / (float) (1440 - sunset);+ return at(Math.round(ref));+ }++ /** The palette at {@code minuteOfDay}, clamped to a day. */+ static Palette at(int minuteOfDay) {+ int m = Math.max(0, Math.min(1440, minuteOfDay));+ Stop a = STOPS[0];+ Stop b = STOPS[STOPS.length - 1];+ for (int i = 0; i < STOPS.length - 1; i++) {+ if (m >= STOPS[i].minute && m <= STOPS[i + 1].minute) {+ a = STOPS[i];+ b = STOPS[i + 1];+ break;+ }+ }+ float t = b.minute == a.minute ? 0f : (m - a.minute) / (float) (b.minute - a.minute);+ return new Palette(+ lerpColor(a.top, b.top, t),+ lerpColor(a.mid, b.mid, t),+ lerpColor(a.bottom, b.bottom, t),+ lerp(a.sun, b.sun, t),+ lerp(a.sunX, b.sunX, t));+ }++ /** Minute of day, 0 to 1439, of a wall clock time. */+ static int minuteOfDay(int hour, int minute) {+ return Math.max(0, Math.min(23, hour)) * 60 + Math.max(0, Math.min(59, minute));+ }++ /** Blends two opaque ARGB colours channel by channel; {@code t} is 0 to 1. */+ static int lerpColor(int from, int to, float t) {+ float f = Math.max(0f, Math.min(1f, t));+ int a = Math.round(((from >>> 24) & 0xFF) + (((to >>> 24) & 0xFF) - ((from >>> 24) & 0xFF)) * f);+ int r = Math.round(((from >> 16) & 0xFF) + (((to >> 16) & 0xFF) - ((from >> 16) & 0xFF)) * f);+ int g = Math.round(((from >> 8) & 0xFF) + (((to >> 8) & 0xFF) - ((from >> 8) & 0xFF)) * f);+ int b = Math.round((from & 0xFF) + ((to & 0xFF) - (from & 0xFF)) * f);+ return (a << 24) | (r << 16) | (g << 8) | b;+ }++ private static int lerp(int from, int to, float t) {+ return Math.round(from + (to - from) * Math.max(0f, Math.min(1f, t)));+ }++ private static float lerp(float from, float to, float t) {+ return from + (to - from) * Math.max(0f, Math.min(1f, t));+ }+}diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SkyView.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SkyView.javanew file mode 100644index 000000000..5df1abe34--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SkyView.java@@ -0,0 +1,81 @@+package io.github.shivamsingh262.photoprints;++import android.content.Context;+import android.graphics.Bitmap;+import android.graphics.Canvas;+import android.graphics.LinearGradient;+import android.graphics.Paint;+import android.graphics.PorterDuff;+import android.graphics.RadialGradient;+import android.graphics.Shader;+import android.graphics.drawable.BitmapDrawable;+import android.util.AttributeSet;+import android.view.Gravity;+import android.view.View;++import java.util.Calendar;++/**+ * A full-screen gradient that follows the clock (Sky): night blues, a warm horizon at sunset, a soft glow where+ * the sun sits. One small bitmap (480x270) stretched over the screen and redrawn at most once a minute, so it+ * costs a single full-screen draw per minute on a weak TV GPU.+ */+public class SkyView extends View {++ private static final int TEX_W = 480, TEX_H = 270;++ private int lastMinute = -1;+ private Bitmap texture;++ public SkyView(Context context, AttributeSet attrs) {+ super(context, attrs);+ }++ @Override+ public boolean hasOverlappingRendering() {+ return false;+ }++ @Override+ protected void onAttachedToWindow() {+ super.onAttachedToWindow();+ update();+ }++ /** Picks up a new time of day; cheap and safe to call often. */+ public void update() {+ Calendar now = Calendar.getInstance();+ int minute = Sky.minuteOfDay(now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE));+ if (minute == lastMinute) return;+ lastMinute = minute;++ Sky.Palette sky = Sky.at(minute);+ boolean first = texture == null;+ if (first) texture = Bitmap.createBitmap(TEX_W, TEX_H, Bitmap.Config.ARGB_8888);+ Canvas canvas = new Canvas(texture);+ canvas.drawColor(0, PorterDuff.Mode.CLEAR);++ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);+ paint.setShader(new LinearGradient(0f, 0f, 0f, TEX_H,+ new int[]{sky.top, sky.mid, sky.bottom},+ new float[]{0f, 0.55f, 1f}, Shader.TileMode.CLAMP));+ canvas.drawRect(0f, 0f, TEX_W, TEX_H, paint);++ if (sky.sun > 0) {+ // A warm core low on the horizon, where the sun (or its afterglow) sits.+ int warm = Sky.lerpColor(sky.bottom, 0xFFFFD9A0, 0.65f);+ paint.setShader(new RadialGradient(+ sky.sunX * TEX_W, TEX_H * 0.80f, TEX_W * 0.55f,+ new int[]{(sky.sun << 24) | (warm & 0x00FFFFFF), warm & 0x00FFFFFF},+ new float[]{0f, 1f}, Shader.TileMode.CLAMP));+ canvas.drawRect(0f, 0f, TEX_W, TEX_H, paint);+ }++ if (first) {+ BitmapDrawable drawable = new BitmapDrawable(getResources(), texture);+ drawable.setGravity(Gravity.FILL);+ setBackground(drawable);+ }+ invalidate();+ }+}diff --git a/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SlideshowActivity.java b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SlideshowActivity.javanew file mode 100644index 000000000..8dae3740a--- /dev/null+++ b/addons/photo-screensaver/app/src/main/java/io/github/shivamsingh262/photoprints/SlideshowActivity.java@@ -0,0 +1,40 @@+package io.github.shivamsingh262.photoprints;++import android.app.Activity;+import android.os.Bundle;+import android.view.WindowManager;++/**+ * The app's tile and its module card on cleanyourtv's Home: the same scene as the screensaver, right away, until+ * Back. The screen stays on while it shows.+ */+public class SlideshowActivity extends Activity {++ private Prints prints;++ @Override+ protected void onCreate(Bundle savedInstanceState) {+ super.onCreate(savedInstanceState);+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);+ setContentView(R.layout.prints);+ prints = new Prints(this, getWindow().getDecorView());+ }++ @Override+ protected void onStart() {+ super.onStart();+ prints.start();+ }++ @Override+ protected void onStop() {+ prints.stop();+ super.onStop();+ }++ @Override+ protected void onDestroy() {+ prints.release();+ super.onDestroy();+ }+}diff --git a/addons/photo-screensaver/app/src/main/res/drawable/banner.xml b/addons/photo-screensaver/app/src/main/res/drawable/banner.xmlnew file mode 100644index 000000000..fa20c1913--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/drawable/banner.xml@@ -0,0 +1,27 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- The app's own art: three tilted prints on a night sky. 320x180, as Android TV banners are. -->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="320dp"+ android:height="180dp"+ android:viewportWidth="320"+ android:viewportHeight="180">+ <path android:pathData="M0,0h320v180h-320z">+ <aapt:attr xmlns:aapt="http://schemas.android.com/aapt" name="android:fillColor">+ <gradient android:type="linear" android:startX="0" android:startY="0" android:endX="0" android:endY="180"+ android:startColor="#FF0B1326" android:endColor="#FF3A2A4A" />+ </aapt:attr>+ </path>+ <group android:rotation="-8" android:pivotX="92" android:pivotY="90">+ <path android:fillColor="#FFE8A33D" android:pathData="M52,58h80v64h-80z" />+ <path android:fillColor="#33000000" android:pathData="M52,106h80v16h-80z" />+ </group>+ <group android:rotation="6" android:pivotX="228" android:pivotY="90">+ <path android:fillColor="#FF5B8DEF" android:pathData="M188,58h80v64h-80z" />+ <path android:fillColor="#33000000" android:pathData="M188,106h80v16h-80z" />+ </group>+ <group android:rotation="-2" android:pivotX="160" android:pivotY="86">+ <path android:fillColor="#FFF2F2F2" android:pathData="M116,46h88v80h-88z" />+ <path android:fillColor="#FF8FC9A0" android:pathData="M122,52h76v58h-76z" />+ <path android:fillColor="#FF4F8A63" android:pathData="M122,110l24,-26l18,18l12,-10l22,18z" />+ </group>+</vector>diff --git a/addons/photo-screensaver/app/src/main/res/drawable/icon.xml b/addons/photo-screensaver/app/src/main/res/drawable/icon.xmlnew file mode 100644index 000000000..982b26def--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/drawable/icon.xml@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- A single print, for places that show the app's icon rather than its banner. -->+<vector xmlns:android="http://schemas.android.com/apk/res/android"+ android:width="48dp"+ android:height="48dp"+ android:viewportWidth="48"+ android:viewportHeight="48">+ <path android:fillColor="#FF0B1326" android:pathData="M0,0h48v48h-48z" />+ <group android:rotation="-6" android:pivotX="24" android:pivotY="24">+ <path android:fillColor="#FFF2F2F2" android:pathData="M10,10h28v28h-28z" />+ <path android:fillColor="#FF8FC9A0" android:pathData="M12,12h24v18h-24z" />+ <path android:fillColor="#FF4F8A63" android:pathData="M12,30l8,-9l6,6l4,-3l6,6z" />+ </group>+</vector>diff --git a/addons/photo-screensaver/app/src/main/res/drawable/print_caption_fade.xml b/addons/photo-screensaver/app/src/main/res/drawable/print_caption_fade.xmlnew file mode 100644index 000000000..4e176423a--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/drawable/print_caption_fade.xml@@ -0,0 +1,8 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Clear at the top, dark at the foot of the photo, so the date reads on any picture. -->+<shape xmlns:android="http://schemas.android.com/apk/res/android">+ <gradient+ android:angle="270"+ android:startColor="#00000000"+ android:endColor="#99000000" />+</shape>diff --git a/addons/photo-screensaver/app/src/main/res/drawable/print_card.xml b/addons/photo-screensaver/app/src/main/res/drawable/print_card.xmlnew file mode 100644index 000000000..3d4b32266--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/drawable/print_card.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- The rounded outline each photo is clipped to, and that casts its shadow. -->+<shape xmlns:android="http://schemas.android.com/apk/res/android">+ <solid android:color="#FF101014" />+ <corners android:radius="16dp" />+</shape>diff --git a/addons/photo-screensaver/app/src/main/res/font/outfit.ttf b/addons/photo-screensaver/app/src/main/res/font/outfit.ttfnew file mode 100644index 000000000..466d6245fBinary files /dev/null and b/addons/photo-screensaver/app/src/main/res/font/outfit.ttf differdiff --git a/addons/photo-screensaver/app/src/main/res/font/outfit_extralight.xml b/addons/photo-screensaver/app/src/main/res/font/outfit_extralight.xmlnew file mode 100644index 000000000..397e29898--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/font/outfit_extralight.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Outfit at weight 200, built once per process. android:fontVariationSettings on each TextView rebuilt+ the variable font for every view (about 10 ms each on a TV CPU). Android 8 ignores the weight here, as+ it did on the views, and draws the default instance. -->+<font-family xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools">+ <font+ android:font="@font/outfit"+ android:fontStyle="normal"+ android:fontWeight="200"+ android:fontVariationSettings="'wght' 200"+ tools:targetApi="28" />+</font-family>diff --git a/addons/photo-screensaver/app/src/main/res/font/outfit_medium.xml b/addons/photo-screensaver/app/src/main/res/font/outfit_medium.xmlnew file mode 100644index 000000000..18d769913--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/font/outfit_medium.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Outfit at weight 500, built once per process. android:fontVariationSettings on each TextView rebuilt+ the variable font for every view (about 10 ms each on a TV CPU). Android 8 ignores the weight here, as+ it did on the views, and draws the default instance. -->+<font-family xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools">+ <font+ android:font="@font/outfit"+ android:fontStyle="normal"+ android:fontWeight="500"+ android:fontVariationSettings="'wght' 500"+ tools:targetApi="28" />+</font-family>diff --git a/addons/photo-screensaver/app/src/main/res/font/outfit_regular.xml b/addons/photo-screensaver/app/src/main/res/font/outfit_regular.xmlnew file mode 100644index 000000000..1550b02e6--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/font/outfit_regular.xml@@ -0,0 +1,13 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- Outfit at weight 400, built once per process. android:fontVariationSettings on each TextView rebuilt+ the variable font for every view (about 10 ms each on a TV CPU). Android 8 ignores the weight here, as+ it did on the views, and draws the default instance. -->+<font-family xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools">+ <font+ android:font="@font/outfit"+ android:fontStyle="normal"+ android:fontWeight="400"+ android:fontVariationSettings="'wght' 400"+ tools:targetApi="28" />+</font-family>diff --git a/addons/photo-screensaver/app/src/main/res/layout/print.xml b/addons/photo-screensaver/app/src/main/res/layout/print.xmlnew file mode 100644index 000000000..05fde4ff9--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/layout/print.xml@@ -0,0 +1,46 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- One print: the whole photo with rounded corners and a soft shadow, its month and year in white over a fade+ along its foot. Prints sizes the photo to its own shape, so nothing is cropped.+ The outer frame is a clear margin the photo and its shadow are drawn into as one hardware layer: tilted, the+ layer is filtered as a whole, so the edges come out smooth instead of stair-stepped. -->+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:padding="@dimen/print_shadow_room"+ android:clipToPadding="false"+ android:clipChildren="false">++ <FrameLayout+ android:id="@+id/printCard"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:background="@drawable/print_card"+ android:elevation="16dp">++ <ImageView+ android:id="@+id/printPhoto"+ android:layout_width="0dp"+ android:layout_height="0dp"+ android:scaleType="fitXY"+ android:importantForAccessibility="no" />++ <TextView+ android:id="@+id/printDate"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_gravity="bottom"+ android:background="@drawable/print_caption_fade"+ android:gravity="start|bottom"+ android:paddingStart="16dp"+ android:paddingEnd="16dp"+ android:paddingTop="32dp"+ android:paddingBottom="12dp"+ android:singleLine="true"+ android:textColor="#F2FFFFFF"+ android:textSize="16sp"+ android:fontFamily="@font/outfit_medium"+ android:letterSpacing="0.04"+ android:shadowColor="#80000000"+ android:shadowRadius="4" />+ </FrameLayout>+</FrameLayout>diff --git a/addons/photo-screensaver/app/src/main/res/layout/prints.xml b/addons/photo-screensaver/app/src/main/res/layout/prints.xmlnew file mode 100644index 000000000..adf572ec5--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/layout/prints.xml@@ -0,0 +1,105 @@+<?xml version="1.0" encoding="utf-8"?>+<!-- The scene (Prints): three photo prints on a time-of-day sky, swept off and dealt in by code, above a line with+ the time and the date. With no photos, where to put them. -->+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:background="#FF000000">++ <io.github.shivamsingh262.photoprints.SkyView+ android:id="@+id/sky"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:importantForAccessibility="no" />++ <FrameLayout+ android:id="@+id/stage"+ android:layout_width="match_parent"+ android:layout_height="match_parent"+ android:clipChildren="false" />++ <LinearLayout+ android:id="@+id/empty"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_gravity="center"+ android:layout_marginBottom="60dp"+ android:gravity="center_horizontal"+ android:orientation="vertical"+ android:visibility="gone">++ <TextView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:text="@string/empty_title"+ android:textColor="#F2FFFFFF"+ android:textSize="28sp"+ android:fontFamily="@font/outfit_regular" />++ <TextView+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_marginTop="12dp"+ android:text="@string/empty_body"+ android:textColor="#B3FFFFFF"+ android:textSize="16sp"+ android:fontFamily="@font/outfit_regular" />++ <TextView+ android:id="@+id/emptyPath"+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_marginTop="6dp"+ android:textColor="#B3FFFFFF"+ android:textSize="16sp"+ android:fontFamily="monospace" />+ </LinearLayout>++ <!-- One line along the bottom: the time and the date. Moved a little at each sweep so it does not burn in. -->+ <LinearLayout+ android:id="@+id/clockLine"+ android:layout_width="match_parent"+ android:layout_height="wrap_content"+ android:layout_gravity="bottom"+ android:layout_marginStart="72dp"+ android:layout_marginEnd="72dp"+ android:layout_marginBottom="40dp"+ android:orientation="horizontal"+ android:baselineAligned="true">++ <TextClock+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:format12Hour="h:mm"+ android:format24Hour="HH:mm"+ android:textColor="#F2FFFFFF"+ android:textSize="56sp"+ android:fontFamily="@font/outfit_extralight"+ android:letterSpacing="-0.04"+ android:includeFontPadding="false" />++ <TextClock+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_marginStart="6dp"+ android:format12Hour="a"+ android:format24Hour=""+ android:textColor="#B3FFFFFF"+ android:textSize="16sp"+ android:fontFamily="@font/outfit_medium"+ android:letterSpacing="0.08"+ android:textAllCaps="true" />++ <TextClock+ android:layout_width="wrap_content"+ android:layout_height="wrap_content"+ android:layout_marginStart="22dp"+ android:format12Hour="@string/date_format"+ android:format24Hour="@string/date_format"+ android:textColor="#B3FFFFFF"+ android:textSize="16sp"+ android:fontFamily="@font/outfit_regular"+ android:letterSpacing="0.14"+ android:textAllCaps="true" />+ </LinearLayout>+</FrameLayout>diff --git a/addons/photo-screensaver/app/src/main/res/values/dimens.xml b/addons/photo-screensaver/app/src/main/res/values/dimens.xmlnew file mode 100644index 000000000..4bcd74818--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/values/dimens.xml@@ -0,0 +1,5 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <!-- The clear margin around each print that its shadow is drawn into (print.xml). -->+ <dimen name="print_shadow_room">28dp</dimen>+</resources>diff --git a/addons/photo-screensaver/app/src/main/res/values/strings.xml b/addons/photo-screensaver/app/src/main/res/values/strings.xmlnew file mode 100644index 000000000..8afcaaa4b--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/values/strings.xml@@ -0,0 +1,8 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <string name="app_name">Photo Prints</string>+ <!-- The date on the clock line, as cleanyourtv's Home writes it. -->+ <string name="date_format">EEEE d MMMM</string>+ <string name="empty_title">No photos yet</string>+ <string name="empty_body">Copy photos to this folder on the TV with photos.sh or adb push:</string>+</resources>diff --git a/addons/photo-screensaver/app/src/main/res/values/themes.xml b/addons/photo-screensaver/app/src/main/res/values/themes.xmlnew file mode 100644index 000000000..55da2eb69--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/values/themes.xml@@ -0,0 +1,6 @@+<?xml version="1.0" encoding="utf-8"?>+<resources>+ <style name="Prints" parent="android:Theme.DeviceDefault.NoActionBar.Fullscreen">+ <item name="android:windowBackground">@android:color/black</item>+ </style>+</resources>diff --git a/addons/photo-screensaver/app/src/main/res/xml/module_card.xml b/addons/photo-screensaver/app/src/main/res/xml/module_card.xmlnew file mode 100644index 000000000..1b8d80614--- /dev/null+++ b/addons/photo-screensaver/app/src/main/res/xml/module_card.xml@@ -0,0 +1,2 @@+<?xml version="1.0" encoding="utf-8"?>+<card spec="1" label="Photo Prints" caption="Your photos" accent="#E8A33D" />diff --git a/addons/photo-screensaver/app/src/test/java/io/github/shivamsingh262/photoprints/PhotosTest.java b/addons/photo-screensaver/app/src/test/java/io/github/shivamsingh262/photoprints/PhotosTest.javanew file mode 100644index 000000000..07d4e7d65--- /dev/null+++ b/addons/photo-screensaver/app/src/test/java/io/github/shivamsingh262/photoprints/PhotosTest.java@@ -0,0 +1,38 @@+package io.github.shivamsingh262.photoprints;++import org.junit.Test;++import static org.junit.Assert.assertArrayEquals;+import static org.junit.Assert.assertFalse;+import static org.junit.Assert.assertNull;+import static org.junit.Assert.assertTrue;++/** The date photos.sh writes into a name, and which files count as photos. */+public class PhotosTest {++ @Test+ public void theDateInTheName() {+ assertArrayEquals(new int[]{2023, 12}, Photos.dateFromName("photo-0007-20231202.jpg"));+ assertArrayEquals(new int[]{2023, 12}, Photos.dateFromName("photo-0007-202312.jpg"));+ assertArrayEquals(new int[]{2026, 1}, Photos.dateFromName("photo-0001-20260110.JPEG"));+ }++ @Test+ public void noDateOrNoSuchMonth() {+ assertNull(Photos.dateFromName("photo-0007.jpg"));+ assertNull(Photos.dateFromName("holiday.jpg"));+ assertNull(Photos.dateFromName("photo-0007-20231302.jpg"));+ assertNull(Photos.dateFromName("photo-0007-18991202.jpg"));+ }++ @Test+ public void onlyImagesCount() {+ assertTrue(Photos.isImage("photo-0001-20231202.jpg"));+ assertTrue(Photos.isImage("Beach day.webp"));+ assertTrue(Photos.isImage("scan.PNG"));+ assertFalse(Photos.isImage(".hidden.jpg"));+ assertFalse(Photos.isImage("notes.txt"));+ assertFalse(Photos.isImage("clip.mp4"));+ assertFalse(Photos.isImage(null));+ }+}diff --git a/addons/photo-screensaver/build.gradle b/addons/photo-screensaver/build.gradlenew file mode 100644index 000000000..48978475f--- /dev/null+++ b/addons/photo-screensaver/build.gradle@@ -0,0 +1,3 @@+plugins {+ id 'com.android.application' version '8.5.2' apply false+}diff --git a/addons/photo-screensaver/gradle.properties b/addons/photo-screensaver/gradle.propertiesnew file mode 100644index 000000000..18825f968--- /dev/null+++ b/addons/photo-screensaver/gradle.properties@@ -0,0 +1,3 @@+org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8+android.useAndroidX=true+android.nonTransitiveRClass=truediff --git a/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.jar b/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.jarnew file mode 100644index 000000000..2c3521197Binary files /dev/null and b/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.jar differdiff --git a/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.properties b/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.propertiesnew file mode 100644index 000000000..77f5d0ba6--- /dev/null+++ b/addons/photo-screensaver/gradle/wrapper/gradle-wrapper.properties@@ -0,0 +1,8 @@+distributionBase=GRADLE_USER_HOME+distributionPath=wrapper/dists+distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip+distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab+networkTimeout=10000+validateDistributionUrl=true+zipStoreBase=GRADLE_USER_HOME+zipStorePath=wrapper/distsdiff --git a/addons/photo-screensaver/gradlew b/addons/photo-screensaver/gradlewnew file mode 100755index 000000000..f5feea6d6--- /dev/null+++ b/addons/photo-screensaver/gradlew@@ -0,0 +1,252 @@+#!/bin/sh++#+# Copyright © 2015-2021 the original authors.+#+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# https://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+#+# SPDX-License-Identifier: Apache-2.0+#++##############################################################################+#+# Gradle start up script for POSIX generated by Gradle.+#+# Important for running:+#+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is+# noncompliant, but you have some other compliant shell such as ksh or+# bash, then to run this script, type that shell name before the whole+# command line, like:+#+# ksh Gradle+#+# Busybox and similar reduced shells will NOT work, because this script+# requires all of these POSIX shell features:+# * functions;+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;+# * compound commands having a testable exit status, especially «case»;+# * various built-in commands including «command», «set», and «ulimit».+#+# Important for patching:+#+# (2) This script targets any POSIX shell, so it avoids extensions provided+# by Bash, Ksh, etc; in particular arrays are avoided.+#+# The "traditional" practice of packing multiple parameters into a+# space-separated string is a well documented source of bugs and security+# problems, so this is (mostly) avoided, by progressively accumulating+# options in "$@", and eventually passing that to Java.+#+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;+# see the in-line comments for details.+#+# There are tweaks for specific operating systems such as AIX, CygWin,+# Darwin, MinGW, and NonStop.+#+# (3) This script is generated from the Groovy template+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt+# within the Gradle project.+#+# You can find Gradle at https://github.com/gradle/gradle/.+#+##############################################################################++# Attempt to set APP_HOME++# Resolve links: $0 may be a link+app_path=$0++# Need this for daisy-chained symlinks.+while+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path+ [ -h "$app_path" ]+do+ ls=$( ls -ld "$app_path" )+ link=${ls#*' -> '}+ case $link in #(+ /*) app_path=$link ;; #(+ *) app_path=$APP_HOME$link ;;+ esac+done++# This is normally unused+# shellcheck disable=SC2034+APP_BASE_NAME=${0##*/}+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s+' "$PWD" ) || exit++# Use the maximum available, or set MAX_FD != -1 to use that value.+MAX_FD=maximum++warn () {+ echo "$*"+} >&2++die () {+ echo+ echo "$*"+ echo+ exit 1+} >&2++# OS specific support (must be 'true' or 'false').+cygwin=false+msys=false+darwin=false+nonstop=false+case "$( uname )" in #(+ CYGWIN* ) cygwin=true ;; #(+ Darwin* ) darwin=true ;; #(+ MSYS* | MINGW* ) msys=true ;; #(+ NONSTOP* ) nonstop=true ;;+esac++CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar+++# Determine the Java command to use to start the JVM.+if [ -n "$JAVA_HOME" ] ; then+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then+ # IBM's JDK on AIX uses strange locations for the executables+ JAVACMD=$JAVA_HOME/jre/sh/java+ else+ JAVACMD=$JAVA_HOME/bin/java+ fi+ if [ ! -x "$JAVACMD" ] ; then+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+ fi+else+ JAVACMD=java+ if ! command -v java >/dev/null 2>&1+ then+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.++Please set the JAVA_HOME variable in your environment to match the+location of your Java installation."+ fi+fi++# Increase the maximum file descriptors if we can.+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then+ case $MAX_FD in #(+ max*)+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.+ # shellcheck disable=SC2039,SC3045+ MAX_FD=$( ulimit -H -n ) ||+ warn "Could not query maximum file descriptor limit"+ esac+ case $MAX_FD in #(+ '' | soft) :;; #(+ *)+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.+ # shellcheck disable=SC2039,SC3045+ ulimit -n "$MAX_FD" ||+ warn "Could not set maximum file descriptor limit to $MAX_FD"+ esac+fi++# Collect all arguments for the java command, stacking in reverse order:+# * args from the command line+# * the main class name+# * -classpath+# * -D...appname settings+# * --module-path (only if needed)+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.++# For Cygwin or MSYS, switch paths to Windows format before running java+if "$cygwin" || "$msys" ; then+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )++ JAVACMD=$( cygpath --unix "$JAVACMD" )++ # Now convert the arguments - kludge to limit ourselves to /bin/sh+ for arg do+ if+ case $arg in #(+ -*) false ;; # don't mess with options #(+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath+ [ -e "$t" ] ;; #(+ *) false ;;+ esac+ then+ arg=$( cygpath --path --ignore --mixed "$arg" )+ fi+ # Roll the args list around exactly as many times as the number of+ # args, so each arg winds up back in the position where it started, but+ # possibly modified.+ #+ # NB: a `for` loop captures its iteration list before it begins, so+ # changing the positional parameters here affects neither the number of+ # iterations, nor the values presented in `arg`.+ shift # remove old arg+ set -- "$@" "$arg" # push replacement arg+ done+fi+++# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'++# Collect all arguments for the java command:+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,+# and any embedded shellness will be escaped.+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be+# treated as '${Hostname}' itself on the command line.++set -- \+ "-Dorg.gradle.appname=$APP_BASE_NAME" \+ -classpath "$CLASSPATH" \+ org.gradle.wrapper.GradleWrapperMain \+ "$@"++# Stop when "xargs" is not available.+if ! command -v xargs >/dev/null 2>&1+then+ die "xargs is not available"+fi++# Use "xargs" to parse quoted args.+#+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.+#+# In Bash we could simply go:+#+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&+# set -- "${ARGS[@]}" "$@"+#+# but POSIX shell has neither arrays nor command substitution, so instead we+# post-process each arg (as a line of input to sed) to backslash-escape any+# character that might be a shell metacharacter, then use eval to reverse+# that process (while maintaining the separation between arguments), and wrap+# the whole thing up as a single "set" statement.+#+# This will of course break if any of these variables contains a newline or+# an unmatched quote.+#++eval "set -- $(+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |+ xargs -n1 |+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |+ tr '\n' ' '+ )" '"$@"'++exec "$JAVACMD" "$@"diff --git a/addons/photo-screensaver/gradlew.bat b/addons/photo-screensaver/gradlew.batnew file mode 100644index 000000000..9d21a2183--- /dev/null+++ b/addons/photo-screensaver/gradlew.bat@@ -0,0 +1,94 @@+@rem+@rem Copyright 2015 the original author or authors.+@rem+@rem Licensed under the Apache License, Version 2.0 (the "License");+@rem you may not use this file except in compliance with the License.+@rem You may obtain a copy of the License at+@rem+@rem https://www.apache.org/licenses/LICENSE-2.0+@rem+@rem Unless required by applicable law or agreed to in writing, software+@rem distributed under the License is distributed on an "AS IS" BASIS,+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+@rem See the License for the specific language governing permissions and+@rem limitations under the License.+@rem+@rem SPDX-License-Identifier: Apache-2.0+@rem++@if "%DEBUG%"=="" @echo off+@rem ##########################################################################+@rem+@rem Gradle startup script for Windows+@rem+@rem ##########################################################################++@rem Set local scope for the variables with windows NT shell+if "%OS%"=="Windows_NT" setlocal++set DIRNAME=%~dp0+if "%DIRNAME%"=="" set DIRNAME=.+@rem This is normally unused+set APP_BASE_NAME=%~n0+set APP_HOME=%DIRNAME%++@rem Resolve any "." and ".." in APP_HOME to make it shorter.+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi++@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"++@rem Find java.exe+if defined JAVA_HOME goto findJavaFromJavaHome++set JAVA_EXE=java.exe+%JAVA_EXE% -version >NUL 2>&1+if %ERRORLEVEL% equ 0 goto execute++echo. 1>&2+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2+echo. 1>&2+echo Please set the JAVA_HOME variable in your environment to match the 1>&2+echo location of your Java installation. 1>&2++goto fail++:findJavaFromJavaHome+set JAVA_HOME=%JAVA_HOME:"=%+set JAVA_EXE=%JAVA_HOME%/bin/java.exe++if exist "%JAVA_EXE%" goto execute++echo. 1>&2+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2+echo. 1>&2+echo Please set the JAVA_HOME variable in your environment to match the 1>&2+echo location of your Java installation. 1>&2++goto fail++:execute+@rem Setup the command line++set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar+++@rem Execute Gradle+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*++:end+@rem End local scope for the variables with windows NT shell+if %ERRORLEVEL% equ 0 goto mainEnd++:fail+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of+rem the _cmd.exe /c_ return code!+set EXIT_CODE=%ERRORLEVEL%+if %EXIT_CODE% equ 0 set EXIT_CODE=1+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%+exit /b %EXIT_CODE%++:mainEnd+if "%OS%"=="Windows_NT" endlocal++:omegadiff --git a/addons/photo-screensaver/photos.sh b/addons/photo-screensaver/photos.shnew file mode 100755index 000000000..b2ac1b7d4--- /dev/null+++ b/addons/photo-screensaver/photos.sh@@ -0,0 +1,62 @@+#!/usr/bin/env bash+# Put a folder of photos on the TV for Photo Prints. Replaces the photos already there.+# Each photo is converted to a JPEG no larger than 1280 px on its long edge first (sips, macOS), so HEIC from an+# iPhone works and the TV decodes a 200 KB file instead of a 5 MB one; a print is about 400 px on the screen, so+# nothing shows the difference. The date the photo was taken goes into the file name, and the print shows its+# month and year. Nothing is uploaded anywhere else: the files go straight to the app's own folder on the TV.+#+# Uses the repo's tools/tv.py and tools/b64push.py (set up as in the main README: tools/venv).+# Usage: TV_HOST=192.168.1.50 addons/photo-screensaver/photos.sh ~/Pictures/TV+# TV_HOST=192.168.1.50 addons/photo-screensaver/photos.sh --clear+set -euo pipefail+SRC="${1:-}"+case "$SRC" in --clear|"") ;; /*) ;; *) SRC="$(pwd)/$SRC" ;; esac+cd "$(dirname "$0")/../../tools"+: "${TV_HOST:?set TV_HOST to the TV IP address, e.g. TV_HOST=192.168.1.50 $0 ~/Pictures/TV}"+PY=venv/bin/python+[ -x "$PY" ] || { echo "run: python3 -m venv tools/venv && tools/venv/bin/pip install -r tools/requirements.txt" >&2; exit 1; }+DIR=/sdcard/Android/data/io.github.shivamsingh262.photoprints/files/photos+tv() { "$PY" -I tv.py "$@"; }++if [ "$SRC" = --clear ]; then+ tv "rm -rf $DIR; echo cleared"+ exit 0+fi+[ -d "${SRC:?usage: photos.sh <folder> | --clear}" ] || { echo "not a folder: $SRC" >&2; exit 1; }+command -v sips >/dev/null || { echo "sips not found: this script converts photos with macOS's sips" >&2; exit 1; }++WORK="$(mktemp -d)"+trap 'rm -rf "$WORK"' EXIT+N=0+while IFS= read -r -d '' FILE; do+ N=$((N + 1))+ # The day the photo was taken, from a date in the file name (20231202_092230.jpg, IMG-20260110-WA0025.jpg),+ # else from when the camera says it was taken. None found: the print shows no date.+ YMD=""+ if [[ "$(basename "$FILE")" =~ (20[0-9]{2})(0[1-9]|1[0-2])([0-3][0-9]) ]]; then+ YMD="-${BASH_REMATCH[1]}${BASH_REMATCH[2]}${BASH_REMATCH[3]}"+ else+ TAKEN="$(sips -g creation "$FILE" 2>/dev/null | awk '/creation:/{print $2}')"+ if [[ "$TAKEN" =~ ^([0-9]{4}):([0-9]{2}):([0-9]{2}) ]]; then+ YMD="-${BASH_REMATCH[1]}${BASH_REMATCH[2]}${BASH_REMATCH[3]}"+ fi+ fi+ OUT="$WORK/$(printf 'photo-%04d' "$N")$YMD.jpg"+ # -Z keeps the aspect ratio; the EXIF orientation tag is kept, and the app turns the photo upright.+ if ! sips -s format jpeg -s formatOptions 85 -Z 1280 "$FILE" --out "$OUT" >/dev/null 2>&1; then+ echo "skipped (not a photo sips can read): $FILE" >&2+ N=$((N - 1))+ fi+done < <(find "$SRC" -maxdepth 1 -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \+ -o -iname '*.heic' -o -iname '*.webp' \) -print0 | sort -z)+[ "$N" -gt 0 ] || { echo "no photos (jpg, jpeg, png, heic, webp) in $SRC" >&2; exit 1; }++tv "rm -rf $DIR; mkdir -p $DIR" >/dev/null+I=0+for OUT in "$WORK"/photo-*.jpg; do+ I=$((I + 1))+ printf '\r%d/%d %s' "$I" "$N" "$(basename "$OUT")"+ "$PY" -I b64push.py "$OUT" "$DIR/$(basename "$OUT")" >/dev/null+done+echo+echo "$N photos on the TV. Photo Prints picks them up at its next sweep."diff --git a/addons/photo-screensaver/settings.gradle b/addons/photo-screensaver/settings.gradlenew file mode 100644index 000000000..5c8e0d956--- /dev/null+++ b/addons/photo-screensaver/settings.gradle@@ -0,0 +1,16 @@+pluginManagement {+ repositories {+ google()+ mavenCentral()+ gradlePluginPortal()+ }+}+dependencyResolutionManagement {+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)+ repositories {+ google()+ mavenCentral()+ }+}+rootProject.name = "photo-screensaver"+include ':app'