Skip to content

Implement #3175: Add home screen folder/file shortcut widget#5522

Closed
wiwie wants to merge 14 commits into
nextcloud:masterfrom
wiwie:master
Closed

Implement #3175: Add home screen folder/file shortcut widget#5522
wiwie wants to merge 14 commits into
nextcloud:masterfrom
wiwie:master

Conversation

@wiwie

@wiwie wiwie commented Feb 25, 2020

Copy link
Copy Markdown

Resolves #3175.

Testing

Writing tests is very important. Please try to write some tests for your PR.

If you need help, please do not hesitate to ask in this PR for help.

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Feb 26, 2020

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@bdaaf63). Click here to learn what that means.
The diff coverage is 7.89%.

@@            Coverage Diff            @@
##             master    #5522   +/-   ##
=========================================
  Coverage          ?   21.99%           
  Complexity        ?        3           
=========================================
  Files             ?      398           
  Lines             ?    33511           
  Branches          ?     4703           
=========================================
  Hits              ?     7371           
  Misses            ?    24951           
  Partials          ?     1189
Impacted Files Coverage Δ Complexity Δ
...ncloud/android/ui/fragment/OCFileListFragment.java 30.59% <0%> (ø) 0 <0> (?)
...cloud/android/ui/activity/FileDisplayActivity.java 22.8% <0%> (ø) 0 <0> (?)
...cloud/android/ui/helpers/FileOperationsHelper.java 4.29% <0%> (ø) 0 <0> (?)
.../java/com/owncloud/android/utils/MimeTypeUtil.java 87.92% <100%> (ø) 0 <0> (?)

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12825.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- src/main/java/com/owncloud/android/ui/helpers/MenuHelper.java  1
         

See the complete overview on Codacy

@nextcloud-android-bot

Copy link
Copy Markdown
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12827.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@wiwie

wiwie commented Feb 27, 2020

Copy link
Copy Markdown
Author

@tobiasKaminsky the integration test failures seem unrelated to my changes and randomly changing. is this due to technical issues or did I forget something?

also: i've trouble coming up with reasonable tests, as adding a shortcut to the homescreen requires user intervention outside the app. how can I incorporate this in automated tests?

*/
public static void inflateItemFileMenu(final MenuInflater inflater, final Menu menu) {
inflater.inflate(R.menu.item_file, menu);
menu.findItem(R.id.action_add_shortcut_to_homescreen).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can't say for sure if it will be the right place, but you might want to check if this needs to be moved/added to FileMenuFilter, while this might not work since (unfortunately) FileMenuFilter isn't used in all places where R.menu.item_fileis being used while your implementation (correctly) is.

So also looping in @tobiasKaminsky @ezaquarii for further discussion

@AndyScherzinger

AndyScherzinger commented Mar 16, 2020

Copy link
Copy Markdown
Member

looping in @tobiasKaminsky @ezaquarii for feedback and review

@wiwie thanks a lot for your PR/contribution. This is highly appreciated. Sorry for letting you wait (this long) we have been busy finishing up the latest stable release ❤️

@tobiasKaminsky

Copy link
Copy Markdown
Member

@wiwie sorry for coming back so late, but we have currently crazy times…

I checked it out and tried to add a widget via long clicking on homescreen, but I cannot find any widget related to NC.
I am using an Android 10 emulator.

@wiwie

wiwie commented Apr 8, 2020

Copy link
Copy Markdown
Author

@wiwie sorry for coming back so late, but we have currently crazy times…

I checked it out and tried to add a widget via long clicking on homescreen, but I cannot find any widget related to NC.
I am using an Android 10 emulator.

That is because I haven't implemented it as a widget but as a pinned shortcut. You can add it to your Homescreen for a specific file or folder by selecting a file or folder and choosing the"add to Homescreen" in the hamburger menu.

@tobiasKaminsky

Copy link
Copy Markdown
Member

Nice 👍 Now I can test it :-)

  • do you think it is possible to have the color tinted? E.g. having an orange theme on server, and thus the folder icon on homescreen is also orange?
  • after creating a widget for one folder, it is again showing "add to homescreen". Can/should we check this and do not show it?

