Skip to content

Conversation

@Koitharu
Copy link
Contributor

Adding desktop shortcuts for subscriptions and application shortcuts (on Android 7.1+)

Screenshot_20190629_182253 Screenshot_20190629_182417

@theScrabi theScrabi added the feature request Issue is related to a feature in the app label Jul 21, 2019
@TobiGr
Copy link
Contributor

TobiGr commented Oct 2, 2019

@nv95 Works good, I'll go through the code soon. Could you take a look at the conflict?
@Stypox changed the order of the actions in all menus and placed share at the end. We should do the same here. Maybe we need an offset variable (see very bad version below) or something different as workaround because the shortcut action would be in the middle and therefore cause some trouble with the index in the OnClickListener.

final boolean shortcutSupported = ShortcutManagerCompat.isRequestPinShortcutSupported(context);

final ArrayList<String> commands = new ArrayList<>(3);
commands.add(context.getResources().getString(R.string.unsubscribe));
if (shortcutSupported) {
    commands.add(context.getResources().getString(R.string.create_shortcut));
}
commands.add(context.getResources().getString(R.string.share));

final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
    final int commandIndexOffset = shortcutSupported ? 0 : 1;
    if (i == 0) {
        deleteChannel(selectedItem);
    } else if (i + commandIndexOffset == 1) {
        ShortcutsHelper.pinShortcut(context, selectedItem);
    } else if (i + commandIndexOffset == 2) {
        shareChannel(selectedItem);
    }
};

@Stypox
Copy link
Member

Stypox commented Oct 26, 2019

Could you provide an apk? ;-)

@Koitharu
Copy link
Contributor Author

Release variant, signed by my key
https://www.dropbox.com/s/e0qxydnfk6q2jox/newpipe_shortcuts.apk?dl=0

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

I wasn't able to test since my launcher does not support shortcuts (I'm on Android 7.1, EMUI 5.0.4)

Copy link
Contributor

@mauriciocolli mauriciocolli left a comment

Choose a reason for hiding this comment

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

I think the idea putting this in a service is a good one, a IntentService would be a good fit here. It'd fix the situation of a slow network and the user moving away from the app, because when the call finally returns with the image, the following exception will be thrown: java.lang.IllegalStateException: Calling application must have a foreground activity or a foreground service. Starting the foreground status would be required here.

When using the image loader and the image comes from the cache, it's almost impossible to exit in time to cause this bug. But it is very possible when the user is in a slow network and the image happens to not be in the cache.

Some considerations:

  • Remove shortcut from the list when unsubscribing.
  • Maybe update the metadata of the shortcut?
    • Though we should respect the rate limiting of the API.

@Koitharu
Copy link
Contributor Author

Koitharu commented Nov 2, 2019

@mauriciocolli I think, use service for shortcuts is not a good idea.

@TobiGr TobiGr force-pushed the dev branch 2 times, most recently from 679bc75 to 2aeccc0 Compare March 16, 2021 08:24
@litetex litetex marked this pull request as draft October 1, 2021 17:13
@litetex
Copy link
Member

litetex commented Oct 1, 2021

No progress since a year, no GitHub actions build and merge conflicts.

Closing this for now. Feel free to reopen it when there is progress again.

@litetex litetex closed this Oct 1, 2021
@litetex litetex mentioned this pull request Oct 10, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Issue is related to a feature in the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants