Launcher: home panel with a Windows button that opens Recents
The panel under the clock holds a Windows button. Android lets only accessibility services open Recents, so a minimal RecentsService does just performGlobalAction(GLOBAL_ACTION_RECENTS); until the user turns it on, the button opens Accessibility settings instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M9yVmqTBBDyq8bEYt2rVq6
This commit is contained in:
1 parent
a52108e95f
commit
ab03efd389
9 files changed
+132
-1
No files matched your search
@@ -31,5 +31,19 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Opens Recents for the Windows button; the user turns it on in Accessibility. -->
|
||||||
|
<service
|
||||||
|
android:name=".RecentsService"
|
||||||
|
android:label="@string/recents_service_label"
|
||||||
|
android:exported="true"
|
||||||
|
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data
|
||||||
|
android:name="android.accessibilityservice"
|
||||||
|
android:resource="@xml/recents_service" />
|
||||||
|
</service>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -72,7 +72,7 @@ import java.util.concurrent.Executors;
|
|||||||
* wicon?p=PROV the provider's icon as a PNG
|
* wicon?p=PROV the provider's icon as a PNG
|
||||||
*
|
*
|
||||||
* and exposes window.Android (launch, appInfo, addWidget, removeWidget, placeWidgets,
|
* 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
|
* 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
|
* 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. */
|
/** window.Android: called from the page's @jscall imports on a binder thread. */
|
||||||
final class Bridge {
|
final class Bridge {
|
||||||
@JavascriptInterface public void launch(String component) {
|
@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")));
|
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() {
|
@JavascriptInterface public boolean is24Hour() {
|
||||||
return DateFormat.is24HourFormat(MainActivity.this);
|
return DateFormat.is24HourFormat(MainActivity.this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() { }
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">ultra Home</string>
|
<string name="app_name">ultra Home</string>
|
||||||
|
<string name="recents_service_label">ultra Home window list</string>
|
||||||
|
<string name="recents_service_summary">Lets the home screen\'s Windows button open Recents</string>
|
||||||
|
<string name="recents_service_description">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.</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Only performGlobalAction(RECENTS): no events, no window content. -->
|
||||||
|
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:description="@string/recents_service_description"
|
||||||
|
android:summary="@string/recents_service_summary"
|
||||||
|
android:accessibilityFeedbackType="feedbackGeneric"
|
||||||
|
android:accessibilityFlags="flagDefault"
|
||||||
|
android:canRetrieveWindowContent="false"
|
||||||
|
android:notificationTimeout="0" />
|
||||||
+29
@@ -41,6 +41,11 @@ def open_settings() -> None:
|
|||||||
def pick_wallpaper() -> None:
|
def pick_wallpaper() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@jscall
|
||||||
|
def open_recents() -> None:
|
||||||
|
"""Show the system's list of open windows (Recents)."""
|
||||||
|
pass
|
||||||
|
|
||||||
@jscall
|
@jscall
|
||||||
def haptic() -> None:
|
def haptic() -> None:
|
||||||
pass
|
pass
|
||||||
@@ -87,6 +92,7 @@ INFO: Const[i32] = 29 # arg: home slot
|
|||||||
SETTINGS: Const[i32] = 30
|
SETTINGS: Const[i32] = 30
|
||||||
WALLPAPER: Const[i32] = 31
|
WALLPAPER: Const[i32] = 31
|
||||||
NOTICE_DONE: Const[i32] = 32
|
NOTICE_DONE: Const[i32] = 32
|
||||||
|
RECENTS: Const[i32] = 33
|
||||||
|
|
||||||
CAP: Const[i32] = 512
|
CAP: Const[i32] = 512
|
||||||
HOME_CAP: Const[i32] = 40
|
HOME_CAP: Const[i32] = 40
|
||||||
@@ -462,6 +468,8 @@ def update(msg: i32, arg: i32) -> None:
|
|||||||
elif msg == WALLPAPER:
|
elif msg == WALLPAPER:
|
||||||
pick_wallpaper()
|
pick_wallpaper()
|
||||||
sheet = NONE
|
sheet = NONE
|
||||||
|
elif msg == RECENTS:
|
||||||
|
open_recents()
|
||||||
elif msg == NOTICE_DONE:
|
elif msg == NOTICE_DONE:
|
||||||
if arg == notice_gen:
|
if arg == notice_gen:
|
||||||
s_clear(notice)
|
s_clear(notice)
|
||||||
@@ -530,6 +538,25 @@ def view_home_slot(i: i32) -> None:
|
|||||||
end()
|
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:
|
def view_home() -> None:
|
||||||
i: i32
|
i: i32
|
||||||
div("home")
|
div("home")
|
||||||
@@ -550,6 +577,8 @@ def view_home() -> None:
|
|||||||
end()
|
end()
|
||||||
end()
|
end()
|
||||||
|
|
||||||
|
view_panel()
|
||||||
|
|
||||||
el("ul")
|
el("ul")
|
||||||
cls("slots")
|
cls("slots")
|
||||||
for i in range(nh):
|
for i in range(nh):
|
||||||
|
|||||||
Binary file not shown.
@@ -30,6 +30,7 @@
|
|||||||
placeWidgets: () => {},
|
placeWidgets: () => {},
|
||||||
openSettings: () => toast("Open system settings"),
|
openSettings: () => toast("Open system settings"),
|
||||||
pickWallpaper: () => toast("Pick a wallpaper"),
|
pickWallpaper: () => toast("Pick a wallpaper"),
|
||||||
|
openRecents: () => toast("Show open windows"),
|
||||||
haptic: () => navigator.vibrate?.(10),
|
haptic: () => navigator.vibrate?.(10),
|
||||||
is24Hour: () => false,
|
is24Hour: () => false,
|
||||||
};
|
};
|
||||||
@@ -89,6 +90,7 @@
|
|||||||
remove_widget: (id) => host.removeWidget(id),
|
remove_widget: (id) => host.removeWidget(id),
|
||||||
open_settings: () => host.openSettings(),
|
open_settings: () => host.openSettings(),
|
||||||
pick_wallpaper: () => host.pickWallpaper(),
|
pick_wallpaper: () => host.pickWallpaper(),
|
||||||
|
open_recents: () => host.openRecents(),
|
||||||
haptic: () => host.haptic(),
|
haptic: () => host.haptic(),
|
||||||
clock_time: (h) => { strs[h] = fmtTime.format(new Date()).replace(/\s?[AP]M$/i, ""); },
|
clock_time: (h) => { strs[h] = fmtTime.format(new Date()).replace(/\s?[AP]M$/i, ""); },
|
||||||
clock_date: (h) => { strs[h] = fmtDate.format(new Date()); },
|
clock_date: (h) => { strs[h] = fmtDate.format(new Date()); },
|
||||||
|
|||||||
@@ -26,6 +26,19 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
|
|||||||
font-variant-numeric: tabular-nums; }
|
font-variant-numeric: tabular-nums; }
|
||||||
.clock .date { margin-top: .5rem; font-size: 1rem; opacity: .9; }
|
.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;
|
.slots, .apps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem .5rem;
|
||||||
grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
||||||
@media (min-width: 480px) { .slots, .apps { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
|
@media (min-width: 480px) { .slots, .apps { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
|
||||||
|
|||||||
Reference in new issue
Block a user