diff --git a/addons/weatherline/.gitignore b/addons/weatherline/.gitignore
new file mode 100644
index 0000000000..a7e04a21b3
--- /dev/null
+++ b/addons/weatherline/.gitignore
@@ -0,0 +1,4 @@
+.gradle/
+build/
+app/build/
+local.properties
diff --git a/addons/weatherline/app/build.gradle b/addons/weatherline/app/build.gradle
new file mode 100644
index 0000000000..05ed1c867c
--- /dev/null
+++ b/addons/weatherline/app/build.gradle
@@ -0,0 +1,29 @@
+plugins {
+ id 'com.android.application'
+}
+
+android {
+ namespace 'io.github.sumyabazar1.weatherline'
+ compileSdk 34
+
+ defaultConfig {
+ applicationId 'io.github.sumyabazar1.weatherline'
+ minSdk 26
+ targetSdk 34
+ versionCode 1
+ versionName '1.0'
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ // Sideloaded over ADB like the launcher: signed with the debug key.
+ signingConfig signingConfigs.debug
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_17
+ targetCompatibility JavaVersion.VERSION_17
+ }
+}
diff --git a/addons/weatherline/app/src/main/AndroidManifest.xml b/addons/weatherline/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..93ba9cf762
--- /dev/null
+++ b/addons/weatherline/app/src/main/AndroidManifest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/BootReceiver.java b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/BootReceiver.java
new file mode 100644
index 0000000000..6202ae07d4
--- /dev/null
+++ b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/BootReceiver.java
@@ -0,0 +1,14 @@
+package io.github.sumyabazar1.weatherline;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+/** A periodic job is dropped by a power cut on some firmware: put it back at boot. */
+public final class BootReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ WeatherRefreshJob.schedule(context);
+ }
+}
diff --git a/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/OpenMeteo.java b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/OpenMeteo.java
new file mode 100644
index 0000000000..519b7a41c4
--- /dev/null
+++ b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/OpenMeteo.java
@@ -0,0 +1,60 @@
+package io.github.sumyabazar1.weatherline;
+
+import org.json.JSONObject;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
+/** One call to Open-Meteo for the place in strings.xml, reduced to the text the launcher shows. */
+final class OpenMeteo {
+
+ private OpenMeteo() {
+ }
+
+ /** "Brisbane 21° Partly cloudy", or null when the request or the answer is unusable. */
+ static String fetch(String place, String lat, String lon, String timezone) {
+ HttpURLConnection c = null;
+ try {
+ String url = "https://api.open-meteo.com/v1/forecast"
+ + "?latitude=" + lat + "&longitude=" + lon
+ + "¤t=temperature_2m,weather_code&timezone=" + timezone;
+ c = (HttpURLConnection) new URL(url).openConnection();
+ c.setConnectTimeout(10000);
+ c.setReadTimeout(10000);
+ c.setRequestProperty("Accept", "application/json");
+ if (c.getResponseCode() != 200) return null;
+ try (InputStream in = c.getInputStream()) {
+ byte[] buf = new byte[4096];
+ StringBuilder sb = new StringBuilder();
+ int n;
+ while ((n = in.read(buf)) > 0) sb.append(new String(buf, 0, n, StandardCharsets.UTF_8));
+ JSONObject current = new JSONObject(sb.toString()).getJSONObject("current");
+ double temp = current.getDouble("temperature_2m");
+ int code = current.getInt("weather_code");
+ return place + " " + Math.round(temp) + "° " + describe(code);
+ }
+ } catch (Exception e) {
+ return null;
+ } finally {
+ if (c != null) c.disconnect();
+ }
+ }
+
+ /** WMO weather code to a short phrase, as Open-Meteo documents them. */
+ private static String describe(int code) {
+ if (code == 0) return "Clear";
+ if (code == 1) return "Mostly clear";
+ if (code == 2) return "Partly cloudy";
+ if (code == 3) return "Overcast";
+ if (code == 45 || code == 48) return "Fog";
+ if (code >= 51 && code <= 57) return "Drizzle";
+ if (code >= 61 && code <= 67) return "Rain";
+ if (code >= 71 && code <= 77) return "Snow";
+ if (code >= 80 && code <= 82) return "Showers";
+ if (code == 85 || code == 86) return "Snow showers";
+ if (code >= 95) return "Storms";
+ return "";
+ }
+}
diff --git a/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherCache.java b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherCache.java
new file mode 100644
index 0000000000..44d32319e8
--- /dev/null
+++ b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherCache.java
@@ -0,0 +1,39 @@
+package io.github.sumyabazar1.weatherline;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+/**
+ * The last reading, kept on disk so the line is on screen the moment Home comes back.
+ *
+ * A TV that has never had a network shows the placeholder until the first successful fetch.
+ */
+final class WeatherCache {
+
+ private static final String PREFS = "weather-line";
+ private static final String KEY_LINE = "line";
+ private static final String KEY_AT = "at";
+ /** 30 minutes: Open-Meteo's own model updates about that often, and the launcher polls every 15. */
+ static final long FRESH_MS = 30 * 60 * 1000L;
+
+ private WeatherCache() {
+ }
+
+ private static SharedPreferences prefs(Context ctx) {
+ return ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
+ }
+
+ static String line(Context ctx) {
+ return prefs(ctx).getString(KEY_LINE, "");
+ }
+
+ static boolean isFresh(Context ctx) {
+ long at = prefs(ctx).getLong(KEY_AT, 0L);
+ return at > 0 && System.currentTimeMillis() - at < FRESH_MS;
+ }
+
+ static void save(Context ctx, String line) {
+ prefs(ctx).edit().putString(KEY_LINE, line)
+ .putLong(KEY_AT, System.currentTimeMillis()).apply();
+ }
+}
diff --git a/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherProvider.java b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherProvider.java
new file mode 100644
index 0000000000..d4be751a82
--- /dev/null
+++ b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherProvider.java
@@ -0,0 +1,57 @@
+package io.github.sumyabazar1.weatherline;
+
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.net.Uri;
+
+/**
+ * content://io.github.sumyabazar1.weatherline/today, one row with a "line" column.
+ *
+ * It never goes online itself: the answer is the cached reading, returned at once, and a stale cache
+ * starts a background refresh for the next read. That keeps the launcher's first frame fast and lets the
+ * line survive a reboot before the network is back.
+ */
+public final class WeatherProvider extends ContentProvider {
+
+ static final String AUTHORITY = "io.github.sumyabazar1.weatherline";
+ private static final String[] COLUMNS = {"line"};
+
+ @Override
+ public boolean onCreate() {
+ WeatherRefreshJob.schedule(getContext());
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ Context ctx = getContext();
+ MatrixCursor cursor = new MatrixCursor(COLUMNS, 1);
+ String line = ctx == null ? "" : WeatherCache.line(ctx);
+ cursor.addRow(new Object[]{line == null ? "" : line});
+ if (ctx != null && !WeatherCache.isFresh(ctx)) WeatherRefreshJob.runNow(ctx);
+ return cursor;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return "vnd.android.cursor.item/weather-line";
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherRefreshJob.java b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherRefreshJob.java
new file mode 100644
index 0000000000..f5aea5d6c6
--- /dev/null
+++ b/addons/weatherline/app/src/main/java/io/github/sumyabazar1/weatherline/WeatherRefreshJob.java
@@ -0,0 +1,78 @@
+package io.github.sumyabazar1.weatherline;
+
+import android.app.job.JobInfo;
+import android.app.job.JobParameters;
+import android.app.job.JobScheduler;
+import android.app.job.JobService;
+import android.content.ComponentName;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.Network;
+import android.net.NetworkCapabilities;
+import android.os.AsyncTask;
+
+/** Fetches the forecast in the background, and only when there is a network to fetch it over. */
+public final class WeatherRefreshJob extends JobService {
+
+ private static final int JOB_ID = 4711;
+
+ static void schedule(Context ctx) {
+ JobScheduler js = ctx.getSystemService(JobScheduler.class);
+ if (js == null) return;
+ JobInfo job = new JobInfo.Builder(JOB_ID, new ComponentName(ctx, WeatherRefreshJob.class))
+ .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
+ .setPeriodic(30 * 60 * 1000L)
+ .setPersisted(true)
+ .build();
+ js.schedule(job);
+ }
+
+ /** One refresh now, for a cache the provider found stale. Cheap enough to run on any query. */
+ static void runNow(Context ctx) {
+ JobScheduler js = ctx.getSystemService(JobScheduler.class);
+ if (js == null) return;
+ JobInfo job = new JobInfo.Builder(JOB_ID + 1, new ComponentName(ctx, WeatherRefreshJob.class))
+ .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
+ .setOverrideDeadline(0)
+ .build();
+ js.schedule(job);
+ }
+
+ @Override
+ public boolean onStartJob(JobParameters params) {
+ Context ctx = getApplicationContext();
+ if (!online(ctx)) {
+ return false; // the job's network requirement normally prevents this
+ }
+ new AsyncTask() {
+ @Override
+ protected String doInBackground(Void... voids) {
+ return OpenMeteo.fetch(ctx.getString(R.string.place),
+ ctx.getString(R.string.latitude),
+ ctx.getString(R.string.longitude),
+ ctx.getString(R.string.timezone));
+ }
+
+ @Override
+ protected void onPostExecute(String line) {
+ if (line != null && !line.isEmpty()) WeatherCache.save(ctx, line);
+ jobFinished(params, false);
+ }
+ }.execute();
+ return true;
+ }
+
+ @Override
+ public boolean onStopJob(JobParameters params) {
+ return false;
+ }
+
+ private static boolean online(Context ctx) {
+ ConnectivityManager cm = ctx.getSystemService(ConnectivityManager.class);
+ if (cm == null) return false;
+ Network n = cm.getActiveNetwork();
+ if (n == null) return false;
+ NetworkCapabilities caps = cm.getNetworkCapabilities(n);
+ return caps != null && caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
+ }
+}
diff --git a/addons/weatherline/app/src/main/res/values/strings.xml b/addons/weatherline/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..a8ed53601e
--- /dev/null
+++ b/addons/weatherline/app/src/main/res/values/strings.xml
@@ -0,0 +1,10 @@
+
+
+ Weather line
+
+
+ Brisbane
+ -27.4698
+ 153.0251
+ Australia/Brisbane
+
diff --git a/addons/weatherline/build.gradle b/addons/weatherline/build.gradle
new file mode 100644
index 0000000000..48978475f3
--- /dev/null
+++ b/addons/weatherline/build.gradle
@@ -0,0 +1,3 @@
+plugins {
+ id 'com.android.application' version '8.5.2' apply false
+}
diff --git a/addons/weatherline/gradle.properties b/addons/weatherline/gradle.properties
new file mode 100644
index 0000000000..1edaf2baa4
--- /dev/null
+++ b/addons/weatherline/gradle.properties
@@ -0,0 +1 @@
+org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
diff --git a/addons/weatherline/gradle/wrapper/gradle-wrapper.jar b/addons/weatherline/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..2c3521197d
Binary files /dev/null and b/addons/weatherline/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/addons/weatherline/gradle/wrapper/gradle-wrapper.properties b/addons/weatherline/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..77f5d0ba6c
--- /dev/null
+++ b/addons/weatherline/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/dists
diff --git a/addons/weatherline/gradlew b/addons/weatherline/gradlew
new file mode 100755
index 0000000000..f5feea6d6b
--- /dev/null
+++ b/addons/weatherline/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/weatherline/gradlew.bat b/addons/weatherline/gradlew.bat
new file mode 100644
index 0000000000..9d21a21834
--- /dev/null
+++ b/addons/weatherline/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
+
+:omega
diff --git a/addons/weatherline/settings.gradle b/addons/weatherline/settings.gradle
new file mode 100644
index 0000000000..66c6986524
--- /dev/null
+++ b/addons/weatherline/settings.gradle
@@ -0,0 +1,16 @@
+pluginManagement {
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+}
+dependencyResolutionManagement {
+ repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+rootProject.name = "weatherline"
+include ':app'
diff --git a/launcher/app/src/main/AndroidManifest.xml b/launcher/app/src/main/AndroidManifest.xml
index ca18afa966..8627a5a8d3 100644
--- a/launcher/app/src/main/AndroidManifest.xml
+++ b/launcher/app/src/main/AndroidManifest.xml
@@ -8,6 +8,8 @@
+
+
+
+
@@ -138,7 +142,7 @@
android:launchMode="singleTop"
android:excludeFromRecents="true"
android:noHistory="true"
- android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
+ android:theme="@style/Theme.TvHome.Panel" />
> moods;
- private String latitude, longitude;
+ /** The place for the glow's sunrise and sunset, and the weather helper, both from useHomeWallpaper's config load. */
+ private String latitude = "", longitude = "", weatherProvider = "";
private final Runnable tick = new Runnable() {
@Override
@@ -74,15 +84,18 @@ public void run() {
/** root is the inflated dream_clock layout. */
ClockScene(View root) {
+ this.root = root;
content = root.findViewById(R.id.dreamContent);
ambient = root.findViewById(R.id.dreamAmbient);
glow = new GradientDrawable();
glow.setGradientType(GradientDrawable.RADIAL_GRADIENT);
ambient.setBackground(glow);
ambient.addOnLayoutChangeListener((v, l, t, r, b, ol, ot, or, ob) ->
- glow.setGradientRadius((r - l) * 0.55f));
+ glow.setGradientRadius((r - l) * 0.85f)); // a wide, soft light rather than a spotlight
colorIndex = random.nextInt(PALETTE.length);
- setGlow(PALETTE[colorIndex]);
+ // No colour yet: with a weather provider the first reading sets one (a reading is async, so painting the
+ // palette here made the glow start bright and then jump to the weather colour). Without one, start() paints
+ // the palette below.
}
void start() {
@@ -94,14 +107,53 @@ void start() {
handler.removeCallbacks(tick);
handler.postDelayed(tick, MOVE_MS);
if (wallpaperFile != null && !wallpaperShown) loadWallpaper();
+ startWeather();
+ // No provider (or no view to fill): the scene keeps its own palette, as before.
+ if (weather == null) setGlow(PALETTE[colorIndex]);
}
void stop() {
+ stopWeather();
handler.removeCallbacksAndMessages(null); // the tick and any glow steps still queued
content.animate().cancel();
wallpaperGeneration++; // a decode still running must not attach its picture to a stopped scene
}
+ /**
+ * The weather line under the date, and the glow's colour, both from the helper that publishes the reading
+ * (config.xml weather_provider). Nothing is fetched here: the launcher has no INTERNET permission, so this
+ * reads the provider's cached line exactly as Home's weather line does.
+ */
+ private void startWeather() {
+ TextView view = root.findViewById(R.id.dreamWeather);
+ if (view == null || weatherProvider.isEmpty()) return;
+ weather = new WeatherLine(view, weatherProvider, handler);
+ weather.format(line -> {
+ String emoji = ClockGlow.emoji(ClockGlow.condition(line));
+ return emoji.isEmpty() ? line : emoji + " " + line;
+ });
+ weather.onReading(line -> {
+ String found = ClockGlow.condition(line);
+ if (found.equals(condition)) return; // the reading has not changed the sky
+ condition = found;
+ if (!weatherSeen) {
+ // The first reading: take the colour at once, rather than starting on the palette and fading.
+ weatherSeen = true;
+ int colour = targetGlow();
+ if (colour != 0) setGlow(colour);
+ return;
+ }
+ shiftGlow();
+ });
+ weather.start();
+ }
+
+ private void stopWeather() {
+ if (weather == null) return;
+ weather.shutdown();
+ weather = null;
+ }
+
/**
* clock_wallpaper: put the picture Home is showing behind the clock, darkened by clock_wallpaper_dim, in
* place of the glow, and carry a collection's rotation on while the screensaver is up. Decoded off the main
@@ -116,6 +168,11 @@ void useHomeWallpaper(Context ctx) {
} catch (RuntimeException e) {
return;
}
+ // The place decides the glow's time of day (and wallpaper_moods, when there is a collection), so it is
+ // read whatever the clock is drawing behind it; the config load is shared with the weather line below.
+ latitude = ctx.getString(R.string.latitude);
+ longitude = ctx.getString(R.string.longitude);
+ weatherProvider = cfg.weatherProvider == null ? "" : cfg.weatherProvider.trim();
if (!cfg.clockWallpaper) {
// clock_glow false: plain black behind the clock (OLED); the clock itself still moves every minute.
if (!cfg.clockGlow) {
@@ -141,8 +198,6 @@ void useHomeWallpaper(Context ctx) {
rotationMs = cfg.wallpaperRotationMinutes * 60_000L;
order = cfg.wallpaperOrder;
moods = cfg.wallpaperMoods;
- latitude = moods.isEmpty() ? "" : ctx.getString(R.string.latitude);
- longitude = moods.isEmpty() ? "" : ctx.getString(R.string.longitude);
}
wallpaperShade = (cfg.clockWallpaperDim * 255 / 100) << 24;
wallpaperRes = ctx.getResources();
@@ -229,13 +284,25 @@ private void moveClock() {
}).start();
}
- /** A random spot that keeps the whole clock on screen, with the glow centred behind it. */
+ /**
+ * A spot that keeps the whole clock on screen, with the glow centred behind it. The first placement is the
+ * composed lower-left stamp; after that it drifts within the lower half, so the look holds and the clock still
+ * moves every minute for the panel's sake.
+ */
private void placeClock() {
View parent = (View) content.getParent();
int maxX = Math.max(0, parent.getWidth() - content.getWidth());
int maxY = Math.max(0, parent.getHeight() - content.getHeight());
- float x = maxX * (0.1f + 0.8f * random.nextFloat());
- float y = maxY * (0.1f + 0.8f * random.nextFloat());
+ float x;
+ float y;
+ if (!placed) {
+ placed = true;
+ x = maxX * 0.07f;
+ y = maxY * 0.72f;
+ } else {
+ x = maxX * (0.05f + 0.5f * random.nextFloat());
+ y = maxY * (0.5f + 0.33f * random.nextFloat());
+ }
content.setX(x);
content.setY(y);
if (parent.getWidth() > 0 && parent.getHeight() > 0) {
@@ -248,7 +315,8 @@ private void shiftGlow() {
if (wallpaperShown) return;
int from = glowColor;
colorIndex = (colorIndex + 1) % PALETTE.length;
- int to = PALETTE[colorIndex];
+ int weather = targetGlow();
+ final int to = weather != 0 ? weather : PALETTE[colorIndex];
ArgbEvaluator mix = new ArgbEvaluator();
for (int i = 1; i <= GLOW_STEPS; i++) {
float f = (float) i / GLOW_STEPS;
@@ -256,9 +324,26 @@ private void shiftGlow() {
}
}
+ /**
+ * The glow's colour: the weather's, deepened by the time of day, with a slow wobble so a long night on one
+ * colour neither burns in nor looks frozen. 0 when no weather is known, leaving the scene's own palette.
+ */
+ private int targetGlow() {
+ if (condition.isEmpty() || wallpaperShown) return 0;
+ // The sun here, so "morning" is the TV's own sunrise rather than a fixed hour.
+ LocalDateTime now = LocalDateTime.now();
+ int minute = now.getHour() * 60 + now.getMinute();
+ int[] sun = WallpaperMood.sun(now.toLocalDate(), latitude, longitude, ZoneId.systemDefault());
+ float wobble = 0.92f + 0.16f * random.nextFloat();
+ // "Full": the curated day/night colour at strength, over the wider radius and the vignette.
+ return ClockGlow.colour(condition, WallpaperMood.timeOfDay(minute, sun[0], sun[1]), wobble, 0.95f);
+ }
+
private void setGlow(int color) {
glowColor = color;
int c = color & 0x00FFFFFF;
- glow.setColors(new int[]{0x40000000 | c, 0x14000000 | c, 0x00000000 | c});
+ // Partial alpha on black, as the palette has always been. The centre is strong enough for the wide radius
+ // to read as real light ("full" of the three previews); the mid stop keeps the falloff soft, not banded.
+ glow.setColors(new int[]{0xC7000000 | c, 0x3D000000 | c, 0x00000000 | c});
}
}
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/Config.java b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
index feb5a8166a..df67392680 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/Config.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/Config.java
@@ -154,6 +154,8 @@ static boolean settingsChanged(long seen, long current) {
final boolean showStats;
/** game_day: the package of an add-on that publishes each team's next game (GameDay); empty = off. */
final String gameDay;
+ /** weather_provider: package of a helper app whose provider answers content:///today; empty = no line. */
+ final String weatherProvider;
/** App library pill after the last Home row (config.xml app_library). */
final boolean appLibrary;
/** OK directly toggles Home membership in the library (app_library_selection). */
@@ -292,7 +294,9 @@ private Config(List dockApps, boolean fillDock, List hiddenApps,
boolean keyFilter, boolean dockGlass, String glowStyle, boolean wallpaperCaptions,
boolean handleViewInputs, boolean tileMenu, boolean dockEvenPadding, boolean dockBand, boolean cinematicDots, boolean cinematicWhiteFocus, boolean wifiStatusColor, int cinematicScrim, int cinematicArt,
Map> wallpaperMoods, boolean gamepadPassthrough, boolean consumeVolumeKeys, boolean powerOnHome, boolean homeLongPressHome, boolean wifiStatusWarnings, List topBarApps, boolean showGreeting, boolean headerWhite, boolean clockWallpaper, int clockWallpaperDim, boolean clockGlow, String glassStyle, boolean singleRow, boolean dockBandAll, boolean lunarDate, int lunarUtcOffset, boolean dateBelowClock, boolean vpnPill, String locale, boolean powerOnHomeAlways, boolean inputsConnectedOnly, boolean inputsCecStateOnly,
- int openOnStartNetworkWait, boolean openOnStartOnWake, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock, boolean glowSnap) {
+ int openOnStartNetworkWait, boolean openOnStartOnWake, boolean iconOnlyVpn, String clockFormat, boolean backOpensClock, boolean glowSnap,
+ String weatherProvider) {
+ this.weatherProvider = weatherProvider;
this.handleViewInputs = handleViewInputs;
this.tileMenu = tileMenu;
this.inputKeycodes = inputKeycodes;
@@ -487,6 +491,7 @@ static Config load(Context ctx) {
boolean homeSettings = res.getBoolean(R.bool.show_home_settings_shortcut);
boolean showStats = res.getBoolean(R.bool.show_stats);
String gameDay = res.getString(R.string.game_day).trim();
+ String weatherProvider = res.getString(R.string.weather_provider).trim();
boolean library = res.getBoolean(R.bool.app_library);
boolean librarySelection = res.getBoolean(R.bool.app_library_selection);
boolean libraryOkOpens = res.getBoolean(R.bool.library_ok_opens);
@@ -715,7 +720,8 @@ static Config load(Context ctx) {
consumeVolumeKeys, powerOnHome, homeLongPressHome, wifiStatusWarnings, topBarApps, showGreeting, headerWhite, clockWallpaper,
Math.max(0, Math.min(90, clockWallpaperDim)), clockGlow, glassStyle, singleRow && dockRow, dockBandAll, lunar, lunarOffset,
dateBelowClock, vpnPill, locale, powerOnHomeAlways, inputsConnectedOnly, inputsCecStateOnly,
- Math.max(0, Math.min(600, openOnStartNetworkWait)), openOnStartOnWake, iconOnlyVpn, clockFormat, backOpensClock, glowSnap);
+ Math.max(0, Math.min(600, openOnStartNetworkWait)), openOnStartOnWake, iconOnlyVpn, clockFormat, backOpensClock, glowSnap,
+ weatherProvider);
}
/**
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
index 5f0c136e34..625331d26d 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/HomeKeyService.java
@@ -266,7 +266,10 @@ protected boolean onKeyEvent(KeyEvent event) {
// The stock launcher handled the remote's Settings button; with it disabled the button does nothing.
if (isSettingsKey(event)) {
if (event.getAction() == KeyEvent.ACTION_UP && !event.isCanceled()) {
- Intent open = settingsPanel ? new Intent(this, QuickSettingsActivity.class)
+ // A hold opens the TV's own Settings; a tap opens the panel, as the stock launcher did.
+ boolean tap = isShortPress(event.getDownTime(), event.getEventTime(),
+ ViewConfiguration.getLongPressTimeout());
+ Intent open = settingsPanel && tap ? new Intent(this, QuickSettingsActivity.class)
: SystemSettings.intent(this, Settings.ACTION_SETTINGS);
try {
startActivity(open.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
index 12fc3090ab..77be9be721 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/MainActivity.java
@@ -193,6 +193,8 @@ protected void attachBaseContext(android.content.Context base) {
private TextView shamsiDate;
/** lunar_date: the lunisolar date under the date line, and the time zone it is computed for. */
private TextView lunarDate;
+ /** weather_provider: the weather line under the date; null when the key is empty. */
+ private WeatherLine weatherLine;
private boolean lunar;
private int lunarOffset;
private TextView stats;
@@ -585,6 +587,14 @@ protected void onCreate(Bundle savedInstanceState) {
lunarOffset = Lunar.offsetFor(cfg.lunarUtcOffset, Locale.getDefault());
if (lunar) lunarDate.setVisibility(View.VISIBLE);
greetingName = cfg.greetingName;
+ if (!cfg.weatherProvider.isEmpty()) {
+ weatherLine = new WeatherLine(findViewById(R.id.weatherLine), cfg.weatherProvider, handler);
+ // The condition's emoji in front of the reading, as the screensaver shows it. Text only otherwise.
+ weatherLine.format(line -> {
+ String emoji = ClockGlow.emoji(ClockGlow.condition(line));
+ return emoji.isEmpty() ? line : emoji + " " + line;
+ });
+ }
if (cfg.dateBelowClock) moveDateBelowClock();
if (cfg.dateBelowClock && cfg.iconOnlyButtons && !cfg.topMenu
&& !getResources().getBoolean(R.bool.rtl_menu_bar)) {
@@ -1124,6 +1134,7 @@ protected void onResume() {
pillsShown = true;
}
if (showStats) startStats();
+ if (weatherLine != null) weatherLine.start();
if (gameDay != null) gameDay.start();
sky.update();
wallpaperPlayer.start();
@@ -1309,6 +1320,7 @@ protected void onPause() {
handler.removeCallbacks(openWhenOnline);
startPending = null; // leaving Home before the network came back: the boot's app stays closed
stopStats();
+ if (weatherLine != null) weatherLine.stop();
if (gameDay != null) gameDay.stop();
handler.removeCallbacks(turnTick);
if (lamp != null) lamp.stop();
@@ -1368,6 +1380,7 @@ protected void onDestroy() {
super.onDestroy();
RemoteKeys.release(this);
cancelHoldOk();
+ if (weatherLine != null) weatherLine.shutdown();
if (gameDay != null) gameDay.shutdown();
unregisterReceiver(packageReceiver);
if (openOnStartOnWake) unregisterReceiver(wakeReceiver);
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
index 418da02fbf..4103afb32b 100644
--- a/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
+++ b/launcher/app/src/main/java/com/gathin/tvhome/QuickSettingsActivity.java
@@ -4,6 +4,7 @@
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
+import android.os.SystemClock;
import android.provider.Settings;
import android.view.View;
import android.widget.ImageView;
@@ -28,6 +29,7 @@ protected void attachBaseContext(android.content.Context base) {
protected void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_quick_settings);
+ openedAt = SystemClock.elapsedRealtime();
if (getResources().getBoolean(R.bool.rtl_menu_bar)) {
View panel = findViewById(R.id.panel);
android.widget.FrameLayout.LayoutParams position =
@@ -43,6 +45,8 @@ protected void onCreate(Bundle state) {
addRow(rows, R.drawable.ic_settings, R.string.tv_settings, 0, SystemSettings.intent(this, Settings.ACTION_SETTINGS));
addRow(rows, R.drawable.ic_picture, R.string.quick_picture, 0, SystemSettings.intent(this, Settings.ACTION_DISPLAY_SETTINGS));
addRow(rows, R.drawable.ic_wifi, R.string.quick_network, 0, SystemSettings.intent(this, Settings.ACTION_WIFI_SETTINGS));
+ addRow(rows, R.drawable.ic_bluetooth, R.string.quick_bluetooth, 0, SystemSettings.intent(this, Settings.ACTION_BLUETOOTH_SETTINGS));
+ addRow(rows, R.drawable.ic_sound, R.string.quick_sound, 0, SystemSettings.intent(this, Settings.ACTION_SOUND_SETTINGS));
addRow(rows, R.drawable.ic_apps, R.string.quick_apps, R.string.quick_apps_hint,
SystemSettings.intent(this, Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));
// Through Home, so it rebuilds with the new choices when Launcher settings closes.
@@ -51,11 +55,16 @@ protected void onCreate(Bundle state) {
rows.getChildAt(0).requestFocus();
}
+ /** When this panel was created, to ignore the pause that lands while it is still coming up. */
+ private long openedAt;
+
/** Settings pressed again while the panel is up. */
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
- finish();
+ // Both key services can answer one press, and the second start arrives as a new intent. Closing
+ // on it made the panel flash and vanish, so a start this soon after opening is the same press.
+ if (SystemClock.elapsedRealtime() - openedAt > SAME_PRESS_MS) finish();
}
/** Anything else taking the screen (Home, an app, a screensaver) closes the panel. */
@@ -63,10 +72,15 @@ protected void onNewIntent(Intent intent) {
@SuppressWarnings("deprecation")
protected void onPause() {
super.onPause();
- finish();
- overridePendingTransition(0, 0);
+ // The window can be paused once while it is still being shown, which finished it at once.
+ if (SystemClock.elapsedRealtime() - openedAt > SAME_PRESS_MS) {
+ finish();
+ overridePendingTransition(0, 0);
+ }
}
+ private static final long SAME_PRESS_MS = 700;
+
private void addRow(LinearLayout rows, int icon, int title, int status, Intent target) {
View row = getLayoutInflater().inflate(R.layout.item_input, rows, false);
((ImageView) row.findViewById(R.id.icon)).setImageResource(icon);
diff --git a/launcher/app/src/main/java/com/gathin/tvhome/WeatherLine.java b/launcher/app/src/main/java/com/gathin/tvhome/WeatherLine.java
new file mode 100644
index 0000000000..1c076aca1f
--- /dev/null
+++ b/launcher/app/src/main/java/com/gathin/tvhome/WeatherLine.java
@@ -0,0 +1,106 @@
+package com.gathin.tvhome;
+
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.view.View;
+import android.widget.TextView;
+
+/**
+ * The weather line under the date, published by a helper app (config.xml weather_provider).
+ *
+ * The launcher has no INTERNET permission and never fetches: it asks the provider for a line and
+ * repaints it. The provider answers from its own cache, so the last reading shows the moment Home
+ * comes back, even before the network is up; an empty line hides the row instead of leaving a gap.
+ */
+final class WeatherLine {
+
+ private static final long POLL_MS = 15 * 60 * 1000L;
+
+ /** What the provider answers, or null when it is missing or cannot be read. */
+ private static final String[] COLUMNS = {"line"};
+
+ private final TextView view;
+ private final Uri uri;
+ private final Handler ui;
+ private final HandlerThread thread;
+ private final Handler bg;
+ private String shown = "";
+ /** Told every reading, for the screensaver's glow; null on Home, which only shows the line. */
+ private java.util.function.Consumer listener;
+ /** Rewrites what the line shows (the screensaver puts an emoji in front); null shows the reading as it is. */
+ private java.util.function.Function format;
+
+ /** Called on the UI thread after each reading, with "" when there is none. */
+ void onReading(java.util.function.Consumer listener) {
+ this.listener = listener;
+ }
+
+ /** How a reading is displayed; the listener still gets the plain reading. */
+ void format(java.util.function.Function format) {
+ this.format = format;
+ }
+
+ WeatherLine(TextView view, String authority, Handler ui) {
+ this.view = view;
+ this.uri = Uri.parse("content://" + authority + "/today");
+ this.ui = ui;
+ this.thread = new HandlerThread("weather-line");
+ this.thread.start();
+ this.bg = new Handler(thread.getLooper());
+ }
+
+ /** Read now, then every 15 minutes while Home is on screen. */
+ void start() {
+ bg.removeCallbacks(tick);
+ bg.post(tick);
+ }
+
+ /** Home left the screen: stop reading until it comes back. */
+ void stop() {
+ bg.removeCallbacks(tick);
+ }
+
+ void shutdown() {
+ bg.removeCallbacksAndMessages(null);
+ thread.quit();
+ }
+
+ private final Runnable tick = new Runnable() {
+ @Override
+ public void run() {
+ final String line = read();
+ ui.post(new Runnable() {
+ @Override
+ public void run() {
+ apply(line);
+ }
+ });
+ bg.postDelayed(this, POLL_MS);
+ }
+ };
+
+ private void apply(String line) {
+ if (listener != null) listener.accept(line == null ? "" : line.trim());
+ if (line == null || line.isEmpty()) {
+ shown = "";
+ view.setVisibility(View.GONE);
+ return;
+ }
+ if (line.equals(shown)) return; // same reading: leave the view alone
+ shown = line;
+ view.setText(format == null ? line : format.apply(line));
+ view.setVisibility(View.VISIBLE);
+ }
+
+ private String read() {
+ try (Cursor c = view.getContext().getContentResolver().query(uri, COLUMNS, null, null, null)) {
+ if (c == null || !c.moveToFirst()) return null;
+ String line = c.getString(0);
+ return line == null ? null : line.trim();
+ } catch (Exception e) {
+ return null; // provider not installed, or not answering
+ }
+ }
+}
diff --git a/launcher/app/src/main/res/anim/panel_in.xml b/launcher/app/src/main/res/anim/panel_in.xml
new file mode 100644
index 0000000000..98443c8594
--- /dev/null
+++ b/launcher/app/src/main/res/anim/panel_in.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/launcher/app/src/main/res/anim/panel_out.xml b/launcher/app/src/main/res/anim/panel_out.xml
new file mode 100644
index 0000000000..e07c469f61
--- /dev/null
+++ b/launcher/app/src/main/res/anim/panel_out.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/launcher/app/src/main/res/drawable/dream_vignette.xml b/launcher/app/src/main/res/drawable/dream_vignette.xml
new file mode 100644
index 0000000000..e45458d84f
--- /dev/null
+++ b/launcher/app/src/main/res/drawable/dream_vignette.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/launcher/app/src/main/res/drawable/ic_bluetooth.xml b/launcher/app/src/main/res/drawable/ic_bluetooth.xml
new file mode 100644
index 0000000000..8f6aee0871
--- /dev/null
+++ b/launcher/app/src/main/res/drawable/ic_bluetooth.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/launcher/app/src/main/res/drawable/ic_sound.xml b/launcher/app/src/main/res/drawable/ic_sound.xml
new file mode 100644
index 0000000000..df3c4b6a0b
--- /dev/null
+++ b/launcher/app/src/main/res/drawable/ic_sound.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/launcher/app/src/main/res/layout/activity_main.xml b/launcher/app/src/main/res/layout/activity_main.xml
index 70c6de304b..669e20633f 100644
--- a/launcher/app/src/main/res/layout/activity_main.xml
+++ b/launcher/app/src/main/res/layout/activity_main.xml
@@ -282,6 +282,21 @@
android:letterSpacing="0.14"
android:textAllCaps="true" />
+
+
+
+
+
+
+
+
+
diff --git a/launcher/app/src/main/res/values-zh-rCN/strings.xml b/launcher/app/src/main/res/values-zh-rCN/strings.xml
index c19bf59f82..dc0360a11a 100644
--- a/launcher/app/src/main/res/values-zh-rCN/strings.xml
+++ b/launcher/app/src/main/res/values-zh-rCN/strings.xml
@@ -93,7 +93,7 @@
未找到可启动的应用
已在主屏幕
添加到主屏幕
- 从主屏幕移除
+ 从主屏幕隐藏
打开
应用信息
无法保存快捷方式
diff --git a/launcher/app/src/main/res/values/config.xml b/launcher/app/src/main/res/values/config.xml
index 2255d16f05..98e1192552 100644
--- a/launcher/app/src/main/res/values/config.xml
+++ b/launcher/app/src/main/res/values/config.xml
@@ -15,12 +15,19 @@
- com.amazon.tv.launcher/com.amazon.tv.launcher.ui.MainSettingsActivity
+
+ io.github.sumyabazar1.weatherline
+
- - com.netflix.ninja
- - com.amazon.amazonvideo.livingroom
+ - org.smarttube.stable
+ - com.tcl.browser
- com.google.android.youtube.tv
- - in.startv.hotstar
+ - com.netflix.ninja
- com.mediatek.wwtv.tvcenter
+ com.tcl.tv
+ - 83
- false
+ true
+ - 4514
+ - 4062:com.netflix.ninja
+ - 190:com.google.android.youtube.tv
+ - 4001:guide:com.tcl.tv
+ - 4020:com.tcl.channelplus/com.tcl.live.ui_play.PlayActivity
+ - 4099:com.amazon.amazonvideo.livingroom
+ - 288:com.android.tv.settings/.accounts.AccountSyncActivity
- false
+ true
true
@@ -501,10 +517,10 @@
instead of dimming and fading back in. Each frame of that fade repaints the whole screen, about 40 per key
press, which a slow GPU such as the Mali-G52 cannot keep up with. Can also be set with "glow_snap" in a
theme's config.json. -->
- false
+ true
- false
+ true
diff --git a/launcher/app/src/main/res/values/strings.xml b/launcher/app/src/main/res/values/strings.xml
index 2b2b53eb1e..9b66b55d5e 100644
--- a/launcher/app/src/main/res/values/strings.xml
+++ b/launcher/app/src/main/res/values/strings.xml
@@ -1,6 +1,6 @@
- Home
+ Clean Home
Inputs
Wi-Fi
Settings
@@ -69,6 +69,8 @@
TV system settings
Display
Network
+ Bluetooth
+ Sound
Apps
Re-enable
On
diff --git a/launcher/app/src/main/res/values/styles.xml b/launcher/app/src/main/res/values/styles.xml
index 25089128de..febb38e7d9 100644
--- a/launcher/app/src/main/res/values/styles.xml
+++ b/launcher/app/src/main/res/values/styles.xml
@@ -6,6 +6,20 @@
- @null
+
+
+
+
+
+