@jancborchardt
In my opinion this is a bit too prominent, but I have no better idea.
2020-04-08-133427

After that I'll do a code review.

@wiwie

wiwie commented Apr 8, 2020

Copy link
Copy Markdown
Author

Regarding your questions:

  • I believe this should be possible if it's possible to retrieve the theme colour from the nextcloud instance?
  • I'll look into it.

@tobiasKaminsky

Copy link
Copy Markdown
Member
* I believe this should be possible if it's possible to retrieve the theme colour from the nextcloud instance?

You can find the color in ThemeUtils.primaryColor(Account account…)

@jancborchardt

Copy link
Copy Markdown
Member

Isn’t it possible to only show this in Android’s widget selector, which then leads to a folder picker? It’s a bit much to have the "Add to home screen" action in the menu of every single folder.

@wiwie

wiwie commented May 27, 2020

Copy link
Copy Markdown
Author

Honestly, I don't see the problem: There are so many entries in the menu already anyways, what is one more for a home screen shortcut? ;-)

It is definitely possible, but implementing an Android widget is way more involved than such a shortcut as implemented here. I started looking into it, but didn't have enough time to finish anything and also got quite frustrated by the fact that such a comparably simple functionality should lead to so much code. but maybe it's just me - I'm not experienced in developing for Android at all - this was my first shot at it. For now I don't know when I'll find time to pick this up again. I'm happily using this shortcut implementation for the last 3 months now.

I'll wait with looking into @tobiasKaminsky's points, until you guys have decided whether it's desirable at all to merge this shortcut implementation.

@ezaquarii

Copy link
Copy Markdown
Collaborator

@wiwie This PR is behind master and has conflicts. I'd take the opportunity and squash the commits - the history is noisy and doesn't provide any value at this point.

@ezaquarii ezaquarii left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  1. Conflicts must be resolved.
  2. DCO.

I suggest squashing the history noise as well. Especially that there is no DCO and adding it to all commits will be painful.

@jancborchardt

Copy link
Copy Markdown
Member

There are so many entries in the menu already anyways, what is one more for a home screen shortcut? ;-)

I take the smiley as you joking, but just to explain: There being so many entries in the menu is exactly the problem, we should not add more, especially not ones which will be used extremely rarely.

@jancborchardt

Copy link
Copy Markdown
Member

Maybe widget pro @dan0xii has some input or can help regarding this? :)

@wiwie

wiwie commented Jun 5, 2020

Copy link
Copy Markdown
Author

@jancborchardt yes, I get your point. I agree that it's a good idea to reduce the number of menu entries. It was the solution that seemed easiest to implement to me, that's the only reason I chose it. I agree that it's polluting the menus as it is.

So just for clarification, you are suggesting the following approach:

  • not to use the dynamic shortcut system
  • Making a widget that initially opens the nextcloud file picker
  • the widget should after initial setup open the chosen file/folder upon tapping and
  • it could be edited/set to a different file/folder upon long pressing
    ?

Something like this seems to be the cleanest solution to me at least, and I tried implementing it but just ran out of time. I can give it another shot if chances are that it will be merged in.

@jancborchardt

Copy link
Copy Markdown
Member

Yes, that seems like a great plan @wiwie! :)

The ability to edit the folder afterwards is even not necessary in the first step, as it's also easy to just remove and recreate.

@dan0xii

dan0xii commented Jun 5, 2020

Copy link
Copy Markdown
Contributor

The ability to edit the folder afterwards is even not necessary in the first step, as it's also easy to just remove and recreate.

Agreed.

For a dynamic shortcut: as a middle-ground, if a dynamic shortcut is required you could put it on the topbar/navbar for each sub folder. (Refresh account, sort, grid view, add to home screen). Less noise but if you're deep into a folder hierarchy you could still drop a shortcut to the home screen.

