Feat: "Add to Home screen" option to create folder shortcuts with deep link - #219
Feat: "Add to Home screen" option to create folder shortcuts with deep link#219Lightz2002 wants to merge 2 commits into
Conversation
|
@wernrab can you review this one? @Lightz2002 I think "add folder path to home screen" is a not so good commit message. |
There was a problem hiding this comment.
🟡 Changes recommended
There are user-visible correctness issues (misleading success messaging and incomplete/unsafe validation + a potential pre-contentView snackbar crash path) that should be fixed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an “Add to Home screen” action for folder items, allowing users to pin a launcher shortcut that deep-links back into the selected folder, with UI for naming/validating the shortcut and runtime handling to open the target folder.
Changes:
- Introduces a new
FileMenuOption.ADD_TO_HOME_SCREENand wires it into the file actions menu (icon + string resources). - Adds
AddToHomeScreenDialogFragmentto collect/validate the shortcut name andFolderShortcutHelperto request a pinned shortcut viaShortcutManager. - Extends
FileDisplayActivityto process the shortcut intent and navigate into the resolved folder.
File summaries
| File | Description |
|---|---|
| opencloudDomain/src/main/java/eu/opencloud/android/domain/files/model/FileMenuOption.kt | Adds a new menu option enum value for the feature. |
| opencloudApp/src/main/res/values/strings.xml | Adds UI strings for the new menu item and dialog. |
| opencloudApp/src/main/res/menu/file_actions_menu.xml | Adds the new “Add to Home screen” menu item. |
| opencloudApp/src/main/res/drawable/ic_action_add_to_home.xml | Adds the vector icon for the new action. |
| opencloudApp/src/main/java/eu/opencloud/android/usecases/files/FilterFileMenuOptionsUseCase.kt | Shows the option only for single-selected folders. |
| opencloudApp/src/main/java/eu/opencloud/android/ui/activity/FileDisplayActivity.kt | Handles shortcut intents and navigates into the folder. |
| opencloudApp/src/main/java/eu/opencloud/android/presentation/files/filelist/MainFileListFragment.kt | Opens the new dialog and triggers shortcut creation. |
| opencloudApp/src/main/java/eu/opencloud/android/presentation/files/addtohomescreen/FolderShortcutHelper.kt | Implements pinned shortcut creation and intent extras. |
| opencloudApp/src/main/java/eu/opencloud/android/presentation/files/addtohomescreen/AddToHomeScreenDialogFragment.kt | Adds the shortcut naming dialog with validation. |
| opencloudApp/src/main/java/eu/opencloud/android/extensions/FileMenuOptionExt.kt | Maps the new option to menu id/string/icon resources. |
Review details
Suppressed comments (1)
opencloudApp/src/main/java/eu/opencloud/android/presentation/files/addtohomescreen/FolderShortcutHelper.kt:36
requestPinShortcut()can fail/return false; also when pinning isn’t supported the code currently shows the same “added” success toast. This can report success even when the launcher declined/doesn’t support pinning.
if (shortcutManager?.isRequestPinShortcutSupported != true) {
Toast.makeText(context, context.getString(R.string.add_to_home_screen_shortcut_added), Toast.LENGTH_SHORT).show()
return
}
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| createPinnedShortcutApi26(context, folder, shortcutName) | ||
| } else { | ||
| Toast.makeText(context, context.getString(R.string.add_to_home_screen_shortcut_added), Toast.LENGTH_SHORT).show() |
| if (file != null) { | ||
| shortcutFolderToNavigate = file | ||
| } else { | ||
| showMessageInSnackbar(R.id.list_layout, getString(R.string.default_error_msg)) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
deep-linking straight into that folder when tapped.
Changes
ADD_TO_HOME_SCREENtoFileMenuOptionand wire it into the file actions menu(
action_add_to_home) with a new icon; only shown for single-selected folders viaFilterFileMenuOptionsUseCaseAddToHomeScreenDialogFragment: pre-filled, editable shortcut name with validation(empty name, max filename length, forbidden characters)
FolderShortcutHelper: creates a pinned shortcut viaShortcutManager(API 26+),embedding the folder's remote ID, remote path, and space ID in the intent
FileDisplayActivityhandles the newOPEN_SHORTCUTaction: resolves the folder byremote path + space ID from local storage and navigates directly into it; extras are
consumed after handling; shows an error snackbar if the folder no longer exists locally
Notes
Testing