diff --git a/.sweet/quiet-icon-scale.md b/.sweet/quiet-icon-scale.md new file mode 100644 index 0000000..a17dbde --- /dev/null +++ b/.sweet/quiet-icon-scale.md @@ -0,0 +1,5 @@ +--- +type: feature +--- + +Add an icon size setting (long-press the home screen, then Icon size): a 70-160% slider with Small / Medium / Large presets and a live preview that resizes the home grid and the app drawer together. Icon, label and row height scale, the column count reflows so nothing overlaps or clips, the choice is saved, and a corrupt saved value is logged and shown instead of silently replaced. 100% is the original size. diff --git a/README.md b/README.md index a3d7a1a..a0a4303 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ # ultra launcher -An Android home screen, written in [MoonBit](https://www.moonbitlang.com). Home starts blank: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. Swipe down (or tap the search pill) for the drawer with every app and a search (Enter opens the first match); long-press an app there for its menu (add to home, app info, uninstall; system apps have no uninstall), and swipe up to close it. The **Windows** button in the panel at the top opens Recents. The layout is saved on the device, and the app updates itself from the latest release here. +An Android home screen, written in [MoonBit](https://www.moonbitlang.com). Home starts blank: long-press it to add apps (the drawer opens in a pick mode) or widgets, and long-press anything on it to drag it somewhere else; let go without moving to get its menu, or, for a widget, handles on its edges that resize it to the grid. **Icon size** in the same menu sets how big icons are (70%–160% in steps of 5, with Small / Medium / Large presets and a live preview; Medium, 100%, is the original size). It applies to the home screen and the app drawer together, scales icon, label and row height, and changes the column count so nothing overlaps or clips. Swipe down (or tap the search pill) for the drawer with every app and a search (Enter opens the first match); long-press an app there for its menu (add to home, app info, uninstall; system apps have no uninstall), and swipe up to close it. The **Windows** button in the panel at the top opens Recents. The layout is saved on the device, and the app updates itself from the latest release here. | home | drawer | app menu | resize handles | |---|---|---|---| | ![home](docs/screenshots/01-home-with-apps.png) | ![drawer](docs/screenshots/03-drawer.png) | ![menu](docs/screenshots/04-drawer-app-menu.png) | ![resize](docs/screenshots/05-resize-handles.png) | +Icon size, before (100%) and at 130% / 70%, the drawer at 130%, and the error shown for a corrupt saved value: + +| before | 130% | 70% | drawer 130% | corrupt value | +|---|---|---|---|---| +| ![before](docs/screenshots/06-icon-size-before.png) | ![large](docs/screenshots/07-icon-size-large.png) | ![small](docs/screenshots/08-icon-size-small.png) | ![drawer](docs/screenshots/09-icon-size-drawer-large.png) | ![corrupt](docs/screenshots/10-icon-size-corrupt.png) | + (Screenshots are of the browser demo at phone size.) ## Install @@ -40,7 +46,7 @@ MoonBit owns the logic and the UI; Java is only what Android itself requires. | package | what | tested by | |---|---|---| -| `grid/` | the home grid: packing (dense, with pinned cells), cell/box math, pin, resize steps, widget columns | `moon test` | +| `grid/` | the home grid: packing (dense, with pinned cells), cell/box math, pin, resize steps, widget columns, and the icon size setting (range, parsing, row height, column counts) | `moon test` | | `gesture/` | pointer state machine: tap, long press (500 ms, 10 px slop), drag, release, swipe | `moon test` | | `updater/` | release/`version.json` parsing, `build-N` tags, the install/skip decision, 6 h throttle | `moon test` | | `jsonx/` | small `Json` accessors | `moon test` | diff --git a/app/model.mbt b/app/model.mbt index 357d770..5c79a47 100644 --- a/app/model.mbt +++ b/app/model.mbt @@ -61,6 +61,8 @@ pub(all) enum Sheet { DrawerApp(Int32) WidgetPicker RecentsSetup + /// The icon size slider and presets. + IconSize } ///| @@ -118,6 +120,19 @@ pub(all) struct Model { mut grid_left : Double mut grid_top : Double mut col_w : Double + /// Icon size in percent of the original (see grid/scale.mbt), applied to the home + /// grid and the drawer. + mut icon_pct : Int32 + /// Why the saved icon size could not be used (empty: it could); shown in the icon + /// size sheet. The bad stored value is left alone until a size is chosen. + mut icon_error : String + /// The last measurement, kept so a size change can lay out again without one. + mut vw : Int32 + mut grid_w : Double + /// Px of screen below the top of the grid that rows can fill. + mut avail_h : Double + /// Columns of the drawer's app list. + mut drawer_cols : Int32 mut query : String mut wquery : String mut drawer : Bool @@ -176,6 +191,12 @@ pub fn Model::new() -> Model { grid_left: 0.0, grid_top: 0.0, col_w: 0.0, + icon_pct: @grid.scale_default, + icon_error: "", + vw: 0, + grid_w: 0.0, + avail_h: 0.0, + drawer_cols: 4, query: "", wquery: "", drawer: false, @@ -222,7 +243,7 @@ pub(all) enum Msg { // ---- from the platform /// Boot: the saved layout (this app's JSON, and the old WebView build's /// `ultra.home.*` localStorage as a JSON object), the clock, and the self-update state. - Restore(saved~ : String?, legacy~ : String?) + Restore(saved~ : String?, legacy~ : String?, icon_size~ : String?) Started( now~ : Int64, last_check~ : Int64, @@ -294,6 +315,12 @@ pub(all) enum Msg { MoveEarlier(Int32) InfoOf(Int32) Settings + /// Open the icon size sheet. + IconSizeMenu + /// The slider's value (text, as the input reports it). + SetIconSize(String) + /// A preset button, in percent. + IconPreset(Int32) Wallpaper Recents RecentsUnavailable @@ -331,6 +358,10 @@ pub(all) enum Effect { /// Ask the shell for a widget's limits and answer `LimitsKnown`. QueryLimits(Int32) SaveHome(String) + /// Store the icon size (percent). + SaveIconSize(Int32) + /// Write a line to the platform's error log. + LogError(String) SaveLastCheck(Int64) /// Send the message after this many ms. Delay(Int32, Msg) diff --git a/app/pkg.generated.mbti b/app/pkg.generated.mbti index ccc68f8..142d7db 100644 --- a/app/pkg.generated.mbti +++ b/app/pkg.generated.mbti @@ -84,6 +84,8 @@ pub(all) enum Effect { LoadWidgets QueryLimits(Int32) SaveHome(String) + SaveIconSize(Int32) + LogError(String) SaveLastCheck(Int64) Delay(Int32, Msg) HoldTimer(Int32, Int32) @@ -123,6 +125,12 @@ pub(all) struct Model { mut grid_left : Double mut grid_top : Double mut col_w : Double + mut icon_pct : Int32 + mut icon_error : String + mut vw : Int32 + mut grid_w : Double + mut avail_h : Double + mut drawer_cols : Int32 mut query : String mut wquery : String mut drawer : Bool @@ -153,6 +161,7 @@ pub(all) struct Model { mut gesture : @gesture.State } pub fn Model::app_row(Self, String) -> Int32 +pub fn Model::cell_h(Self) -> Int32 pub fn Model::drawer_open(Self) -> Bool pub fn Model::first_match(Self) -> Int32 pub fn Model::first_widget_match(Self) -> Int32 @@ -166,7 +175,7 @@ pub fn Model::widget_matches(Self, Int32) -> Bool #derive(Eq, @debug.Debug) pub(all) enum Msg { - Restore(saved~ : String?, legacy~ : String?) + Restore(saved~ : String?, legacy~ : String?, icon_size~ : String?) Started(now~ : Int64, last_check~ : Int64, declined~ : Int32, installed~ : Int32) Measured(vw~ : Int32, vh~ : Int32, grid_left~ : Double, grid_top~ : Double, grid_w~ : Double, bottom_pad~ : Double, scroll_y~ : Double) AppsLoaded(String?) @@ -209,6 +218,9 @@ pub(all) enum Msg { MoveEarlier(Int32) InfoOf(Int32) Settings + IconSizeMenu + SetIconSize(String) + IconPreset(Int32) Wallpaper Recents RecentsUnavailable @@ -249,6 +261,7 @@ pub(all) enum Sheet { DrawerApp(Int32) WidgetPicker RecentsSetup + IconSize } pub(all) struct WidgetInfo { diff --git a/app/sim_wbtest.mbt b/app/sim_wbtest.mbt index fa272b1..cb20b29 100644 --- a/app/sim_wbtest.mbt +++ b/app/sim_wbtest.mbt @@ -33,7 +33,7 @@ struct Sim { fn Sim::new() -> Sim { let m = Model::new() let s = { m, tree: [], table: [], log: [], last_x: 0.0, last_y: 0.0, } - s.run(update(m, Restore(saved=None, legacy=None))) + s.run(update(m, Restore(saved=None, legacy=None, icon_size=None))) s.send( Measured( vw=390, @@ -757,7 +757,7 @@ test "the layout is saved on every change and restored" { } assert_eq(saved, save_json(s.m.home)) let s2 = Sim::new() - s2.run(update(s2.m, Restore(saved=Some(saved), legacy=None))) + s2.run(update(s2.m, Restore(saved=Some(saved), legacy=None, icon_size=None))) assert_eq(s2.home_names(), ["Chrome", "Gmail"]) // restoring what is already saved doesn't save it again let n = s2.log.filter(fn(e) { e is SaveHome(_) }).length() - 1 // Sim::new saved the empty one @@ -783,7 +783,7 @@ test "the old WebView build's home screen is brought over once" { assert_eq(legacy_import("{}", Ref(1)).length(), 0) assert_eq(legacy_import("garbage", Ref(1)).length(), 0) let s = Sim::new() - s.run(update(s.m, Restore(saved=None, legacy=Some(legacy)))) + s.run(update(s.m, Restore(saved=None, legacy=Some(legacy), icon_size=None))) assert_eq(s.m.home.length(), 2) assert_true(s.log.contains(SaveHome(save_json(s.m.home)))) // saved in the new format // a saved layout wins over the old one @@ -794,6 +794,7 @@ test "the old WebView build's home screen is brought over once" { Restore( saved=Some(save_json([slot_app("c.gmail/.Main")])), legacy=Some(legacy), + icon_size=None, ), ), ) @@ -927,7 +928,7 @@ test "view snapshot: home with an app" { #| #| Search apps #| - #|