You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feat: "Add to Home screen" option to create folder shortcuts with deep link - #219
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
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.
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
}
The dialog allows names up to the filesystem limit (223 characters), but Android pinned shortcuts impose much smaller limits on shortLabel/longLabel. A valid 26+ character input can therefore fail during ShortcutInfo validation or pinning instead of creating the shortcut. Validate against the shortcut API limits or deliberately truncate before building it.
val shortcut = ShortcutInfo.Builder(context, shortcutId)
.setShortLabel(shortcutName)
.setLongLabel(shortcutName)
On API levels below 26 this branch cannot create a pinned shortcut, but it displays the success message Shortcut added to Home screen. Users are therefore told the action succeeded even though no shortcut was created; use an unsupported-version message or hide/disable the action.
This error path runs from onCreate before setContentView initializes the activity layout. Consequently findViewById(R.id.list_layout) is null and Snackbar.make can fail, so tapping a shortcut for a deleted folder crashes instead of showing the documented error. Defer the snackbar until after the content view is set.
The launcher starts shortcut intents from another UID, so the
non-exported FileDisplayActivity was rejected with a SecurityException.
A dedicated exported trampoline validates the shortcut action and
forwards only the shortcut extras to the real activity.
The shortcut carried only path and space, so after an account switch
the same path resolved against the wrong account (or not at all).
Include the folder owner in the shortcut intent and restart with
that account selected before looking the folder up.
The dialog accepted names up to MAX_FILENAME_LENGTH (223 chars) and
passed them unchanged to setShortLabel/setLongLabel, which Android
caps at 10/25 recommended characters. Validate the name in the dialog
and truncate labels defensively before building the ShortcutInfo.
requestPinShortcut is asynchronous and the success toast fired
unconditionally before the user even confirmed the launcher dialog.
Pass an IntentSender backed by ShortcutPinResultReceiver and report
success only when the launcher actually pinned the shortcut; surface
an error toast when requestPinShortcut returns false.
The action was only wired to the bottom-sheet menu; when chosen from
the long-press selection action mode it fell through
onSingleFileActionChosen and did nothing. Open the dialog via the
child fragment manager and clear the selection like other actions.
handleShortcutIntent() is only invoked from onCreate, but the trampoline starts FileDisplayActivity with FLAG_ACTIVITY_CLEAR_TOP. When the app already has a FileDisplayActivity, Android delivers the shortcut intent to that existing instance via onNewIntent; BaseActivity.onNewIntent() does not call this handler, so tapping a pinned shortcut while the app is open is a no-op (and this also prevents the cross-account redirect from being processed). Handle the shortcut intent from onNewIntent as well, including updating the activity's intent/account state before resolving the folder.
val sc = eu.opencloud.android.presentation.files.addtohomescreen.FolderShortcutHelper
if (intent?.action != sc.ACTION_OPEN_SHORTCUT) return
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
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.
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