Skip to content

Feat: "Add to Home screen" option to create folder shortcuts with deep link - #219

Open
Lightz2002 wants to merge 2 commits into
opencloud-eu:mainfrom
Lightz2002:main
Open

Feat: "Add to Home screen" option to create folder shortcuts with deep link#219
Lightz2002 wants to merge 2 commits into
opencloud-eu:mainfrom
Lightz2002:main

Conversation

@Lightz2002

Copy link
Copy Markdown
  • Adds an "Add to Home screen" action for folders that pins a launcher shortcut,
    deep-linking straight into that folder when tapped.

Changes

  • Add ADD_TO_HOME_SCREEN to FileMenuOption and wire it into the file actions menu
    (action_add_to_home) with a new icon; only shown for single-selected folders via
    FilterFileMenuOptionsUseCase
  • New AddToHomeScreenDialogFragment: pre-filled, editable shortcut name with validation
    (empty name, max filename length, forbidden characters)
  • New FolderShortcutHelper: creates a pinned shortcut via ShortcutManager (API 26+),
    embedding the folder's remote ID, remote path, and space ID in the intent
  • FileDisplayActivity handles the new OPEN_SHORTCUT action: resolves the folder by
    remote 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

  • Devices below API 26 show a toast instead of creating a shortcut
  • Shortcut opens in All Files view regardless of the last used file list option

Testing

  • Long-press/overflow menu on a folder → "Add to Home screen" → confirm → pin the shortcut
  • Tap the shortcut → app opens directly inside the target folder
  • Rename the shortcut in the dialog; verify empty names / forbidden chars are rejected
  • Delete the folder, then tap the shortcut → error message shown

@wernrab
wernrab requested review from guruz and wernrab August 31, 2026 13:56
@guruz

guruz commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@wernrab can you review this one?

@Lightz2002 I think "add folder path to home screen" is a not so good commit message.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_SCREEN and wires it into the file actions menu (icon + string resources).
  • Adds AddToHomeScreenDialogFragment to collect/validate the shortcut name and FolderShortcutHelper to request a pinned shortcut via ShortcutManager.
  • Extends FileDisplayActivity to 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants