Commit 4fee3a2
committed
Feat: Add Widget Page feature
This commit introduces a new Widget Page feature, allowing users to add, resize, and manage app widgets.
**Core Functionality:**
- A new fragment `widgetFragment` and its corresponding layout `fragment_widget_container` have been added.
- `ResizableWidgetWrapper` class has been created to handle widget resizing, dragging, and context menu operations (Resize, Delete, Open, View in Store).
- Widgets are placed on a grid defined by `GRID_COLUMNS` and `CELL_MARGIN`.
- Widget state (ID, position, size, cell span) is persisted in a `widgets.json` file using Moshi.
**MainActivity Changes:**
- Added `widgetPermissionLauncher` to handle widget bind and configuration intents.
- Introduced `launchWidgetPermission`, `safeCreateWidget`, and `flushPendingWidgets` to manage the widget creation lifecycle, especially when `WidgetFragment` might not be immediately available.
**WidgetFragment Logic:**
- Initializes `AppWidgetManager` and `AppWidgetHost`.
- Handles widget addition via a custom picker that groups widgets by app.
- Manages the lifecycle of widgets: allocation, binding, configuration (if needed), and creation of `ResizableWidgetWrapper`.
- Provides functionality to reset all widgets.
- Saves and restores widget configurations to/from `widgets.json`.
- Includes logic to find empty slots in the grid for new widgets.
- Overrides `onBackPressed` to handle exiting resize mode for widgets.
**UI and Resources:**
- New string resources for widget-related actions and titles have been added to `strings.xml`.
- `fragment_widget_container.xml` defines the `FrameLayout` (`widget_grid`) that hosts the widgets.
- Resize handles and a grid overlay are displayed when a widget is in resize mode.1 parent 421881b commit 4fee3a2
File tree
5 files changed
+1289
-0
lines changed- app/src/main
- java/com/github/droidworksstudio/mlauncher
- ui
- widgets
- res
- layout
- values
5 files changed
+1289
-0
lines changedLines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
119 | 131 | | |
120 | 132 | | |
121 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
122 | 145 | | |
123 | 146 | | |
124 | 147 | | |
| |||
319 | 342 | | |
320 | 343 | | |
321 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
322 | 379 | | |
323 | 380 | | |
324 | 381 | | |
| |||
0 commit comments