Browse Source

Fix widget due to API level 31 pending intent changes

pull/621/head
Eric Kok 3 years ago
parent
commit
ae09a0602b
  1. 8
      README.md
  2. 3
      app/src/main/java/org/transdroid/core/service/AppUpdateJobRunner.java
  3. 3
      app/src/main/java/org/transdroid/core/service/RssCheckerJobRunner.java
  4. 2
      app/src/main/java/org/transdroid/core/service/ServerCheckerJobRunner.java
  5. 18
      app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java

8
README.md

@ -2,7 +2,7 @@ Transdroid
========== ==========
[www.transdroid.org](https://www.transdroid.org/) [www.transdroid.org](https://www.transdroid.org/)
[Twitter](https://twitter.com/transdroid) - [transdroid@2312.nl](transdroid@2312.nl) [Twitter](https://twitter.com/transdroid) - [transdroid@2312.nl](mailto:transdroid@2312.nl)
Manage torrents from your Android device. Manage torrents from your Android device.
@ -46,20 +46,20 @@ Code structure
============== ==============
Starting with version 2.3.0, Transdroid is developed in Android Studio, fully integrating with the Gradle build system. Starting with version 2.3.0, Transdroid is developed in Android Studio, fully integrating with the Gradle build system.
It is (since version 2.5.18) compiled against Android 10 (API level 29) and (since version 2.2.0) supporting Android ICS (API level 15) and up only. It is (since version 2.5.21) compiled against Android 12 (API level 31) and (since version 2.2.0) supporting Android ICS (API level 15) and up only.
To support lite (Transdrone, specially for the Play Store) and full (Transdroid) versions of the app, build flavours are defined in gradle, which contain version-specific resources. To support lite (Transdrone, specially for the Play Store) and full (Transdroid) versions of the app, build flavours are defined in gradle, which contain version-specific resources.
Dependencies are managed via JCentral et al. in the app's build.gradle file. Dependencies are managed via JCentral et al. in the app's build.gradle file.
Developed By Developed By
============ ============
Designed and developed by [Eric Kok](eric@2312.nl) of [2312 development](https://2312.nl/). Designed and developed by [Eric Kok](mailto:eric@2312.nl) of [2312 development](https://2312.nl/).
Contributions by various others (see commit log). Contributions by various others (see commit log).
License License
======= =======
Copyright 2010-2020 Eric Kok et al. Copyright 2010-2022 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

3
app/src/main/java/org/transdroid/core/service/AppUpdateJobRunner.java

@ -171,7 +171,8 @@ public class AppUpdateJobRunner {
private void newNotification(String ticker, String title, String text, String downloadUrl, int notifyID) { private void newNotification(String ticker, String title, String text, String downloadUrl, int notifyID) {
PendingIntent pi = PendingIntent.getActivity(context, notifyID, PendingIntent pi = PendingIntent.getActivity(context, notifyID,
new Intent(Intent.ACTION_VIEW, Uri.parse(downloadUrl)), PendingIntent.FLAG_UPDATE_CURRENT); new Intent(Intent.ACTION_VIEW, Uri.parse(downloadUrl)),
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.CHANNEL_APP_UPDATE) final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.CHANNEL_APP_UPDATE)
.setSmallIcon(R.drawable.ic_stat_notification) .setSmallIcon(R.drawable.ic_stat_notification)
.setTicker(ticker) .setTicker(ticker)

3
app/src/main/java/org/transdroid/core/service/RssCheckerJobRunner.java

@ -122,7 +122,8 @@ public class RssCheckerJobRunner {
// Provide a notification, since there are new RSS items // Provide a notification, since there are new RSS items
PendingIntent pi = PendingIntent PendingIntent pi = PendingIntent
.getActivity(context, 80000, new Intent(context, RssFeedsActivity_.class), PendingIntent.FLAG_UPDATE_CURRENT); .getActivity(context, 80000, new Intent(context, RssFeedsActivity_.class),
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
String title = context.getResources().getQuantityString(R.plurals.rss_service_new, unread, Integer.toString(unread)); String title = context.getResources().getQuantityString(R.plurals.rss_service_new, unread, Integer.toString(unread));
String forString = Collections2.joinString(hasUnread, ", "); String forString = Collections2.joinString(hasUnread, ", ");
final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.CHANNEL_RSS_CHECKER) final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannels.CHANNEL_RSS_CHECKER)

2
app/src/main/java/org/transdroid/core/service/ServerCheckerJobRunner.java

@ -147,7 +147,7 @@ public class ServerCheckerJobRunner {
i.putExtra("org.transdroid.START_SERVER", server.getOrder()); i.putExtra("org.transdroid.START_SERVER", server.getOrder());
// Should start the main activity directly into this server // Should start the main activity directly into this server
PendingIntent pi = PendingIntent.getActivity(context, notifyBase + server.getOrder(), i, PendingIntent pi = PendingIntent.getActivity(context, notifyBase + server.getOrder(), i,
PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
ArrayList<Torrent> affectedTorrents = new ArrayList<>(newTorrents.size() + doneTorrents.size()); ArrayList<Torrent> affectedTorrents = new ArrayList<>(newTorrents.size() + doneTorrents.size());
affectedTorrents.addAll(newTorrents); affectedTorrents.addAll(newTorrents);
affectedTorrents.addAll(doneTorrents); affectedTorrents.addAll(doneTorrents);

18
app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java

@ -91,7 +91,8 @@ public class ListWidgetProvider extends AppWidgetProvider {
rv.setRemoteAdapter(appWidgetId, R.id.torrents_list, data); rv.setRemoteAdapter(appWidgetId, R.id.torrents_list, data);
Intent open = new Intent(context, TorrentsActivity_.class); Intent open = new Intent(context, TorrentsActivity_.class);
open.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); open.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
rv.setPendingIntentTemplate(R.id.torrents_list, PendingIntent.getActivity(context, appWidgetId, open, PendingIntent.FLAG_UPDATE_CURRENT)); rv.setPendingIntentTemplate(R.id.torrents_list, PendingIntent.getActivity(context, appWidgetId, open,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
rv.setEmptyView(R.id.torrents_list, R.id.error_text); rv.setEmptyView(R.id.torrents_list, R.id.error_text);
rv.setTextViewText(R.id.error_text, context.getString(R.string.widget_loading)); rv.setTextViewText(R.id.error_text, context.getString(R.string.widget_loading));
@ -107,8 +108,10 @@ public class ListWidgetProvider extends AppWidgetProvider {
start.setAction(INTENT_STARTSERVER); start.setAction(INTENT_STARTSERVER);
start.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); start.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
start.putExtra(EXTRA_SERVER, config.getServerId()); start.putExtra(EXTRA_SERVER, config.getServerId());
rv.setOnClickPendingIntent(R.id.icon_image, PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT)); rv.setOnClickPendingIntent(R.id.icon_image, PendingIntent.getActivity(context, appWidgetId, start,
rv.setOnClickPendingIntent(R.id.navigation_view, PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
rv.setOnClickPendingIntent(R.id.navigation_view, PendingIntent.getActivity(context, appWidgetId, start,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
// Set up the widgets refresh button pending intent (calling this WidgetProvider itself) // Set up the widgets refresh button pending intent (calling this WidgetProvider itself)
// Make sure that the intent is unique using a custom data path (rather than just the extras) // Make sure that the intent is unique using a custom data path (rather than just the extras)
@ -116,7 +119,8 @@ public class ListWidgetProvider extends AppWidgetProvider {
refresh.setData(Uri.parse("intent://widget/" + appWidgetId + "/refresh")); refresh.setData(Uri.parse("intent://widget/" + appWidgetId + "/refresh"));
refresh.putExtra(EXTRA_REFRESH, appWidgetId); refresh.putExtra(EXTRA_REFRESH, appWidgetId);
refresh.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); refresh.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
rv.setOnClickPendingIntent(R.id.refresh_button, PendingIntent.getBroadcast(context, appWidgetId, refresh, PendingIntent.FLAG_UPDATE_CURRENT)); rv.setOnClickPendingIntent(R.id.refresh_button, PendingIntent.getBroadcast(context, appWidgetId, refresh,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
// Set up the control (pause and resume) buttons (calling the WidgetProvider itself) // Set up the control (pause and resume) buttons (calling the WidgetProvider itself)
Intent pauseall = new Intent(context, ListWidgetProvider_.class); Intent pauseall = new Intent(context, ListWidgetProvider_.class);
@ -124,13 +128,15 @@ public class ListWidgetProvider extends AppWidgetProvider {
pauseall.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); pauseall.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
pauseall.setAction(ControlService.INTENT_PAUSEALL); pauseall.setAction(ControlService.INTENT_PAUSEALL);
rv.setOnClickPendingIntent(R.id.pauseall_button, rv.setOnClickPendingIntent(R.id.pauseall_button,
PendingIntent.getBroadcast(context, appWidgetId, pauseall, PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(context, appWidgetId, pauseall,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
Intent resumeall = new Intent(context, ListWidgetProvider_.class); Intent resumeall = new Intent(context, ListWidgetProvider_.class);
resumeall.setData(Uri.parse("intent://widget/" + appWidgetId + "/resumeall")); resumeall.setData(Uri.parse("intent://widget/" + appWidgetId + "/resumeall"));
resumeall.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); resumeall.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
resumeall.setAction(ControlService.INTENT_RESUMEALL); resumeall.setAction(ControlService.INTENT_RESUMEALL);
rv.setOnClickPendingIntent(R.id.resumeall_button, rv.setOnClickPendingIntent(R.id.resumeall_button,
PendingIntent.getBroadcast(context, appWidgetId, resumeall, PendingIntent.FLAG_UPDATE_CURRENT)); PendingIntent.getBroadcast(context, appWidgetId, resumeall,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
return rv; return rv;

Loading…
Cancel
Save