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:
Claude committed 2026-10-21 19:03:52 +00:00
1 parent a52108e95f
commit ab03efd389
9 files changed
+132 -1

No files matched your search

+14
View File
@@ -31,5 +31,19 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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>
</manifest>
@@ -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);
}
@@ -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"?>
<resources>
<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>
@@ -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" />