Conversation
Adds a "Backup & restore" section to Settings that exports the home screen icons and folders to a JSON file and imports them back, through the Storage Access Framework. A backup keeps each item's page, its cell on that page, its dock flag, and for an icon in a folder its slot in that folder, so multiple home screens, the dock and folder contents all survive the round trip. Widgets and pinned shortcuts are deliberately left out in both directions: a widget id only means something to the AppWidgetHost that allocated it, and a shortcut id only to the app that pinned it, so restoring either on another device would bind to an unrelated widget or to nothing at all. Icons and folders are just grid coordinates plus a package/activity reference, so they can be checked against this device before anything is written. Import asks what to do with cells that are already in use: keep the current icons and give restored ones a free cell, let restored icons take their cell and move the current occupant, or drop the current icons and folders first. In all three, no two items end up on the same cell, which also covers items of the file colliding with each other. A free cell is looked for from the item's own page onwards and never on an earlier one, so a full page spills onto the next and the page grouping of the file is kept. The dock is one row shared by every page, so a docked item only competes for dock cells, and a widget is never pushed aside because it spans several cells. An item is skipped when its app is not installed, when it does not fit this device's grid, or when no free cell is left for it. Matching against the installed apps falls back to the package name when the stored activity name is empty, because the launcher writes its own default icons that way (see MainActivity.getDefaultAppPackages) and launches them through getLaunchIntentForPackage; requiring the full package/activity identifier would have skipped every one of those. Export reads the database on a background thread, since Room is built without allowMainThreadQueries. Reading a picked file reports provider and parse failures separately, and neither path lets an exception reach the background thread's uncaught handler: a document provider lives in another process and is free to marshal back arbitrary unchecked exceptions, which would otherwise take down the launcher instead of showing an error. Closes FossifyOrg#94
Contributor
|
Fossify accepts code contributions only for open issues labeled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a "Backup & restore" section to Settings that exports the home screen icons and folders to a JSON file and imports them back, through the Storage Access Framework.
Type of change(s)
What changed and why
LayoutBackupHelperand itsimportLayout/exportLayoutmethods and the 3 ImportMode constants.Tests performed
Both exports and imports (including app' with different page counts/configurations)
Before & after preview
New menu:
Import logic choosing:
Closes the following issue(s)
Checklist
CHANGELOG.md.Detailed description
A backup keeps each item's page, its cell on that page, its dock flag, and for an icon in a folder its slot in that
folder, so multiple home screens, the dock and folder contents all survive the round trip.
Widgets and pinned shortcuts are deliberately left out in both directions: a widget id only means something to the
AppWidgetHost that allocated it, and a shortcut id only to the app that pinned it, so restoring either on another device
would bind to an unrelated widget or to nothing at all.
Icons and folders are just grid coordinates plus a package/activity reference, so they can be checked against this
device before anything is written.
Import asks what to do with cells that are already in use:
In all three, no two items end up on the same cell, which also covers items of the file colliding with each other.
A free cell is looked for from the item's own page onwards and never on an earlier one, so a full page spills onto the
next and the page grouping of the file is kept.
The dock is one row shared by every page, so a docked item only competes for dock cells, and a widget is never pushed
aside because it spans several cells. An item is skipped when its app is not installed, when it does not fit this
device's grid, or when no free cell is left for it. Matching against the installed apps falls back to the package name
when the stored activity name is empty, because the launcher writes its own default icons that way (see
MainActivity.getDefaultAppPackages) and launches them throughgetLaunchIntentForPackage; requiring the fullpackage/activity identifier would have skipped every one of those.
Export reads the database on a background thread, since Room is built without allowMainThreadQueries.
Reading a picked file reports provider and parse failures separately, and neither path lets an exception reach the
background thread's uncaught handler: a document provider lives in another process and is free to marshal back arbitrary
unchecked exceptions, which would otherwise take down the launcher instead of showing an error.
Export file sample
{ "version": 1, "items": [ { "tempId": 3, "parentTempId": null, "left": 3, "top": 5, "right": 3, "bottom": 5, "page": 0, "packageName": "org.mozilla.fennec_fdroid", "activityName": "", "title": "Fennec", "type": 0, "className": "", "docked": true }, { "tempId": 6, "parentTempId": null, "left": 4, "top": 5, "right": 4, "bottom": 5, "page": 0, "packageName": "com.android.settings", "activityName": "com.android.settings.Settings", "title": "Paramètres", "type": 0, "className": "", "docked": true }, { "tempId": 7, "parentTempId": null, "left": 1, "top": 5, "right": 1, "bottom": 5, "page": 0, "packageName": "org.fossify.phone", "activityName": "org.fossify.phone.activities.SplashActivity.Green", "title": "Téléphone", "type": 0, "className": "", "docked": true } ] }