Fix wallpaper transparency, Recents setup guide, and drawer animation
This commit is contained in:
1 parent
2fa7bd745b
commit
216c80252d
14 files changed
+474
-86
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: fix
|
||||||
|
---
|
||||||
|
|
||||||
|
Show the Android system wallpaper behind the transparent WebView, add an in-app setup guide for Android 13+ "Restricted setting" on the Windows button, and smooth out app drawer animations with keyed overlays, GPU-composited open/close transitions, delayed IME focus, and pre-warmed app icons.
|
||||||
@@ -36,6 +36,7 @@ import android.view.View;
|
|||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.webkit.JavascriptInterface;
|
import android.webkit.JavascriptInterface;
|
||||||
import android.webkit.RenderProcessGoneDetail;
|
import android.webkit.RenderProcessGoneDetail;
|
||||||
@@ -77,9 +78,10 @@ import java.util.concurrent.Executors;
|
|||||||
*
|
*
|
||||||
* and exposes window.Android (launch, appInfo, uninstall, addWidget, removeWidget,
|
* and exposes window.Android (launch, appInfo, uninstall, addWidget, removeWidget,
|
||||||
* placeWidgets, coverWidgets, widgetLimits, excludeGestures, loadIcons, haptic, keyboard,
|
* placeWidgets, coverWidgets, widgetLimits, excludeGestures, loadIcons, haptic, keyboard,
|
||||||
* openSettings, pickWallpaper, openRecents, httpGet, installApk, installedVersion,
|
* openSettings, pickWallpaper, openRecents, recentsEnabled, openAccessibilitySettings,
|
||||||
* declinedVersion) for the page's host effects. No decisions are made here: the page
|
* openSelfAppInfo, httpGet, installApk, installedVersion, declinedVersion) for the page's
|
||||||
* (core/ and app/ in MoonBit) decides, this class carries them out.
|
* host effects. No decisions are made here: the page (core/ and app/ in MoonBit) decides,
|
||||||
|
* this class carries them out.
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -110,6 +112,12 @@ public class HomeActivity extends Activity {
|
|||||||
private final Map<String, byte[]> icons = new ConcurrentHashMap<>();
|
private final Map<String, byte[]> icons = new ConcurrentHashMap<>();
|
||||||
private final Map<String, LauncherActivityInfo> activities = new ConcurrentHashMap<>();
|
private final Map<String, LauncherActivityInfo> activities = new ConcurrentHashMap<>();
|
||||||
private final Handler main = new Handler(Looper.getMainLooper());
|
private final Handler main = new Handler(Looper.getMainLooper());
|
||||||
|
private final Runnable showIme = () -> {
|
||||||
|
if (!ready || web == null) return;
|
||||||
|
web.requestFocus();
|
||||||
|
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||||
|
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
};
|
||||||
private final ExecutorService iconThread = Executors.newSingleThreadExecutor();
|
private final ExecutorService iconThread = Executors.newSingleThreadExecutor();
|
||||||
|
|
||||||
private final LauncherApps.Callback packages = new LauncherApps.Callback() {
|
private final LauncherApps.Callback packages = new LauncherApps.Callback() {
|
||||||
@@ -129,6 +137,11 @@ public class HomeActivity extends Activity {
|
|||||||
widgetHost = new Host(this);
|
widgetHost = new Host(this);
|
||||||
|
|
||||||
Window w = getWindow();
|
Window w = getWindow();
|
||||||
|
w.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER);
|
||||||
|
if (Build.VERSION.SDK_INT >= 29) {
|
||||||
|
w.setNavigationBarContrastEnforced(false);
|
||||||
|
w.setStatusBarContrastEnforced(false);
|
||||||
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 30) {
|
if (Build.VERSION.SDK_INT >= 30) {
|
||||||
w.setDecorFitsSystemWindows(false);
|
w.setDecorFitsSystemWindows(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -139,6 +152,7 @@ public class HomeActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createWebView() {
|
private void createWebView() {
|
||||||
|
main.removeCallbacks(showIme);
|
||||||
ready = false;
|
ready = false;
|
||||||
web = new WebView(this);
|
web = new WebView(this);
|
||||||
web.setBackgroundColor(Color.TRANSPARENT);
|
web.setBackgroundColor(Color.TRANSPARENT);
|
||||||
@@ -174,7 +188,9 @@ public class HomeActivity extends Activity {
|
|||||||
widgetViews.clear();
|
widgetViews.clear();
|
||||||
widgetSizes.clear();
|
widgetSizes.clear();
|
||||||
widgetLayer = new CoverLayer(this);
|
widgetLayer = new CoverLayer(this);
|
||||||
|
widgetLayer.setBackgroundColor(Color.TRANSPARENT);
|
||||||
FrameLayout root = new FrameLayout(this);
|
FrameLayout root = new FrameLayout(this);
|
||||||
|
root.setBackgroundColor(Color.TRANSPARENT);
|
||||||
root.addView(web);
|
root.addView(web);
|
||||||
root.addView(widgetLayer);
|
root.addView(widgetLayer);
|
||||||
setContentView(root);
|
setContentView(root);
|
||||||
@@ -196,6 +212,7 @@ public class HomeActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
launcher.unregisterCallback(packages);
|
launcher.unregisterCallback(packages);
|
||||||
|
main.removeCallbacks(showIme);
|
||||||
iconThread.shutdownNow();
|
iconThread.shutdownNow();
|
||||||
web.destroy();
|
web.destroy();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -752,13 +769,16 @@ public class HomeActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show Recents through RecentsService. Until the user has turned the service on, take
|
* Show Recents through RecentsService, falling back to Accessibility settings if
|
||||||
* them to Accessibility settings, with our service highlighted where Settings supports it.
|
* invoked directly while the service isn't running.
|
||||||
*/
|
*/
|
||||||
private void openRecents() {
|
private void openRecents() {
|
||||||
if (RecentsService.showRecents()) return;
|
if (RecentsService.showRecents()) return;
|
||||||
Toast.makeText(this, "Turn on \"" + getString(R.string.recents_service_label)
|
openAccessibilitySettings();
|
||||||
+ "\" to show open windows", Toast.LENGTH_LONG).show();
|
}
|
||||||
|
|
||||||
|
/** Open Accessibility settings with RecentsService highlighted where Settings supports it. */
|
||||||
|
private void openAccessibilitySettings() {
|
||||||
String me = new ComponentName(this, RecentsService.class).flattenToString();
|
String me = new ComponentName(this, RecentsService.class).flattenToString();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putString(":settings:fragment_args_key", me);
|
args.putString(":settings:fragment_args_key", me);
|
||||||
@@ -767,6 +787,12 @@ public class HomeActivity extends Activity {
|
|||||||
.putExtra(":settings:show_fragment_args", args));
|
.putExtra(":settings:show_fragment_args", args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Open ultra Home's own App info page (for "Allow restricted settings" on Android 13+). */
|
||||||
|
private void openSelfAppInfo() {
|
||||||
|
startIntent(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||||
|
Uri.fromParts("package", getPackageName(), null)));
|
||||||
|
}
|
||||||
|
|
||||||
/** 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) {
|
||||||
@@ -833,16 +859,14 @@ public class HomeActivity extends Activity {
|
|||||||
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
|
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The page focused the drawer's search box; show the keyboard for it. */
|
/** The page focused the drawer's search box; show the keyboard once the entrance finishes. */
|
||||||
@JavascriptInterface public void showKeyboard() {
|
@JavascriptInterface public void showKeyboard() {
|
||||||
main.postDelayed(() -> {
|
main.removeCallbacks(showIme);
|
||||||
web.requestFocus();
|
main.postDelayed(showIme, 190);
|
||||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
|
||||||
if (imm != null) imm.showSoftInput(web, InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}, 50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface public void hideKeyboard() {
|
@JavascriptInterface public void hideKeyboard() {
|
||||||
|
main.removeCallbacks(showIme);
|
||||||
main.post(() -> {
|
main.post(() -> {
|
||||||
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
InputMethodManager imm = getSystemService(InputMethodManager.class);
|
||||||
if (imm != null) imm.hideSoftInputFromWindow(web.getWindowToken(), 0);
|
if (imm != null) imm.hideSoftInputFromWindow(web.getWindowToken(), 0);
|
||||||
@@ -857,8 +881,22 @@ public class HomeActivity 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() {
|
@JavascriptInterface public boolean openRecents() {
|
||||||
|
if (!RecentsService.isRunning()) return false;
|
||||||
main.post(HomeActivity.this::openRecents);
|
main.post(HomeActivity.this::openRecents);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface public boolean recentsEnabled() {
|
||||||
|
return RecentsService.isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface public void openAccessibilitySettings() {
|
||||||
|
main.post(HomeActivity.this::openAccessibilitySettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JavascriptInterface public void openSelfAppInfo() {
|
||||||
|
main.post(HomeActivity.this::openSelfAppInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** GET a URL on a background thread; the page hears back through launcher.httpResult(tag, ok, text). */
|
/** GET a URL on a background thread; the page hears back through launcher.httpResult(tag, ok, text). */
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ import android.view.accessibility.AccessibilityEvent;
|
|||||||
public class RecentsService extends AccessibilityService {
|
public class RecentsService extends AccessibilityService {
|
||||||
private static volatile RecentsService running;
|
private static volatile RecentsService running;
|
||||||
|
|
||||||
|
/** Whether the accessibility service is currently connected. */
|
||||||
|
static boolean isRunning() {
|
||||||
|
return running != null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Open Recents; false when the service isn't turned on. */
|
/** Open Recents; false when the service isn't turned on. */
|
||||||
static boolean showRecents() {
|
static boolean showRecents() {
|
||||||
RecentsService s = running;
|
RecentsService s = running;
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
<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_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_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>
|
<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. If Android blocks this as a restricted setting, open ultra Home\'s App info and turn on Allow restricted settings once. This service reads nothing on screen and does nothing else.</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -60,6 +60,7 @@ pub(all) enum Sheet {
|
|||||||
/// The menu of a drawer app (row in the app list).
|
/// The menu of a drawer app (row in the app list).
|
||||||
DrawerApp(Int32)
|
DrawerApp(Int32)
|
||||||
WidgetPicker
|
WidgetPicker
|
||||||
|
RecentsSetup
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
@@ -110,6 +111,9 @@ pub(all) struct Model {
|
|||||||
mut query : String
|
mut query : String
|
||||||
mut wquery : String
|
mut wquery : String
|
||||||
mut drawer : Bool
|
mut drawer : Bool
|
||||||
|
/// The drawer is animating out before detaching.
|
||||||
|
mut drawer_closing : Bool
|
||||||
|
mut drawer_gen : Int32
|
||||||
/// The drawer is in "add apps" mode: taps toggle home slots.
|
/// The drawer is in "add apps" mode: taps toggle home slots.
|
||||||
mut picking : Bool
|
mut picking : Bool
|
||||||
mut sheet : Sheet
|
mut sheet : Sheet
|
||||||
@@ -165,6 +169,8 @@ pub fn Model::new() -> Model {
|
|||||||
query: "",
|
query: "",
|
||||||
wquery: "",
|
wquery: "",
|
||||||
drawer: false,
|
drawer: false,
|
||||||
|
drawer_closing: false,
|
||||||
|
drawer_gen: 0,
|
||||||
picking: false,
|
picking: false,
|
||||||
sheet: NoSheet,
|
sheet: NoSheet,
|
||||||
gone: "",
|
gone: "",
|
||||||
@@ -257,6 +263,7 @@ pub(all) enum Msg {
|
|||||||
WClear
|
WClear
|
||||||
OpenDrawer
|
OpenDrawer
|
||||||
CloseDrawer
|
CloseDrawer
|
||||||
|
DrawerClosed(Int32)
|
||||||
OpenApp(Int32)
|
OpenApp(Int32)
|
||||||
OpenFirst
|
OpenFirst
|
||||||
OpenHome(Int32)
|
OpenHome(Int32)
|
||||||
@@ -278,6 +285,9 @@ pub(all) enum Msg {
|
|||||||
Settings
|
Settings
|
||||||
Wallpaper
|
Wallpaper
|
||||||
Recents
|
Recents
|
||||||
|
RecentsUnavailable
|
||||||
|
OpenAccessibilitySettings
|
||||||
|
OpenSelfAppInfo
|
||||||
CheckUpdates
|
CheckUpdates
|
||||||
Lift(Int32)
|
Lift(Int32)
|
||||||
Grab(Int32)
|
Grab(Int32)
|
||||||
@@ -301,6 +311,8 @@ pub(all) enum Effect {
|
|||||||
OpenSettings
|
OpenSettings
|
||||||
PickWallpaper
|
PickWallpaper
|
||||||
OpenRecents
|
OpenRecents
|
||||||
|
OpenAccessibilitySettings
|
||||||
|
OpenSelfAppInfo
|
||||||
Haptic
|
Haptic
|
||||||
/// Fetch apps.json / widgets.json and answer `AppsLoaded` / `WidgetsLoaded`.
|
/// Fetch apps.json / widgets.json and answer `AppsLoaded` / `WidgetsLoaded`.
|
||||||
LoadApps
|
LoadApps
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ pub(all) enum Effect {
|
|||||||
OpenSettings
|
OpenSettings
|
||||||
PickWallpaper
|
PickWallpaper
|
||||||
OpenRecents
|
OpenRecents
|
||||||
|
OpenAccessibilitySettings
|
||||||
|
OpenSelfAppInfo
|
||||||
Haptic
|
Haptic
|
||||||
LoadApps
|
LoadApps
|
||||||
LoadWidgets
|
LoadWidgets
|
||||||
@@ -122,6 +124,8 @@ pub(all) struct Model {
|
|||||||
mut query : String
|
mut query : String
|
||||||
mut wquery : String
|
mut wquery : String
|
||||||
mut drawer : Bool
|
mut drawer : Bool
|
||||||
|
mut drawer_closing : Bool
|
||||||
|
mut drawer_gen : Int32
|
||||||
mut picking : Bool
|
mut picking : Bool
|
||||||
mut sheet : Sheet
|
mut sheet : Sheet
|
||||||
mut gone : String
|
mut gone : String
|
||||||
@@ -147,10 +151,12 @@ pub(all) struct Model {
|
|||||||
mut gesture : @gesture.State
|
mut gesture : @gesture.State
|
||||||
}
|
}
|
||||||
pub fn Model::app_row(Self, String) -> Int32
|
pub fn Model::app_row(Self, String) -> Int32
|
||||||
|
pub fn Model::drawer_open(Self) -> Bool
|
||||||
pub fn Model::first_match(Self) -> Int32
|
pub fn Model::first_match(Self) -> Int32
|
||||||
pub fn Model::first_widget_match(Self) -> Int32
|
pub fn Model::first_widget_match(Self) -> Int32
|
||||||
pub fn Model::hidden(Self, Int32) -> Bool
|
pub fn Model::hidden(Self, Int32) -> Bool
|
||||||
pub fn Model::home_of(Self, Int32) -> Int32
|
pub fn Model::home_of(Self, Int32) -> Int32
|
||||||
|
pub fn Model::icon_keys(Self) -> Array[String]
|
||||||
pub fn Model::new() -> Self
|
pub fn Model::new() -> Self
|
||||||
pub fn Model::packed(Self) -> @grid.Packed
|
pub fn Model::packed(Self) -> @grid.Packed
|
||||||
pub fn Model::slot_of_widget(Self, Int32) -> Int32
|
pub fn Model::slot_of_widget(Self, Int32) -> Int32
|
||||||
@@ -182,6 +188,7 @@ pub(all) enum Msg {
|
|||||||
WClear
|
WClear
|
||||||
OpenDrawer
|
OpenDrawer
|
||||||
CloseDrawer
|
CloseDrawer
|
||||||
|
DrawerClosed(Int32)
|
||||||
OpenApp(Int32)
|
OpenApp(Int32)
|
||||||
OpenFirst
|
OpenFirst
|
||||||
OpenHome(Int32)
|
OpenHome(Int32)
|
||||||
@@ -202,6 +209,9 @@ pub(all) enum Msg {
|
|||||||
Settings
|
Settings
|
||||||
Wallpaper
|
Wallpaper
|
||||||
Recents
|
Recents
|
||||||
|
RecentsUnavailable
|
||||||
|
OpenAccessibilitySettings
|
||||||
|
OpenSelfAppInfo
|
||||||
CheckUpdates
|
CheckUpdates
|
||||||
Lift(Int32)
|
Lift(Int32)
|
||||||
Grab(Int32)
|
Grab(Int32)
|
||||||
@@ -228,6 +238,7 @@ pub(all) enum Sheet {
|
|||||||
Item(Int32)
|
Item(Int32)
|
||||||
DrawerApp(Int32)
|
DrawerApp(Int32)
|
||||||
WidgetPicker
|
WidgetPicker
|
||||||
|
RecentsSetup
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(all) struct WidgetInfo {
|
pub(all) struct WidgetInfo {
|
||||||
|
|||||||
+90
-2
@@ -249,6 +249,21 @@ fn cell_center(col : Int32, row : Int32) -> (Double, Double) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
/// Finish the pending drawer-close animation timer.
|
||||||
|
fn Sim::finish_drawer_close(self : Sim) -> Unit {
|
||||||
|
let mut gen : Int32? = None
|
||||||
|
for e in self.log {
|
||||||
|
if e is Delay(_, DrawerClosed(g)) {
|
||||||
|
gen = Some(g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match gen {
|
||||||
|
Some(g) => self.send(DrawerClosed(g))
|
||||||
|
None => abort("no pending DrawerClosed timer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
/// Add apps to the home screen through the long-press menu and the drawer's pick mode.
|
/// Add apps to the home screen through the long-press menu and the drawer's pick mode.
|
||||||
fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
|
fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
|
||||||
@@ -258,6 +273,7 @@ fn Sim::add_apps(self : Sim, labels : Array[String]) -> Unit {
|
|||||||
self.tap("tile", label=l, from=1) // the drawer's, not the home screen's under it
|
self.tap("tile", label=l, from=1) // the drawer's, not the home screen's under it
|
||||||
}
|
}
|
||||||
self.tap("btn", label="Done")
|
self.tap("btn", label="Done")
|
||||||
|
self.finish_drawer_close()
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
@@ -294,7 +310,9 @@ test "add apps through the drawer's pick mode" {
|
|||||||
s.tap("tile", label="Phone", from=1)
|
s.tap("tile", label="Phone", from=1)
|
||||||
s.tap("tile", label="Gmail", from=1) // toggled off again
|
s.tap("tile", label="Gmail", from=1) // toggled off again
|
||||||
s.tap("btn", label="Done")
|
s.tap("btn", label="Done")
|
||||||
assert_true(!s.m.drawer)
|
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||||
|
s.finish_drawer_close()
|
||||||
|
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||||
assert_eq(s.home_names(), ["Chrome", "Phone"])
|
assert_eq(s.home_names(), ["Chrome", "Phone"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,8 +325,10 @@ test "swipe down opens the drawer, swipe up closes it" {
|
|||||||
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=false))
|
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=false))
|
||||||
assert_true(s.m.drawer) // the list isn't at its end yet
|
assert_true(s.m.drawer) // the list isn't at its end yet
|
||||||
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=true))
|
s.send(Touch(dx=3.0, dy=-120.0, ms=200, home_top=false, list_end=true))
|
||||||
assert_true(!s.m.drawer)
|
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||||
assert_true(s.has_effect(HideKeyboard))
|
assert_true(s.has_effect(HideKeyboard))
|
||||||
|
s.finish_drawer_close()
|
||||||
|
assert_true(!s.m.drawer)
|
||||||
s.send(Touch(dx=3.0, dy=40.0, ms=200, home_top=true, list_end=false))
|
s.send(Touch(dx=3.0, dy=40.0, ms=200, home_top=true, list_end=false))
|
||||||
assert_true(!s.m.drawer) // too short
|
assert_true(!s.m.drawer) // too short
|
||||||
}
|
}
|
||||||
@@ -703,6 +723,8 @@ test "back and home close things from the top down" {
|
|||||||
assert_eq(s.m.sheet, NoSheet)
|
assert_eq(s.m.sheet, NoSheet)
|
||||||
assert_true(s.m.drawer)
|
assert_true(s.m.drawer)
|
||||||
s.send(Back)
|
s.send(Back)
|
||||||
|
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||||
|
s.finish_drawer_close()
|
||||||
assert_true(!s.m.drawer)
|
assert_true(!s.m.drawer)
|
||||||
s.send(OpenDrawer)
|
s.send(OpenDrawer)
|
||||||
s.send(GoHome)
|
s.send(GoHome)
|
||||||
@@ -902,3 +924,69 @@ test "view snapshot: home with an app" {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
test "RecentsUnavailable opens setup sheet with settings and app info actions" {
|
||||||
|
let s = Sim::new()
|
||||||
|
s.send(RecentsUnavailable)
|
||||||
|
assert_eq(s.m.sheet, RecentsSetup)
|
||||||
|
let html = s.sheet_html()
|
||||||
|
assert_true(html.contains("Enable window list"))
|
||||||
|
assert_true(html.contains("Restricted setting"))
|
||||||
|
assert_true(html.contains("Allow restricted settings"))
|
||||||
|
s.tap("btn", label="Open Accessibility settings")
|
||||||
|
assert_true(s.has_effect(OpenAccessibilitySettings))
|
||||||
|
assert_eq(s.m.sheet, RecentsSetup)
|
||||||
|
s.tap("btn", label="Open App info")
|
||||||
|
assert_true(s.has_effect(OpenSelfAppInfo))
|
||||||
|
assert_eq(s.m.sheet, RecentsSetup)
|
||||||
|
s.tap("btn", label="Close")
|
||||||
|
assert_eq(s.m.sheet, NoSheet)
|
||||||
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
test "drawer close animation lifecycle and reopening cancels stale close" {
|
||||||
|
let s = Sim::new()
|
||||||
|
s.send(OpenDrawer)
|
||||||
|
assert_true(s.m.drawer_open())
|
||||||
|
s.send(CloseDrawer)
|
||||||
|
assert_true(s.m.drawer && s.m.drawer_closing)
|
||||||
|
assert_true(!s.m.drawer_open())
|
||||||
|
assert_true(s.has_effect(HideKeyboard))
|
||||||
|
let stale_gen = s.m.drawer_gen
|
||||||
|
assert_true(s.has_effect(Delay(140, DrawerClosed(stale_gen))))
|
||||||
|
assert_true(@vdom.to_html(s.tree[1]).contains("drawer closing"))
|
||||||
|
// Reopening while closing cancels the pending close
|
||||||
|
s.send(OpenDrawer)
|
||||||
|
assert_true(s.m.drawer_open())
|
||||||
|
assert_true(!s.m.drawer_closing)
|
||||||
|
s.send(DrawerClosed(stale_gen))
|
||||||
|
assert_true(s.m.drawer_open())
|
||||||
|
// Launching an app closes immediately with no closing animation delay
|
||||||
|
s.tap("tile", label="Chrome", from=1)
|
||||||
|
assert_true(s.has_effect(Launch("c.chrome/.Main")))
|
||||||
|
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||||
|
// First-match Enter and GoHome also close immediately
|
||||||
|
s.send(OpenDrawer)
|
||||||
|
let c = s.chain("input")
|
||||||
|
s.run(typed(s.m, s.table, c, "cal"))
|
||||||
|
s.run(key(s.m, s.table, c, Enter))
|
||||||
|
assert_true(!s.m.drawer && !s.m.drawer_closing)
|
||||||
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
test "top-level view nodes have distinct non-zero keys" {
|
||||||
|
let s = Sim::new()
|
||||||
|
s.send(OpenDrawer)
|
||||||
|
s.send(AppMenu(0))
|
||||||
|
s.m.notice = "Added to home"
|
||||||
|
let keys : Array[Int32] = []
|
||||||
|
for n in view(s.m) {
|
||||||
|
if n is El(e) {
|
||||||
|
assert_true(e.key != 0)
|
||||||
|
assert_true(!keys.contains(e.key))
|
||||||
|
keys.push(e.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_eq(keys, [1, 2, 3, 4, 6])
|
||||||
|
}
|
||||||
+73
-18
@@ -155,13 +155,48 @@ fn Model::drop_gone(self : Model, fx : Array[Effect]) -> Unit {
|
|||||||
self.gone = ""
|
self.gone = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
/// Whether the drawer is open and not currently animating out.
|
||||||
|
pub fn Model::drawer_open(self : Model) -> Bool {
|
||||||
|
self.drawer && !self.drawer_closing
|
||||||
|
}
|
||||||
|
|
||||||
|
///|
|
||||||
|
/// App icon keys in priority order: home-screen apps first, then the rest of the app list.
|
||||||
|
pub fn Model::icon_keys(self : Model) -> Array[String] {
|
||||||
|
let out : Array[String] = []
|
||||||
|
let seen : Map[String, Bool] = Map([])
|
||||||
|
for s in self.home {
|
||||||
|
if s.kind == App {
|
||||||
|
let row = self.app_row(s.str)
|
||||||
|
if row >= 0 {
|
||||||
|
let k = self.apps[row].icon
|
||||||
|
if k != "" && !seen.contains(k) {
|
||||||
|
seen[k] = true
|
||||||
|
out.push(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for a in self.apps {
|
||||||
|
let k = a.icon
|
||||||
|
if k != "" && !seen.contains(k) {
|
||||||
|
seen[k] = true
|
||||||
|
out.push(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
|
fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
|
||||||
if self.drawer {
|
if self.drawer && !self.drawer_closing {
|
||||||
fx.push(HideKeyboard)
|
fx.push(HideKeyboard)
|
||||||
}
|
}
|
||||||
self.query = ""
|
self.query = ""
|
||||||
self.drawer = false
|
self.drawer = false
|
||||||
|
self.drawer_closing = false
|
||||||
|
self.drawer_gen += 1
|
||||||
self.picking = false
|
self.picking = false
|
||||||
self.sheet = NoSheet
|
self.sheet = NoSheet
|
||||||
self.lifted = -1
|
self.lifted = -1
|
||||||
@@ -173,19 +208,23 @@ fn Model::close_all(self : Model, fx : Array[Effect]) -> Unit {
|
|||||||
|
|
||||||
///|
|
///|
|
||||||
fn Model::open_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
fn Model::open_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
||||||
if self.sheet == NoSheet && !self.drawer {
|
if self.sheet == NoSheet && !self.drawer_open() {
|
||||||
self.drawer = true
|
self.drawer = true
|
||||||
|
self.drawer_closing = false
|
||||||
|
self.drawer_gen += 1
|
||||||
|
self.picking = false
|
||||||
|
self.query = ""
|
||||||
fx.push(FocusSearch)
|
fx.push(FocusSearch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
fn Model::close_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
fn Model::close_drawer(self : Model, fx : Array[Effect]) -> Unit {
|
||||||
if self.drawer && self.sheet == NoSheet {
|
if self.drawer_open() && self.sheet == NoSheet {
|
||||||
self.drawer = false
|
self.drawer_closing = true
|
||||||
self.picking = false
|
self.drawer_gen += 1
|
||||||
self.query = ""
|
|
||||||
fx.push(HideKeyboard)
|
fx.push(HideKeyboard)
|
||||||
|
fx.push(Delay(140, DrawerClosed(self.drawer_gen)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,11 +557,8 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
m.resizing = -1
|
m.resizing = -1
|
||||||
} else if m.sheet != NoSheet {
|
} else if m.sheet != NoSheet {
|
||||||
m.sheet = NoSheet
|
m.sheet = NoSheet
|
||||||
} else if m.drawer {
|
} else if m.drawer_open() {
|
||||||
m.drawer = false
|
m.close_drawer(fx)
|
||||||
m.picking = false
|
|
||||||
m.query = ""
|
|
||||||
fx.push(HideKeyboard)
|
|
||||||
}
|
}
|
||||||
WidgetAdded(id) =>
|
WidgetAdded(id) =>
|
||||||
if m.chosen >= 0 &&
|
if m.chosen >= 0 &&
|
||||||
@@ -543,7 +579,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
}
|
}
|
||||||
WidgetMenu(wid) => {
|
WidgetMenu(wid) => {
|
||||||
let i = m.slot_of_widget(wid)
|
let i = m.slot_of_widget(wid)
|
||||||
if i >= 0 && !m.drawer && m.sheet == NoSheet {
|
if i >= 0 && !m.drawer_open() && m.sheet == NoSheet {
|
||||||
m.resizing = -1
|
m.resizing = -1
|
||||||
m.regrab = false
|
m.regrab = false
|
||||||
m.lifted = i
|
m.lifted = i
|
||||||
@@ -552,7 +588,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
}
|
}
|
||||||
WidgetGrab(wid) => {
|
WidgetGrab(wid) => {
|
||||||
let i = m.slot_of_widget(wid)
|
let i = m.slot_of_widget(wid)
|
||||||
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
|
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
|
||||||
m.resizing = -1
|
m.resizing = -1
|
||||||
m.regrab = true
|
m.regrab = true
|
||||||
m.lifted = i
|
m.lifted = i
|
||||||
@@ -577,8 +613,8 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
Touch(dx~, dy~, ms~, home_top~, list_end~) =>
|
Touch(dx~, dy~, ms~, home_top~, list_end~) =>
|
||||||
if !m.dragged && m.lifted < 0 && m.sheet == NoSheet {
|
if !m.dragged && m.lifted < 0 && m.sheet == NoSheet {
|
||||||
match @gesture.classify_swipe(dx, dy, ms) {
|
match @gesture.classify_swipe(dx, dy, ms) {
|
||||||
Some(Down) => if !m.drawer && home_top { m.open_drawer(fx) }
|
Some(Down) => if !m.drawer_open() && home_top { m.open_drawer(fx) }
|
||||||
Some(Up) => if m.drawer && list_end { m.close_drawer(fx) }
|
Some(Up) => if m.drawer_open() && list_end { m.close_drawer(fx) }
|
||||||
None => ()
|
None => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,6 +669,13 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
WClear => m.wquery = ""
|
WClear => m.wquery = ""
|
||||||
OpenDrawer => m.open_drawer(fx)
|
OpenDrawer => m.open_drawer(fx)
|
||||||
CloseDrawer => m.close_drawer(fx)
|
CloseDrawer => m.close_drawer(fx)
|
||||||
|
DrawerClosed(gen) =>
|
||||||
|
if gen == m.drawer_gen && m.drawer_closing {
|
||||||
|
m.drawer = false
|
||||||
|
m.drawer_closing = false
|
||||||
|
m.picking = false
|
||||||
|
m.query = ""
|
||||||
|
}
|
||||||
OpenApp(row) =>
|
OpenApp(row) =>
|
||||||
if row >= 0 && row < m.apps.length() {
|
if row >= 0 && row < m.apps.length() {
|
||||||
fx.push(Launch(m.apps[row].component))
|
fx.push(Launch(m.apps[row].component))
|
||||||
@@ -663,7 +706,7 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppMenu(row) =>
|
AppMenu(row) =>
|
||||||
if m.drawer && m.sheet == NoSheet {
|
if m.drawer_open() && m.sheet == NoSheet {
|
||||||
fx.push(Haptic)
|
fx.push(Haptic)
|
||||||
m.sheet = DrawerApp(row)
|
m.sheet = DrawerApp(row)
|
||||||
}
|
}
|
||||||
@@ -685,7 +728,10 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
PickApps => {
|
PickApps => {
|
||||||
m.sheet = NoSheet
|
m.sheet = NoSheet
|
||||||
m.drawer = true
|
m.drawer = true
|
||||||
|
m.drawer_closing = false
|
||||||
|
m.drawer_gen += 1
|
||||||
m.picking = true
|
m.picking = true
|
||||||
|
m.query = ""
|
||||||
}
|
}
|
||||||
PickWidget => {
|
PickWidget => {
|
||||||
m.sheet = WidgetPicker
|
m.sheet = WidgetPicker
|
||||||
@@ -723,6 +769,12 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
m.sheet = NoSheet
|
m.sheet = NoSheet
|
||||||
}
|
}
|
||||||
Recents => fx.push(OpenRecents)
|
Recents => fx.push(OpenRecents)
|
||||||
|
RecentsUnavailable => {
|
||||||
|
m.resizing = -1
|
||||||
|
m.sheet = RecentsSetup
|
||||||
|
}
|
||||||
|
OpenAccessibilitySettings => fx.push(OpenAccessibilitySettings)
|
||||||
|
OpenSelfAppInfo => fx.push(OpenSelfAppInfo)
|
||||||
CheckUpdates => {
|
CheckUpdates => {
|
||||||
m.sheet = NoSheet
|
m.sheet = NoSheet
|
||||||
if m.checking {
|
if m.checking {
|
||||||
@@ -735,14 +787,17 @@ fn step(m : Model, msg : Msg, fx : Array[Effect]) -> Unit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lift(i) =>
|
Lift(i) =>
|
||||||
if !m.drawer && m.sheet == NoSheet && i != m.lifted && i < m.home.length() {
|
if !m.drawer_open() &&
|
||||||
|
m.sheet == NoSheet &&
|
||||||
|
i != m.lifted &&
|
||||||
|
i < m.home.length() {
|
||||||
fx.push(Haptic)
|
fx.push(Haptic)
|
||||||
m.resizing = -1
|
m.resizing = -1
|
||||||
m.regrab = false
|
m.regrab = false
|
||||||
m.lifted = i
|
m.lifted = i
|
||||||
}
|
}
|
||||||
Grab(i) =>
|
Grab(i) =>
|
||||||
if i >= 0 && i == m.resizing && !m.drawer && m.sheet == NoSheet {
|
if i >= 0 && i == m.resizing && !m.drawer_open() && m.sheet == NoSheet {
|
||||||
m.resizing = -1
|
m.resizing = -1
|
||||||
m.regrab = true
|
m.regrab = true
|
||||||
m.lifted = i
|
m.lifted = i
|
||||||
|
|||||||
+75
-6
@@ -42,7 +42,7 @@ fn Model::view_slot(
|
|||||||
let style = cell_style(cell)
|
let style = cell_style(cell)
|
||||||
match s.kind {
|
match s.kind {
|
||||||
Widget => {
|
Widget => {
|
||||||
let live = !self.drawer &&
|
let live = !self.drawer_open() &&
|
||||||
self.sheet == NoSheet &&
|
self.sheet == NoSheet &&
|
||||||
(self.resizing < 0 || i == self.resizing)
|
(self.resizing < 0 || i == self.resizing)
|
||||||
let attrs = [("data-slot", i.to_string())]
|
let attrs = [("data-slot", i.to_string())]
|
||||||
@@ -165,6 +165,7 @@ fn Model::view_home(self : Model) -> Node[Msg] {
|
|||||||
}
|
}
|
||||||
el(
|
el(
|
||||||
"div",
|
"div",
|
||||||
|
key=1,
|
||||||
classes=["home"],
|
classes=["home"],
|
||||||
handlers={
|
handlers={
|
||||||
..Handlers::none(),
|
..Handlers::none(),
|
||||||
@@ -255,7 +256,16 @@ fn Model::view_drawer(self : Model) -> Node[Msg] {
|
|||||||
} else if tiles.length() == 0 {
|
} else if tiles.length() == 0 {
|
||||||
children.push(el("p", classes=["empty"], children=[text("No apps match.")]))
|
children.push(el("p", classes=["empty"], children=[text("No apps match.")]))
|
||||||
}
|
}
|
||||||
el("div", classes=["drawer", cls_if("picking", self.picking)], children~)
|
el(
|
||||||
|
"div",
|
||||||
|
key=2,
|
||||||
|
classes=[
|
||||||
|
"drawer",
|
||||||
|
cls_if("picking", self.picking),
|
||||||
|
cls_if("closing", self.drawer_closing),
|
||||||
|
],
|
||||||
|
children~,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
@@ -379,11 +389,70 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RecentsSetup => {
|
||||||
|
items.push(sheet_title("Enable window list"))
|
||||||
|
items.push(
|
||||||
|
el("p", classes=["sheet-copy"], children=[
|
||||||
|
text(
|
||||||
|
"Android only lets accessibility services open Recents, and blocks them on sideloaded apps until you allow restricted settings once (it stays allowed across updates). This service reads nothing on screen.",
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
items.push(
|
||||||
|
el("ol", classes=["sheet-steps"], children=[
|
||||||
|
el("li", children=[
|
||||||
|
text("Tap "),
|
||||||
|
el("strong", children=[text("Open Accessibility settings")]),
|
||||||
|
text(" and tap "),
|
||||||
|
el("strong", children=[text("ultra Home window list")]),
|
||||||
|
text("."),
|
||||||
|
]),
|
||||||
|
el("li", children=[
|
||||||
|
text("If Android says "),
|
||||||
|
el("strong", children=[text("Restricted setting")]),
|
||||||
|
text(", return here, tap "),
|
||||||
|
el("strong", children=[text("Open App info")]),
|
||||||
|
text(", then tap "),
|
||||||
|
el("strong", children=[text("⋮")]),
|
||||||
|
text(" (or scroll to the bottom on Android 15+) → "),
|
||||||
|
el("strong", children=[text("Allow restricted settings")]),
|
||||||
|
text("."),
|
||||||
|
]),
|
||||||
|
el("li", children=[
|
||||||
|
text("Return to "),
|
||||||
|
el("strong", children=[text("Accessibility settings")]),
|
||||||
|
text(" and turn on "),
|
||||||
|
el("strong", children=[text("ultra Home window list")]),
|
||||||
|
text("."),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
items.push(
|
||||||
|
el("div", classes=["sheet-actions"], children=[
|
||||||
|
el(
|
||||||
|
"button",
|
||||||
|
classes=["btn"],
|
||||||
|
handlers=tap(OpenAccessibilitySettings),
|
||||||
|
children=[text("Open Accessibility settings")],
|
||||||
|
),
|
||||||
|
el(
|
||||||
|
"button",
|
||||||
|
classes=["btn", "secondary"],
|
||||||
|
handlers=tap(OpenSelfAppInfo),
|
||||||
|
children=[text("Open App info")],
|
||||||
|
),
|
||||||
|
el("button", classes=["btn", "ghost"], handlers=tap(CloseSheet), children=[
|
||||||
|
text("Close"),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
el("div", classes=["sheet-overlay"], handlers=tap(CloseSheet)),
|
el("div", key=3, classes=["sheet-overlay"], handlers=tap(CloseSheet)),
|
||||||
el(
|
el(
|
||||||
"div",
|
"div",
|
||||||
|
key=4,
|
||||||
classes=["sheet"],
|
classes=["sheet"],
|
||||||
attrs=[("role", "dialog"), ("aria-modal", "true")],
|
attrs=[("role", "dialog"), ("aria-modal", "true")],
|
||||||
handlers={ ..Handlers::none(), escape: Some(CloseSheet), },
|
handlers={ ..Handlers::none(), escape: Some(CloseSheet), },
|
||||||
@@ -394,7 +463,7 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
|||||||
|
|
||||||
///|
|
///|
|
||||||
fn Model::view_resize_bar(self : Model) -> Node[Msg] {
|
fn Model::view_resize_bar(self : Model) -> Node[Msg] {
|
||||||
el("div", classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
|
el("div", key=5, classes=["resize-bar"], attrs=[("role", "toolbar")], children=[
|
||||||
el("span", classes=["resize-hint"], children=[
|
el("span", classes=["resize-hint"], children=[
|
||||||
text("Drag to move, or drag the handles to resize"),
|
text("Drag to move, or drag the handles to resize"),
|
||||||
]),
|
]),
|
||||||
@@ -419,12 +488,12 @@ pub fn view(m : Model) -> Array[Node[Msg]] {
|
|||||||
}
|
}
|
||||||
if m.sheet != NoSheet {
|
if m.sheet != NoSheet {
|
||||||
out.append(m.view_sheet())
|
out.append(m.view_sheet())
|
||||||
} else if m.resizing >= 0 && !m.drawer {
|
} else if m.resizing >= 0 && !m.drawer_open() {
|
||||||
out.push(m.view_resize_bar())
|
out.push(m.view_resize_bar())
|
||||||
}
|
}
|
||||||
if m.notice != "" {
|
if m.notice != "" {
|
||||||
out.push(
|
out.push(
|
||||||
el("div", classes=["notice"], attrs=[("role", "status")], children=[
|
el("div", key=6, classes=["notice"], attrs=[("role", "status")], children=[
|
||||||
text(m.notice),
|
text(m.notice),
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
|
|||||||
+62
-7
@@ -28,6 +28,7 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
p.on("pageerror", (e) => { console.error("page error:", e.message); process.exitCode = 1; });
|
p.on("pageerror", (e) => { console.error("page error:", e.message); process.exitCode = 1; });
|
||||||
await p.addInitScript((release) => {
|
await p.addInitScript((release) => {
|
||||||
window.__calls = [];
|
window.__calls = [];
|
||||||
|
window.__recentsEnabled = true;
|
||||||
const rec = (n) => (...a) => { window.__calls.push([n, ...a]); };
|
const rec = (n) => (...a) => { window.__calls.push([n, ...a]); };
|
||||||
const disc = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><circle cx='4' cy='4' r='4' fill='red'/></svg>");
|
const disc = "data:image/svg+xml," + encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><circle cx='4' cy='4' r='4' fill='red'/></svg>");
|
||||||
window.Android = {
|
window.Android = {
|
||||||
@@ -38,7 +39,11 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
widgetLimits: () => JSON.stringify({ w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }),
|
widgetLimits: () => JSON.stringify({ w: 110, minW: 64, minH: 64, maxW: 0, maxH: 0, h: true, v: true }),
|
||||||
loadIcons: (json) => { rec("loadIcons")(json); const o = {}; for (const k of JSON.parse(json)) o[k] = disc; setTimeout(() => window.launcher.icons(o), 0); },
|
loadIcons: (json) => { rec("loadIcons")(json); const o = {}; for (const k of JSON.parse(json)) o[k] = disc; setTimeout(() => window.launcher.icons(o), 0); },
|
||||||
haptic: rec("haptic"), showKeyboard: rec("showKeyboard"), hideKeyboard: rec("hideKeyboard"),
|
haptic: rec("haptic"), showKeyboard: rec("showKeyboard"), hideKeyboard: rec("hideKeyboard"),
|
||||||
openSettings: rec("openSettings"), pickWallpaper: rec("pickWallpaper"), openRecents: rec("openRecents"),
|
openSettings: rec("openSettings"), pickWallpaper: rec("pickWallpaper"),
|
||||||
|
recentsEnabled: () => !!window.__recentsEnabled,
|
||||||
|
openRecents: () => { rec("openRecents")(); return !!window.__recentsEnabled; },
|
||||||
|
openAccessibilitySettings: rec("openAccessibilitySettings"),
|
||||||
|
openSelfAppInfo: rec("openSelfAppInfo"),
|
||||||
httpGet: (url, tag) => { rec("httpGet")(url, tag);
|
httpGet: (url, tag) => { rec("httpGet")(url, tag);
|
||||||
setTimeout(() => window.launcher.httpResult(tag, true, url.endsWith("/latest") ? release : JSON.stringify({ versionCode: 9, commit: "abc" })), 0); },
|
setTimeout(() => window.launcher.httpResult(tag, true, url.endsWith("/latest") ? release : JSON.stringify({ versionCode: 9, commit: "abc" })), 0); },
|
||||||
installApk: rec("installApk"), installedVersion: () => 5, declinedVersion: () => -1,
|
installApk: rec("installApk"), installedVersion: () => 5, declinedVersion: () => -1,
|
||||||
@@ -56,6 +61,14 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
await p.reload();
|
await p.reload();
|
||||||
await p.waitForSelector(".hint");
|
await p.waitForSelector(".hint");
|
||||||
assert.ok(!(await p.evaluate(() => document.documentElement.classList.contains("demo"))), "no demo backdrop on a phone");
|
assert.ok(!(await p.evaluate(() => document.documentElement.classList.contains("demo"))), "no demo backdrop on a phone");
|
||||||
|
const bg = await p.evaluate(() => ({
|
||||||
|
htmlColor: getComputedStyle(document.documentElement).backgroundColor,
|
||||||
|
htmlImage: getComputedStyle(document.documentElement).backgroundImage,
|
||||||
|
bodyColor: getComputedStyle(document.body).backgroundColor,
|
||||||
|
}));
|
||||||
|
assert.equal(bg.htmlColor, "rgba(0, 0, 0, 0)", "html background is transparent on Android");
|
||||||
|
assert.equal(bg.bodyColor, "rgba(0, 0, 0, 0)", "body background is transparent on Android");
|
||||||
|
assert.equal(bg.htmlImage, "none", "no demo gradient on Android");
|
||||||
|
|
||||||
// on start the page checks for an update: release API, then version.json, then installs build 9 over 5
|
// on start the page checks for an update: release API, then version.json, then installs build 9 over 5
|
||||||
await p.waitForFunction(() => window.__calls.some((c) => c[0] === "installApk"));
|
await p.waitForFunction(() => window.__calls.some((c) => c[0] === "installApk"));
|
||||||
@@ -64,10 +77,17 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
assert.deepEqual((await calls("installApk"))[0].slice(1), ["https://x/a.apk", 9]);
|
assert.deepEqual((await calls("installApk"))[0].slice(1), ["https://x/a.apk", 9]);
|
||||||
assert.equal(await p.textContent(".notice"), "Downloading launcher update (build 9)…");
|
assert.equal(await p.textContent(".notice"), "Downloading launcher update (build 9)…");
|
||||||
|
|
||||||
|
// app icons are pre-warmed right after apps.json loads, before opening the drawer
|
||||||
|
await p.waitForFunction(() => window.__calls.some((c) => c[0] === "loadIcons"));
|
||||||
|
assert.ok((await calls("loadIcons")).length > 0, "icons are pre-warmed before opening the drawer");
|
||||||
|
|
||||||
// the drawer asks the shell for icons (batched, by key) and fills the images from its answer
|
// the drawer asks the shell for icons (batched, by key) and fills the images from its answer
|
||||||
await p.evaluate(() => document.body.dispatchEvent(Object.assign(new Event("x"), {})));
|
await p.evaluate(() => document.body.dispatchEvent(Object.assign(new Event("x"), {})));
|
||||||
await longpress(".hint");
|
await longpress(".hint");
|
||||||
|
await p.evaluate(() => { document.querySelector(".sheet-overlay").__tag = "overlay"; });
|
||||||
await p.click(".sheet-item >> text=Add apps"); await settle();
|
await p.click(".sheet-item >> text=Add apps"); await settle();
|
||||||
|
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle sheet-overlay");
|
||||||
|
assert.equal(await p.$eval(".drawer", (d) => getComputedStyle(d).backdropFilter), "none", "no full-screen backdrop blur");
|
||||||
assert.ok((await calls("loadIcons")).length > 0, "icons are asked for");
|
assert.ok((await calls("loadIcons")).length > 0, "icons are asked for");
|
||||||
assert.ok(!(await calls("showKeyboard")).length, "no keyboard in pick mode");
|
assert.ok(!(await calls("showKeyboard")).length, "no keyboard in pick mode");
|
||||||
await p.click(".apps .tile:nth-child(4)"); await p.click(".drawer-head >> text=Done"); await settle();
|
await p.click(".apps .tile:nth-child(4)"); await p.click(".drawer-head >> text=Done"); await settle();
|
||||||
@@ -75,9 +95,28 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
await p.click(".slots .tile"); await settle();
|
await p.click(".slots .tile"); await settle();
|
||||||
assert.deepEqual((await calls("launch"))[0].slice(1), ["com.example.chrome/.MainActivity"]);
|
assert.deepEqual((await calls("launch"))[0].slice(1), ["com.example.chrome/.MainActivity"]);
|
||||||
|
|
||||||
// Windows asks the shell for Recents; settings and wallpaper too
|
// Windows asks the shell for Recents when enabled, and opens setup sheet when disabled
|
||||||
await p.click(".panel-btn"); await settle();
|
await p.click(".panel-btn"); await settle();
|
||||||
assert.equal((await calls("openRecents")).length, 1);
|
assert.equal((await calls("openRecents")).length, 1);
|
||||||
|
assert.ok(!(await p.$(".sheet")), "no setup sheet when RecentsService is running");
|
||||||
|
|
||||||
|
await p.evaluate(() => { window.__recentsEnabled = false; });
|
||||||
|
await p.click(".panel-btn");
|
||||||
|
await p.waitForSelector(".sheet");
|
||||||
|
assert.equal((await calls("openRecents")).length, 2);
|
||||||
|
assert.equal(await p.textContent(".sheet-title"), "Enable window list");
|
||||||
|
const setupText = await p.textContent(".sheet");
|
||||||
|
assert.ok(setupText.includes("Restricted setting"), "explains Android 13+ Restricted setting");
|
||||||
|
assert.ok(setupText.includes("Allow restricted settings"), "explains Allow restricted settings step");
|
||||||
|
await p.click(".sheet button:has-text('Open Accessibility settings')"); await settle();
|
||||||
|
assert.equal((await calls("openAccessibilitySettings")).length, 1);
|
||||||
|
assert.ok(await p.$(".sheet"), "setup sheet stays open while user checks Settings");
|
||||||
|
await p.click(".sheet button:has-text('Open App info')"); await settle();
|
||||||
|
assert.equal((await calls("openSelfAppInfo")).length, 1);
|
||||||
|
assert.ok(await p.$(".sheet"), "setup sheet stays open while user checks App info");
|
||||||
|
await p.click(".sheet button:has-text('Close')"); await settle();
|
||||||
|
assert.ok(!(await p.$(".sheet")), "Close dismisses setup sheet");
|
||||||
|
await p.evaluate(() => { window.__recentsEnabled = true; });
|
||||||
|
|
||||||
// add a widget: the shell binds it and the page places it over its slot (wid, x, y, w, h, editing)
|
// add a widget: the shell binds it and the page places it over its slot (wid, x, y, w, h, editing)
|
||||||
await longpress(".home", 0.95);
|
await longpress(".home", 0.95);
|
||||||
@@ -95,14 +134,17 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
assert.ok(w < 358, "starts at its natural width, not the whole row"); // 110px natural = 2 columns
|
assert.ok(w < 358, "starts at its natural width, not the whole row"); // 110px natural = 2 columns
|
||||||
|
|
||||||
// opening the drawer: the shell is told to cover the widgets, the keyboard comes up, widgets are unmarked
|
// opening the drawer: the shell is told to cover the widgets, the keyboard comes up, widgets are unmarked
|
||||||
await p.click(".search-pill"); await settle();
|
await p.click(".search-pill");
|
||||||
await p.waitForSelector(".drawer");
|
await p.waitForSelector(".drawer");
|
||||||
assert.ok((await calls("coverWidgets")).length > 0, "the shell hides widgets under the drawer");
|
await settle();
|
||||||
|
assert.equal((await calls("coverWidgets")).pop()[1], -1, "the shell hides widgets under the drawer");
|
||||||
assert.ok((await calls("showKeyboard")).length > 0, "the search takes the keyboard");
|
assert.ok((await calls("showKeyboard")).length > 0, "the search takes the keyboard");
|
||||||
assert.equal(await p.$$eval("[data-wid]", (ws) => ws.length), 0);
|
assert.equal(await p.$$eval("[data-wid]", (ws) => ws.length), 0);
|
||||||
await p.click(".drawer-head >> text=Close"); await settle();
|
await p.click(".drawer-head >> text=Close");
|
||||||
|
await p.waitForSelector(".drawer.closing", { timeout: 1000 });
|
||||||
assert.ok((await calls("hideKeyboard")).length > 0);
|
assert.ok((await calls("hideKeyboard")).length > 0);
|
||||||
assert.equal((await calls("coverWidgets")).pop()[1], 0, "the widgets are shown again");
|
assert.equal((await calls("coverWidgets")).pop()[1], 0, "the widgets are shown again as drawer closes");
|
||||||
|
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||||
|
|
||||||
// a long press on the native widget view reaches the page; letting go without moving shows handles,
|
// a long press on the native widget view reaches the page; letting go without moving shows handles,
|
||||||
// and the shell is told to keep its edge swipes off them
|
// and the shell is told to keep its edge swipes off them
|
||||||
@@ -118,13 +160,26 @@ const RELEASE = JSON.stringify({ tag_name: "build-9", assets: [
|
|||||||
await p.click(".resize-bar >> text=Remove"); await settle();
|
await p.click(".resize-bar >> text=Remove"); await settle();
|
||||||
assert.equal((await calls("removeWidget"))[0][1], 77);
|
assert.equal((await calls("removeWidget"))[0][1], 77);
|
||||||
|
|
||||||
|
// opening the drawer while a notice is visible does not recycle .notice as .drawer
|
||||||
|
await longpress(".home", 0.95);
|
||||||
|
await p.click(".sheet-item >> text=Check for updates");
|
||||||
|
await p.waitForSelector(".notice");
|
||||||
|
await p.evaluate(() => { document.querySelector(".notice").__tag = "notice"; });
|
||||||
|
await p.click(".search-pill");
|
||||||
|
await p.waitForSelector(".drawer");
|
||||||
|
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle .notice");
|
||||||
|
assert.equal(await p.$eval(".notice", (n) => n.__tag), "notice", ".notice keeps its DOM element");
|
||||||
|
await p.click(".drawer-head >> text=Close");
|
||||||
|
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||||
|
|
||||||
// a package change: the shell calls reload(), which fetches the app list again and re-asks for icons
|
// a package change: the shell calls reload(), which fetches the app list again and re-asks for icons
|
||||||
const before = (await calls("loadIcons")).length;
|
const before = (await calls("loadIcons")).length;
|
||||||
await p.evaluate(() => window.launcher.reload()); await settle();
|
await p.evaluate(() => window.launcher.reload()); await settle();
|
||||||
assert.ok((await calls("loadIcons")).length > before, "icons are asked for again after a reload");
|
assert.ok((await calls("loadIcons")).length > before, "icons are asked for again after a reload");
|
||||||
// back and home close the drawer
|
// back and home close the drawer
|
||||||
await p.click(".search-pill"); await p.waitForSelector(".drawer");
|
await p.click(".search-pill"); await p.waitForSelector(".drawer");
|
||||||
await p.evaluate(() => window.launcher.back()); await settle();
|
await p.evaluate(() => window.launcher.back());
|
||||||
|
await p.waitForSelector(".drawer", { state: "detached", timeout: 2000 });
|
||||||
assert.ok(!(await p.$(".drawer")));
|
assert.ok(!(await p.$(".drawer")));
|
||||||
console.log("android bridge ok");
|
console.log("android bridge ok");
|
||||||
await b.close(); srv.close();
|
await b.close(); srv.close();
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ const serve = () => new Promise((resolve) => {
|
|||||||
await p.waitForSelector(".hint");
|
await p.waitForSelector(".hint");
|
||||||
await shot(p, "00-blank-home");
|
await shot(p, "00-blank-home");
|
||||||
assert.ok(!(await p.$(".clock")), "home has no built-in clock");
|
assert.ok(!(await p.$(".clock")), "home has no built-in clock");
|
||||||
|
const demoBg = await p.evaluate(() => ({
|
||||||
|
hasDemo: document.documentElement.classList.contains("demo"),
|
||||||
|
htmlBgImage: getComputedStyle(document.documentElement).backgroundImage,
|
||||||
|
bodyBgColor: getComputedStyle(document.body).backgroundColor,
|
||||||
|
}));
|
||||||
|
assert.ok(demoBg.hasDemo, "desktop mode adds .demo class");
|
||||||
|
assert.ok(demoBg.htmlBgImage.includes("linear-gradient"), "desktop mode keeps gradient backdrop");
|
||||||
|
assert.equal(demoBg.bodyBgColor, "rgba(0, 0, 0, 0)", "body itself stays transparent");
|
||||||
const longpress = async (sel, fy = 0.5) => {
|
const longpress = async (sel, fy = 0.5) => {
|
||||||
const r = await p.locator(sel).first().boundingBox();
|
const r = await p.locator(sel).first().boundingBox();
|
||||||
await p.mouse.move(r.x + r.width / 2, r.y + r.height * fy);
|
await p.mouse.move(r.x + r.width / 2, r.y + r.height * fy);
|
||||||
@@ -51,7 +59,9 @@ const serve = () => new Promise((resolve) => {
|
|||||||
const homeApps = () => p.$$eval(".slots .name", (ns) => ns.map((n) => n.textContent));
|
const homeApps = () => p.$$eval(".slots .name", (ns) => ns.map((n) => n.textContent));
|
||||||
// long press on the blank home: add apps through the drawer's pick mode
|
// long press on the blank home: add apps through the drawer's pick mode
|
||||||
await longpress(".hint");
|
await longpress(".hint");
|
||||||
|
await p.evaluate(() => { document.querySelector(".sheet-overlay").__tag = "overlay"; });
|
||||||
await p.click(".sheet-item >> text=Add apps"); await settle();
|
await p.click(".sheet-item >> text=Add apps"); await settle();
|
||||||
|
assert.equal(await p.$eval(".drawer", (d) => d.__tag), undefined, "drawer does not recycle sheet-overlay");
|
||||||
for (const i of [4, 8, 12]) await p.click(`.apps .tile:nth-child(${i})`);
|
for (const i of [4, 8, 12]) await p.click(`.apps .tile:nth-child(${i})`);
|
||||||
await settle();
|
await settle();
|
||||||
assert.equal(await p.$$eval(".apps .tile.on", (ts) => ts.length), 3);
|
assert.equal(await p.$$eval(".apps .tile.on", (ts) => ts.length), 3);
|
||||||
|
|||||||
+16
-13
@@ -172,23 +172,18 @@ extern "js" fn resize_handles() -> String =
|
|||||||
#|() => JSON.stringify([...document.querySelectorAll(".resize-handle")].map((h) => { const r = h.getBoundingClientRect(); return [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]; }))
|
#|() => JSON.stringify([...document.querySelectorAll(".resize-handle")].map((h) => { const r = h.getBoundingClientRect(); return [Math.round(r.left), Math.round(r.top), Math.round(r.width), Math.round(r.height)]; }))
|
||||||
|
|
||||||
///|
|
///|
|
||||||
/// The drawer covers the page down to this y (px); -1 once it covers the screen, 0 when
|
/// Whether the drawer is open and not animating out.
|
||||||
/// there is no drawer. `last` is the previous bottom edge, so the answer can run ahead of it.
|
extern "js" fn drawer_covering() -> Bool =
|
||||||
extern "js" fn drawer_cover(last : Double) -> Double =
|
#|() => !!document.querySelector(".drawer:not(.closing)")
|
||||||
#|(last) => { const d = document.querySelector(".drawer"); if (!d) return 0; const b = d.getBoundingClientRect().bottom; if (b >= innerHeight - 1) return -1; return Math.min(innerHeight - 1, Math.max(0, Math.ceil(b + 2 * Math.max(0, b - last)))); }
|
|
||||||
|
|
||||||
///|
|
///|
|
||||||
extern "js" fn drawer_bottom() -> Double =
|
/// A drawer over the home screen's widgets without a sheet on top (the shell keeps widget views placed while `cover` hides them).
|
||||||
#|() => { const d = document.querySelector(".drawer"); return d ? d.getBoundingClientRect().bottom : 0 }
|
|
||||||
|
|
||||||
///|
|
|
||||||
/// A drawer or sheet over the home screen's widgets (the shell has them step aside).
|
|
||||||
extern "js" fn has_drawer() -> Bool =
|
extern "js" fn has_drawer() -> Bool =
|
||||||
#|() => !!document.querySelector(".drawer") && !document.querySelector(".sheet-overlay")
|
#|() => !!document.querySelector(".drawer:not(.closing)") && !document.querySelector(".sheet-overlay")
|
||||||
|
|
||||||
///|
|
///|
|
||||||
extern "js" fn focus_search() -> Unit =
|
extern "js" fn focus_search() -> Unit =
|
||||||
#|() => { const i = document.querySelector(".drawer:not(.picking) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
|
#|() => { const i = document.querySelector(".drawer:not(.picking):not(.closing) .drawer-head input"); if (i) i.focus({ preventScroll: true }) }
|
||||||
|
|
||||||
///|
|
///|
|
||||||
extern "js" fn blur_active() -> Unit =
|
extern "js" fn blur_active() -> Unit =
|
||||||
@@ -308,8 +303,16 @@ extern "js" fn h_pick_wallpaper() -> Unit =
|
|||||||
#|() => window.Android.pickWallpaper()
|
#|() => window.Android.pickWallpaper()
|
||||||
|
|
||||||
///|
|
///|
|
||||||
extern "js" fn h_open_recents() -> Unit =
|
extern "js" fn h_open_recents() -> Bool =
|
||||||
#|() => window.Android.openRecents()
|
#|() => window.Android.openRecents() !== false
|
||||||
|
|
||||||
|
///|
|
||||||
|
extern "js" fn h_open_accessibility_settings() -> Unit =
|
||||||
|
#|() => window.Android.openAccessibilitySettings && window.Android.openAccessibilitySettings()
|
||||||
|
|
||||||
|
///|
|
||||||
|
extern "js" fn h_open_self_app_info() -> Unit =
|
||||||
|
#|() => window.Android.openSelfAppInfo && window.Android.openSelfAppInfo()
|
||||||
|
|
||||||
///|
|
///|
|
||||||
extern "js" fn h_http_get(url : String, tag : Int32) -> Unit =
|
extern "js" fn h_http_get(url : String, tag : Int32) -> Unit =
|
||||||
|
|||||||
+40
-17
@@ -20,8 +20,6 @@ priv struct PageState {
|
|||||||
mut placed : String
|
mut placed : String
|
||||||
mut excluded : String
|
mut excluded : String
|
||||||
mut cover_y : Int32
|
mut cover_y : Int32
|
||||||
mut cover_last : Double
|
|
||||||
mut cover_loop : Bool
|
|
||||||
mut measured : String
|
mut measured : String
|
||||||
mut touch : (Double, Double, Double)?
|
mut touch : (Double, Double, Double)?
|
||||||
mut demo_widget : Int32
|
mut demo_widget : Int32
|
||||||
@@ -43,8 +41,6 @@ fn PageState::new() -> PageState {
|
|||||||
placed: "",
|
placed: "",
|
||||||
excluded: "[]",
|
excluded: "[]",
|
||||||
cover_y: 0,
|
cover_y: 0,
|
||||||
cover_last: 0.0,
|
|
||||||
cover_loop: false,
|
|
||||||
measured: "",
|
measured: "",
|
||||||
touch: None,
|
touch: None,
|
||||||
demo_widget: 100,
|
demo_widget: 100,
|
||||||
@@ -135,14 +131,31 @@ fn exec(e : @app.Effect) -> Unit {
|
|||||||
}
|
}
|
||||||
OpenRecents =>
|
OpenRecents =>
|
||||||
if android {
|
if android {
|
||||||
h_open_recents()
|
if !h_open_recents() {
|
||||||
|
dispatch(RecentsUnavailable)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast("Show open windows")
|
toast("Show open windows")
|
||||||
}
|
}
|
||||||
|
OpenAccessibilitySettings =>
|
||||||
|
if android {
|
||||||
|
h_open_accessibility_settings()
|
||||||
|
} else {
|
||||||
|
toast("Open Accessibility settings")
|
||||||
|
}
|
||||||
|
OpenSelfAppInfo =>
|
||||||
|
if android {
|
||||||
|
h_open_self_app_info()
|
||||||
|
} else {
|
||||||
|
toast("Open App info")
|
||||||
|
}
|
||||||
Haptic => h_haptic()
|
Haptic => h_haptic()
|
||||||
LoadApps =>
|
LoadApps =>
|
||||||
fetch_text("apps.json", fn(ok, text) {
|
fetch_text("apps.json", fn(ok, text) {
|
||||||
dispatch(AppsLoaded(if ok { Some(text) } else { None }))
|
dispatch(AppsLoaded(if ok { Some(text) } else { None }))
|
||||||
|
if ok {
|
||||||
|
prewarm_app_icons()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
LoadWidgets =>
|
LoadWidgets =>
|
||||||
fetch_text("widgets.json", fn(ok, text) {
|
fetch_text("widgets.json", fn(ok, text) {
|
||||||
@@ -251,28 +264,38 @@ fn place() -> Unit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
/// Native widgets sit above the page, so the drawer can't cover them by itself. While
|
/// Native widgets sit above the page, so the shell hides them while the drawer is open.
|
||||||
/// it slides down the shell hides them above its bottom edge each frame, a little ahead
|
|
||||||
/// of it (by its speed), since the shell trails a frame.
|
|
||||||
fn cover() -> Unit {
|
fn cover() -> Unit {
|
||||||
let st = state.val
|
let st = state.val
|
||||||
let y = drawer_cover(st.cover_last).to_int()
|
let y = if drawer_covering() { -1 } else { 0 }
|
||||||
st.cover_last = drawer_bottom()
|
|
||||||
if y != st.cover_y {
|
if y != st.cover_y {
|
||||||
st.cover_y = y
|
st.cover_y = y
|
||||||
h_cover_widgets(y)
|
h_cover_widgets(y)
|
||||||
}
|
}
|
||||||
if y != 0 && y != -1 && !st.cover_loop {
|
|
||||||
st.cover_loop = true
|
|
||||||
request_frame(fn() {
|
|
||||||
state.val.cover_loop = false
|
|
||||||
cover()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- icons -------------------------------------------------------------------------
|
// ---- icons -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
///|
|
||||||
|
/// Pre-fetch uncached app icons on Android right after apps.json loads so the drawer
|
||||||
|
/// opens with icons ready instead of popping them in during the first open animation.
|
||||||
|
fn prewarm_app_icons() -> Unit {
|
||||||
|
if !h_has_load_icons() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let st = state.val
|
||||||
|
let want : Array[Json] = []
|
||||||
|
for k in model.icon_keys() {
|
||||||
|
if !st.icon_src.contains(k) && !st.icon_asked.contains(k) {
|
||||||
|
st.icon_asked[k] = true
|
||||||
|
want.push(Json::string(k))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if want.length() > 0 {
|
||||||
|
h_load_icons(Json::array(want).stringify())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///|
|
///|
|
||||||
/// Each `<img class="icon" data-icon=KEY>` gets its src from here. On a phone the shell
|
/// Each `<img class="icon" data-icon=KEY>` gets its src from here. On a phone the shell
|
||||||
/// draws icons on its own thread and hands them back as data: URIs in batches, so the
|
/// draws icons on its own thread and hands them back as data: URIs in batches, so the
|
||||||
|
|||||||
+22
-8
@@ -37,7 +37,7 @@ body {
|
|||||||
margin: 0; background: var(--background); color: var(--foreground);
|
margin: 0; background: var(--background); color: var(--foreground);
|
||||||
font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased;
|
font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
.light, .dark { background: var(--background); color: var(--foreground); }
|
.light, .dark { color: var(--foreground); }
|
||||||
button, input { font: inherit; color: inherit; margin: 0; }
|
button, input { font: inherit; color: inherit; margin: 0; }
|
||||||
button { border: 0; background: none; padding: 0; }
|
button { border: 0; background: none; padding: 0; }
|
||||||
:focus-visible { outline: none; }
|
:focus-visible { outline: none; }
|
||||||
@@ -102,7 +102,7 @@ button { border: 0; background: none; padding: 0; }
|
|||||||
--bottom: var(--inset-bottom, env(safe-area-inset-bottom, 0px));
|
--bottom: var(--inset-bottom, env(safe-area-inset-bottom, 0px));
|
||||||
--shadow-text: 0 1px 4px rgb(0 0 0 / .6);
|
--shadow-text: 0 1px 4px rgb(0 0 0 / .6);
|
||||||
}
|
}
|
||||||
html, body { background: transparent; }
|
html, html.dark, html.light, body { background: transparent; }
|
||||||
html.demo { background: linear-gradient(160deg, #1e293b, #4c1d95 55%, #0f172a) fixed; }
|
html.demo { background: linear-gradient(160deg, #1e293b, #4c1d95 55%, #0f172a) fixed; }
|
||||||
body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: transparent;
|
body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: transparent;
|
||||||
user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
|
user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
|
||||||
@@ -204,12 +204,21 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
|
|||||||
background: rgb(255 255 255 / .75); border-radius: 1px; transform: rotate(45deg); }
|
background: rgb(255 255 255 / .75); border-radius: 1px; transform: rotate(45deg); }
|
||||||
button { cursor: pointer; }
|
button { cursor: pointer; }
|
||||||
|
|
||||||
/* ---- drawer: slides down over the home screen */
|
/* ---- drawer: GPU-composited slide+fade over the home screen */
|
||||||
.drawer { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
|
.drawer { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column;
|
||||||
padding: calc(var(--top) + 1rem) 16px 0; background: rgb(10 10 14 / .72);
|
padding: calc(var(--top) + 1rem) 16px 0; background: rgb(10 10 14 / .84);
|
||||||
backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
|
will-change: transform, opacity;
|
||||||
animation: drop .22s cubic-bezier(.2, .8, .2, 1); }
|
animation: drawer-in 180ms cubic-bezier(.2, .8, .2, 1); }
|
||||||
@keyframes drop { from { transform: translateY(-100%); } to { transform: none; } }
|
.drawer.closing { pointer-events: none;
|
||||||
|
animation: drawer-out 140ms cubic-bezier(.4, 0, 1, 1) forwards; }
|
||||||
|
@keyframes drawer-in {
|
||||||
|
from { opacity: 0; transform: translate3d(0, -20px, 0); }
|
||||||
|
to { opacity: 1; transform: translate3d(0, 0, 0); }
|
||||||
|
}
|
||||||
|
@keyframes drawer-out {
|
||||||
|
from { opacity: 1; transform: translate3d(0, 0, 0); }
|
||||||
|
to { opacity: 0; transform: translate3d(0, -16px, 0); }
|
||||||
|
}
|
||||||
.drawer-head { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
|
.drawer-head { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
|
||||||
.drawer-head .input { flex: 1; height: 2.75rem; border-radius: 999px; padding: 0 1.25rem; font-size: 1rem;
|
.drawer-head .input { flex: 1; height: 2.75rem; border-radius: 999px; padding: 0 1.25rem; font-size: 1rem;
|
||||||
background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .15); color: #fff; }
|
background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .15); color: #fff; }
|
||||||
@@ -250,6 +259,11 @@ button { cursor: pointer; }
|
|||||||
.widget-name { display: grid; }
|
.widget-name { display: grid; }
|
||||||
.widget-name small { color: var(--muted-foreground); font-size: .8rem; }
|
.widget-name small { color: var(--muted-foreground); font-size: .8rem; }
|
||||||
.widget-search { width: 100%; margin-bottom: .5rem; }
|
.widget-search { width: 100%; margin-bottom: .5rem; }
|
||||||
|
.sheet-copy { margin: 0 .5rem .75rem; font-size: .875rem; color: var(--muted-foreground); line-height: 1.45; }
|
||||||
|
.sheet-steps { margin: 0 .5rem 1rem; padding-left: 1.25rem; display: grid; gap: .5rem; font-size: .875rem; line-height: 1.45; }
|
||||||
|
.sheet-steps strong { font-weight: 600; color: var(--popover-foreground); }
|
||||||
|
.sheet-actions { display: grid; gap: .5rem; margin: 0 .25rem; }
|
||||||
|
.sheet-actions .btn { width: 100%; height: 2.5rem; }
|
||||||
|
|
||||||
.notice, #toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 2rem); z-index: 30;
|
.notice, #toast { position: fixed; left: 50%; bottom: calc(var(--bottom) + 2rem); z-index: 30;
|
||||||
transform: translateX(-50%); padding: .5rem 1rem; border-radius: 999px;
|
transform: translateX(-50%); padding: .5rem 1rem; border-radius: 999px;
|
||||||
@@ -258,4 +272,4 @@ button { cursor: pointer; }
|
|||||||
#toast { opacity: 0; transition: opacity .2s; animation: none; }
|
#toast { opacity: 0; transition: opacity .2s; animation: none; }
|
||||||
#toast.show { opacity: 1; }
|
#toast.show { opacity: 1; }
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) { .drawer, .sheet { animation: none; } }
|
@media (prefers-reduced-motion: reduce) { .drawer, .drawer.closing, .sheet { animation: none; } }
|
||||||
Reference in new issue
Block a user