PS. Love this widget. Would be using it as soon as it's available.

@jancborchardt

Copy link
Copy Markdown
Member

@dan0xii the navbar/topbar action menu is to be removed, as the actions in it were moved into icons or actions (grid toggle, sort entry, pull to refresh).

So I'd still say it would be best to do this via the native widget mechanism?

@wiwie

wiwie commented Jun 14, 2020

Copy link
Copy Markdown
Author

I am finished with an initial implementation based on widgets without editing functionality as discussed above.

Several questions:

  • should this pull request be abandoned and a new one created for the new implementation? This one was conflicting anyway and the two implementations are independent.
  • During testing of the initial widget based implementation I discovered that there is at least one limitation to widgets, that shortcuts don't have: shortcuts can be grouped together into collapsible folders on the home screen, while widgets cannot. I used this feature initially to not fill up my Homescreen too much. Since I'm not very experienced with developing for Android I can't exclude the possibility that there are more such limitations that could reduce the usefulness of widgets for this use-case and motivate the use of the shortcut system instead.
  • if we were to decide to make another attempt with shortcuts, what about placing all the shortcut functionality for all files and folders into one central place instead of adding it to each file and folder entry? I was thinking that one could for instance add an entry to the main menu on the left (not sure whether it is called like this in Android terms) called "Homescreen shortcuts" and manage everything from there. Or, if that is too prominent, maybe add an Advanced entry to the menu and hide the shortcut entry therein.

@tobiasKaminsky

Copy link
Copy Markdown
Member
* I was thinking that one could for instance add an entry to the main menu on the left (not sure whether it is called like this in Android terms) called "Homescreen shortcuts" and manage everything from there. Or, if that is too prominent, maybe add an Advanced entry to the menu and hide the shortcut entry therein.

What would be in this entry?
I would assume that it is enough to have an entry within the overflow menu for each file/folder, or?

@wiwie

wiwie commented Jun 25, 2020

Copy link
Copy Markdown
Author

I understood previous feedback in this PR such that adding the "add to homescreen" to the overflow menu of each file/folder would be too much.

@jancborchardt wrote:

I take the smiley as you joking, but just to explain: There being so many entries in the menu is exactly the problem, we should not add more, especially not ones which will be used extremely rarely.

hence the alternative idea, making one central place somewhere, that allows to manage homescreen shortcuts. i.e. it could have

  • a list of all homescreen shortcuts previously created
  • a button to add a new one (which would then open a file chooser / folder chooser)
  • some way of deleting existing shortcuts.

maybe I'm misunderstanding. are you talking about a different menu?

@wiwie

wiwie commented Aug 2, 2020

Copy link
Copy Markdown
Author

I'll close this PR as there was no more feedback from the maintainers.

@wiwie wiwie closed this Aug 2, 2020
@stefan-niedermann

Copy link
Copy Markdown
Member

@wiwie have you seen #6363 ? I mentioned you but you didn't respond, so i am not sure whether you took note of it.

I tried to find and describe an alternative solution for implementing shortcuts without the criticized drawbacks for users who aren't interested or not using shortcuts at all and without cluttering the UI for those people.

Woul be great to hear your opinion 🙂

@wiwie

wiwie commented Aug 3, 2020

Copy link
Copy Markdown
Author

Hi Stefan, thanks for getting back. Sorry, I really hadn't seen your issue. It seems that you really did a well and thorough analysis of how shortcuts are being used in various launchers, way better than I could. So not sure how much I could contribute, but will give it a shot and write my five cents when I have time. ☺️

@stefan-niedermann

Copy link
Copy Markdown
Member

Would be really awesome to keep you contributing in this corner :) I am really appreciated about your engagement, we just need to make sure that it goes into the right direction 😉.

So take you time and if you feel happy, just start another PR - i am sure one will jump in and join - let's continue in the other issue then if you agree 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add home screen folder/file shortcut widget

8 participants