diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 0ec947c..59880fe 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -31,5 +31,19 @@
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/java/dev/ultra/launcher/MainActivity.java b/android/app/src/main/java/dev/ultra/launcher/MainActivity.java
index 4c82b96..6a114f4 100644
--- a/android/app/src/main/java/dev/ultra/launcher/MainActivity.java
+++ b/android/app/src/main/java/dev/ultra/launcher/MainActivity.java
@@ -72,7 +72,7 @@ import java.util.concurrent.Executors;
* wicon?p=PROV the provider's icon as a PNG
*
* and exposes window.Android (launch, appInfo, addWidget, removeWidget, placeWidgets,
- * openSettings, pickWallpaper, haptic, is24Hour) for the app's @jscall imports.
+ * openSettings, pickWallpaper, openRecents, haptic, is24Hour) for the app's @jscall imports.
*
* Widgets are real AppWidgetHostViews in a layer above the WebView. The page reports where
* its live widget slots are (placeWidgets), and this class moves the views there. Package
@@ -567,6 +567,22 @@ public class MainActivity extends Activity {
}
}
+ /**
+ * Show Recents through RecentsService. Until the user has turned the service on, take
+ * them to Accessibility settings, with our service highlighted where Settings supports it.
+ */
+ private void openRecents() {
+ if (RecentsService.showRecents()) return;
+ Toast.makeText(this, "Turn on \"" + getString(R.string.recents_service_label)
+ + "\" to show open windows", Toast.LENGTH_LONG).show();
+ String me = new ComponentName(this, RecentsService.class).flattenToString();
+ Bundle args = new Bundle();
+ args.putString(":settings:fragment_args_key", me);
+ startIntent(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
+ .putExtra(":settings:fragment_args_key", me)
+ .putExtra(":settings:show_fragment_args", args));
+ }
+
/** window.Android: called from the page's @jscall imports on a binder thread. */
final class Bridge {
@JavascriptInterface public void launch(String component) {
@@ -609,6 +625,10 @@ public class MainActivity extends Activity {
main.post(() -> startIntent(Intent.createChooser(new Intent(Intent.ACTION_SET_WALLPAPER), "Wallpaper")));
}
+ @JavascriptInterface public void openRecents() {
+ main.post(MainActivity.this::openRecents);
+ }
+
@JavascriptInterface public boolean is24Hour() {
return DateFormat.is24HourFormat(MainActivity.this);
}
diff --git a/android/app/src/main/java/dev/ultra/launcher/RecentsService.java b/android/app/src/main/java/dev/ultra/launcher/RecentsService.java
new file mode 100644
index 0000000..9ef3551
--- /dev/null
+++ b/android/app/src/main/java/dev/ultra/launcher/RecentsService.java
@@ -0,0 +1,41 @@
+package dev.ultra.launcher;
+
+import android.accessibilityservice.AccessibilityService;
+import android.content.Intent;
+import android.view.accessibility.AccessibilityEvent;
+
+/**
+ * An accessibility service that does nothing but open Recents (the system's list of open
+ * windows) for the home screen's Windows button. Android lets no other app open Recents,
+ * so the user turns this on once under Settings > Accessibility. It reads no window
+ * content and asks for no events.
+ */
+public class RecentsService extends AccessibilityService {
+ private static volatile RecentsService running;
+
+ /** Open Recents; false when the service isn't turned on. */
+ static boolean showRecents() {
+ RecentsService s = running;
+ return s != null && s.performGlobalAction(GLOBAL_ACTION_RECENTS);
+ }
+
+ @Override
+ protected void onServiceConnected() {
+ running = this;
+ }
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ running = null;
+ return super.onUnbind(intent);
+ }
+
+ @Override
+ public void onDestroy() {
+ running = null;
+ super.onDestroy();
+ }
+
+ @Override public void onAccessibilityEvent(AccessibilityEvent event) { }
+ @Override public void onInterrupt() { }
+}
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index ecacc41..da3aee5 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1,4 +1,7 @@
ultra Home
+ ultra Home window list
+ Lets the home screen\'s Windows button open Recents
+ Turn this on so the Windows button on the ultra Home screen can show your open windows (Recents). Android only lets accessibility services open Recents. This service reads nothing on screen and does nothing else.
diff --git a/android/app/src/main/res/xml/recents_service.xml b/android/app/src/main/res/xml/recents_service.xml
new file mode 100644
index 0000000..f5eb58f
--- /dev/null
+++ b/android/app/src/main/res/xml/recents_service.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/web/app.py b/web/app.py
index ba8ea31..45cc085 100644
--- a/web/app.py
+++ b/web/app.py
@@ -41,6 +41,11 @@ def open_settings() -> None:
def pick_wallpaper() -> None:
pass
+@jscall
+def open_recents() -> None:
+ """Show the system's list of open windows (Recents)."""
+ pass
+
@jscall
def haptic() -> None:
pass
@@ -87,6 +92,7 @@ INFO: Const[i32] = 29 # arg: home slot
SETTINGS: Const[i32] = 30
WALLPAPER: Const[i32] = 31
NOTICE_DONE: Const[i32] = 32
+RECENTS: Const[i32] = 33
CAP: Const[i32] = 512
HOME_CAP: Const[i32] = 40
@@ -462,6 +468,8 @@ def update(msg: i32, arg: i32) -> None:
elif msg == WALLPAPER:
pick_wallpaper()
sheet = NONE
+ elif msg == RECENTS:
+ open_recents()
elif msg == NOTICE_DONE:
if arg == notice_gen:
s_clear(notice)
@@ -530,6 +538,25 @@ def view_home_slot(i: i32) -> None:
end()
+def view_panel() -> None:
+ """The panel under the clock: shortcuts to system surfaces."""
+ el("section")
+ cls("panel")
+ attr("aria-label", "Shortcuts")
+ el("button")
+ cls("panel-btn")
+ on_click(RECENTS, 0)
+ el("span")
+ cls("windows-glyph")
+ attr("aria-hidden", "true")
+ end()
+ el("span")
+ text("Windows")
+ end()
+ end()
+ end()
+
+
def view_home() -> None:
i: i32
div("home")
@@ -550,6 +577,8 @@ def view_home() -> None:
end()
end()
+ view_panel()
+
el("ul")
cls("slots")
for i in range(nh):
diff --git a/web/app.wasm b/web/app.wasm
index 2670d4f..0cb08e0 100644
Binary files a/web/app.wasm and b/web/app.wasm differ
diff --git a/web/index.html b/web/index.html
index 56ee560..20241da 100644
--- a/web/index.html
+++ b/web/index.html
@@ -30,6 +30,7 @@
placeWidgets: () => {},
openSettings: () => toast("Open system settings"),
pickWallpaper: () => toast("Pick a wallpaper"),
+ openRecents: () => toast("Show open windows"),
haptic: () => navigator.vibrate?.(10),
is24Hour: () => false,
};
@@ -89,6 +90,7 @@
remove_widget: (id) => host.removeWidget(id),
open_settings: () => host.openSettings(),
pick_wallpaper: () => host.pickWallpaper(),
+ open_recents: () => host.openRecents(),
haptic: () => host.haptic(),
clock_time: (h) => { strs[h] = fmtTime.format(new Date()).replace(/\s?[AP]M$/i, ""); },
clock_date: (h) => { strs[h] = fmtDate.format(new Date()); },
diff --git a/web/style.css b/web/style.css
index c0c1a54..0e86f30 100644
--- a/web/style.css
+++ b/web/style.css
@@ -26,6 +26,19 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
font-variant-numeric: tabular-nums; }
.clock .date { margin-top: .5rem; font-size: 1rem; opacity: .9; }
+.panel { display: flex; gap: .5rem; margin: 0 auto 2rem; padding: .5rem; max-width: 22rem;
+ border-radius: 1.25rem; background: rgb(255 255 255 / .12); border: 1px solid rgb(255 255 255 / .16);
+ backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
+.panel-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: .6rem;
+ min-height: 3rem; padding: .5rem 1rem; border: 0; border-radius: .9rem;
+ background: rgb(255 255 255 / .1); color: #fff; font: inherit; font-weight: 500;
+ cursor: pointer; text-shadow: 0 1px 4px rgb(0 0 0 / .35); }
+.panel-btn:hover, .panel-btn:active { background: rgb(255 255 255 / .22); }
+.windows-glyph { position: relative; width: 1.1rem; height: 1.1rem; }
+.windows-glyph::before, .windows-glyph::after { content: ""; position: absolute; border: 2px solid currentColor;
+ border-radius: .25rem; box-sizing: border-box; }
+.windows-glyph::before { inset: 0 .3rem .3rem 0; opacity: .6; }
+.windows-glyph::after { inset: .3rem 0 0 .3rem; background: rgb(255 255 255 / .15); }
.slots, .apps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem .5rem;
grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 480px) { .slots, .apps { grid-template-columns: repeat(5, minmax(0, 1fr)); } }