From 26071dc3cfe6184ea10ee49429a3e499e93e29a0 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 29 Oct 2020 20:10:05 +0100 Subject: Make notification channels consistent between app settings and system settings --- app/src/main/res/xml/preferences_notifications.xml | 41 +++++++++------ .../download/DownloadServiceNotification.java | 2 +- .../core/util/gui/NotificationUtils.java | 61 +++++++++++++++------- core/src/main/res/values/strings.xml | 16 +++--- 4 files changed, 73 insertions(+), 47 deletions(-) diff --git a/app/src/main/res/xml/preferences_notifications.xml b/app/src/main/res/xml/preferences_notifications.xml index 3aa907ca8..237ea5c99 100644 --- a/app/src/main/res/xml/preferences_notifications.xml +++ b/app/src/main/res/xml/preferences_notifications.xml @@ -2,21 +2,28 @@ - - - + + + + + + + + \ No newline at end of file diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java index 975bc3cb3..2d482c689 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadServiceNotification.java @@ -148,7 +148,7 @@ public class DownloadServiceNotification { id = R.id.notification_auto_download_report; content = createAutoDownloadNotificationContent(reportQueue); } else { - channelId = NotificationUtils.CHANNEL_ID_ERROR; + channelId = NotificationUtils.CHANNEL_ID_DOWNLOAD_ERROR; titleId = R.string.download_report_title; iconId = R.drawable.ic_notification_sync_error; intent = ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(context); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java index ddbe68938..47975b013 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.util.gui; import android.app.NotificationChannel; +import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.content.Context; import android.os.Build; @@ -13,10 +14,13 @@ public class NotificationUtils { public static final String CHANNEL_ID_USER_ACTION = "user_action"; public static final String CHANNEL_ID_DOWNLOADING = "downloading"; public static final String CHANNEL_ID_PLAYING = "playing"; - public static final String CHANNEL_ID_ERROR = "error"; + public static final String CHANNEL_ID_DOWNLOAD_ERROR = "error"; public static final String CHANNEL_ID_SYNC_ERROR = "sync_error"; public static final String CHANNEL_ID_AUTO_DOWNLOAD = "auto_download"; + public static final String GROUP_ID_ERRORS = "group_errors"; + public static final String GROUP_ID_NEWS = "group_news"; + public static void createChannels(Context context) { if (android.os.Build.VERSION.SDK_INT < 26) { return; @@ -24,6 +28,9 @@ public class NotificationUtils { NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (mNotificationManager != null) { + mNotificationManager.createNotificationChannelGroup(createGroupErrors(context)); + mNotificationManager.createNotificationChannelGroup(createGroupNews(context)); + mNotificationManager.createNotificationChannel(createChannelUserAction(context)); mNotificationManager.createNotificationChannel(createChannelDownloading(context)); mNotificationManager.createNotificationChannel(createChannelPlaying(context)); @@ -35,36 +42,38 @@ public class NotificationUtils { @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelUserAction(Context c) { - NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_USER_ACTION, + NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_USER_ACTION, c.getString(R.string.notification_channel_user_action), NotificationManager.IMPORTANCE_HIGH); - mChannel.setDescription(c.getString(R.string.notification_channel_user_action_description)); - return mChannel; + notificationChannel.setDescription(c.getString(R.string.notification_channel_user_action_description)); + notificationChannel.setGroup(GROUP_ID_ERRORS); + return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelDownloading(Context c) { - NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_DOWNLOADING, + NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_DOWNLOADING, c.getString(R.string.notification_channel_downloading), NotificationManager.IMPORTANCE_LOW); - mChannel.setDescription(c.getString(R.string.notification_channel_downloading_description)); - mChannel.setShowBadge(false); - return mChannel; + notificationChannel.setDescription(c.getString(R.string.notification_channel_downloading_description)); + notificationChannel.setShowBadge(false); + return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelPlaying(Context c) { - NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_PLAYING, + NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_PLAYING, c.getString(R.string.notification_channel_playing), NotificationManager.IMPORTANCE_LOW); - mChannel.setDescription(c.getString(R.string.notification_channel_playing_description)); - mChannel.setShowBadge(false); - return mChannel; + notificationChannel.setDescription(c.getString(R.string.notification_channel_playing_description)); + notificationChannel.setShowBadge(false); + return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelError(Context c) { - NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_ERROR, - c.getString(R.string.notification_channel_error), NotificationManager.IMPORTANCE_HIGH); - mChannel.setDescription(c.getString(R.string.notification_channel_error_description)); - return mChannel; + NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_DOWNLOAD_ERROR, + c.getString(R.string.notification_channel_download_error), NotificationManager.IMPORTANCE_HIGH); + notificationChannel.setDescription(c.getString(R.string.notification_channel_download_error_description)); + notificationChannel.setGroup(GROUP_ID_ERRORS); + return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) @@ -72,14 +81,28 @@ public class NotificationUtils { NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_SYNC_ERROR, c.getString(R.string.notification_channel_sync_error), NotificationManager.IMPORTANCE_HIGH); notificationChannel.setDescription(c.getString(R.string.notification_channel_sync_error_description)); + notificationChannel.setGroup(GROUP_ID_ERRORS); return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelAutoDownload(Context c) { - NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID_AUTO_DOWNLOAD, + NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_AUTO_DOWNLOAD, c.getString(R.string.notification_channel_auto_download), NotificationManager.IMPORTANCE_DEFAULT); - mChannel.setDescription(c.getString(R.string.notification_channel_episode_auto_download)); - return mChannel; + notificationChannel.setDescription(c.getString(R.string.notification_channel_episode_auto_download)); + notificationChannel.setGroup(GROUP_ID_NEWS); + return notificationChannel; + } + + @RequiresApi(api = Build.VERSION_CODES.O) + private static NotificationChannelGroup createGroupErrors(Context c) { + return new NotificationChannelGroup(GROUP_ID_ERRORS, + c.getString(R.string.notification_group_errors)); + } + + @RequiresApi(api = Build.VERSION_CODES.O) + private static NotificationChannelGroup createGroupNews(Context c) { + return new NotificationChannelGroup(GROUP_ID_NEWS, + c.getString(R.string.notification_group_news)); } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d760052d4..9f536c037 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -450,8 +450,6 @@ Force full synchronization Sync all subscriptions and episode states with gpodder.net. %1$s with device %2$s]]> - Synchronization failed - This setting does not apply to authentication errors. Customize the speeds available for variable speed playback The speed to use when starting audio playback for episodes in this podcast Auto Skip @@ -478,10 +476,6 @@ You can only select a maximum of %1$d items. Set Lockscreen Background Set the lockscreen background to the current episode\'s image. As a side effect, this will also show the image in third party apps. - Download failed - If downloads fail, generate a report that shows the details of the failure. - Automatic download completed - Show a notification for automatically downloaded episodes. Android versions before 4.1 do not support expanded notifications. Enqueue Location Add episodes to: %1$s @@ -854,17 +848,19 @@ Error playing media. Skipping… + Errors + News Action required Shown if your action is required, for example if you need to enter a password. Downloading Shown while currently downloading. Currently playing Allows to control playback. This is the main notification you see while playing a podcast. - Errors - Shown if something went wrong, for example if download or feed update fails. - Synchronization Errors + Download failed + Shown when download or feed update fails. + Synchronization failed Shown when gpodder synchronization fails. - Auto Downloads + Automatic download completed Shown when episodes have been automatically downloaded. -- cgit v1.2.3 From 151cccce666d7eca4026bd90c64243c0afa92380 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 29 Oct 2020 20:21:43 +0100 Subject: Use system's notification settings on supported devices --- .../fragment/preferences/MainPreferencesFragment.java | 13 +++++++++++-- .../danoeh/antennapod/core/preferences/UserPreferences.java | 9 +++++++++ .../java/de/danoeh/antennapod/core/sync/SyncService.java | 6 +++++- .../danoeh/antennapod/core/util/gui/NotificationUtils.java | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index 99fd12021..7b533cf4e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -1,7 +1,9 @@ package de.danoeh.antennapod.fragment.preferences; import android.content.Intent; +import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.PreferenceFragmentCompat; import com.bytehamster.lib.preferencesearch.SearchConfiguration; @@ -10,6 +12,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.BugReportActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.util.IntentUtils; +import de.danoeh.antennapod.core.util.gui.NotificationUtils; import de.danoeh.antennapod.fragment.preferences.about.AboutFragment; public class MainPreferencesFragment extends PreferenceFragmentCompat { @@ -70,10 +73,16 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { return true; }); findPreference(PREF_NOTIFICATION).setOnPreferenceClickListener(preference -> { - ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_notifications); + if (Build.VERSION.SDK_INT >= 26) { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); + intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName()); + startActivity(intent); + } else { + ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_notifications); + } return true; }); - findPreference(PREF_ABOUT).setOnPreferenceClickListener( preference -> { getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutFragment()) diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 56dd95fe6..5ded1d447 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -301,10 +301,16 @@ public class UserPreferences { * @return {@code true} if download reports are shown, {@code false} otherwise */ public static boolean showDownloadReport() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); } public static boolean showAutoDownloadReport() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); } @@ -728,6 +734,9 @@ public class UserPreferences { } public static boolean gpodnetNotificationsEnabled() { + if (Build.VERSION.SDK_INT >= 26) { + return true; // System handles notification preferences + } return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index 1f5d9b75f..ffe90eee2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -485,7 +485,11 @@ public class SyncService extends Worker { } private void updateErrorNotification(SyncServiceException exception) { - Log.d(TAG, "Posting error notification"); + if (!UserPreferences.gpodnetNotificationsEnabled()) { + Log.d(TAG, "Skipping sync error notification because of user setting"); + return; + } + Log.d(TAG, "Posting sync error notification"); final String description = getApplicationContext().getString(R.string.gpodnetsync_error_descr) + exception.getMessage(); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java index 47975b013..168350b34 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java @@ -22,7 +22,7 @@ public class NotificationUtils { public static final String GROUP_ID_NEWS = "group_news"; public static void createChannels(Context context) { - if (android.os.Build.VERSION.SDK_INT < 26) { + if (Build.VERSION.SDK_INT < 26) { return; } NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); -- cgit v1.2.3 From 7ac4f1856144d37916eadce03af5957c6d5a2a4f Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Thu, 29 Oct 2020 20:39:50 +0100 Subject: Migrate notification channel settings --- .../core/preferences/UserPreferences.java | 21 +++++++++++++++++++++ .../antennapod/core/util/gui/NotificationUtils.java | 18 +++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index 5ded1d447..ed9c519a6 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -307,6 +307,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getShowDownloadReportRaw() { + return prefs.getBoolean(PREF_SHOW_DOWNLOAD_REPORT, true); + } + public static boolean showAutoDownloadReport() { if (Build.VERSION.SDK_INT >= 26) { return true; // System handles notification preferences @@ -314,6 +321,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getShowAutoDownloadReportRaw() { + return prefs.getBoolean(PREF_SHOW_AUTO_DOWNLOAD_REPORT, false); + } + public static boolean enqueueDownloadedEpisodes() { return prefs.getBoolean(PREF_ENQUEUE_DOWNLOADED, true); } @@ -740,6 +754,13 @@ public class UserPreferences { return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); } + /** + * Used for migration of the preference to system notification channels. + */ + public static boolean getGpodnetNotificationsEnabledRaw() { + return prefs.getBoolean(PREF_GPODNET_NOTIFICATIONS, true); + } + public static void setGpodnetNotificationsEnabled() { prefs.edit() .putBoolean(PREF_GPODNET_NOTIFICATIONS, true) diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java index 168350b34..3101eac34 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/gui/NotificationUtils.java @@ -9,6 +9,7 @@ import android.os.Build; import androidx.annotation.RequiresApi; import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.preferences.UserPreferences; public class NotificationUtils { public static final String CHANNEL_ID_USER_ACTION = "user_action"; @@ -73,6 +74,11 @@ public class NotificationUtils { c.getString(R.string.notification_channel_download_error), NotificationManager.IMPORTANCE_HIGH); notificationChannel.setDescription(c.getString(R.string.notification_channel_download_error_description)); notificationChannel.setGroup(GROUP_ID_ERRORS); + + if (!UserPreferences.getShowDownloadReportRaw()) { + // Migration from app managed setting: disable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); + } return notificationChannel; } @@ -82,15 +88,25 @@ public class NotificationUtils { c.getString(R.string.notification_channel_sync_error), NotificationManager.IMPORTANCE_HIGH); notificationChannel.setDescription(c.getString(R.string.notification_channel_sync_error_description)); notificationChannel.setGroup(GROUP_ID_ERRORS); + + if (!UserPreferences.getGpodnetNotificationsEnabledRaw()) { + // Migration from app managed setting: disable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); + } return notificationChannel; } @RequiresApi(api = Build.VERSION_CODES.O) private static NotificationChannel createChannelAutoDownload(Context c) { NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID_AUTO_DOWNLOAD, - c.getString(R.string.notification_channel_auto_download), NotificationManager.IMPORTANCE_DEFAULT); + c.getString(R.string.notification_channel_auto_download), NotificationManager.IMPORTANCE_NONE); notificationChannel.setDescription(c.getString(R.string.notification_channel_episode_auto_download)); notificationChannel.setGroup(GROUP_ID_NEWS); + + if (UserPreferences.getShowAutoDownloadReportRaw()) { + // Migration from app managed setting: enable notification + notificationChannel.setImportance(NotificationManager.IMPORTANCE_DEFAULT); + } return notificationChannel; } -- cgit v1.2.3 From ec9d631d8d4df732d6288431960bca2bdd2fa4a9 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Mon, 2 Nov 2020 17:10:20 +0100 Subject: Fixed crash when playing from preferences --- .../de/danoeh/antennapod/core/feed/util/PlaybackSpeedUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/util/PlaybackSpeedUtils.java b/core/src/main/java/de/danoeh/antennapod/core/feed/util/PlaybackSpeedUtils.java index 0d5ecbb71..d6740994d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/util/PlaybackSpeedUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/util/PlaybackSpeedUtils.java @@ -1,5 +1,6 @@ package de.danoeh.antennapod.core.feed.util; +import android.util.Log; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.feed.FeedItem; import de.danoeh.antennapod.core.feed.FeedMedia; @@ -14,6 +15,7 @@ import static de.danoeh.antennapod.core.feed.FeedPreferences.SPEED_USE_GLOBAL; * Utility class to use the appropriate playback speed based on {@link PlaybackPreferences} */ public final class PlaybackSpeedUtils { + private static final String TAG = "PlaybackSpeedUtils"; private PlaybackSpeedUtils() { } @@ -33,8 +35,10 @@ public final class PlaybackSpeedUtils { FeedItem item = ((FeedMedia) media).getItem(); if (item != null) { Feed feed = item.getFeed(); - if (feed != null) { + if (feed != null && feed.getPreferences() != null) { playbackSpeed = feed.getPreferences().getFeedPlaybackSpeed(); + } else { + Log.d(TAG, "Can not get feed specific playback speed: " + feed); } } } -- cgit v1.2.3 From a3a5a936a2c1cc9d9a7b6580be15ed2c19e912f7 Mon Sep 17 00:00:00 2001 From: Anderson Mesquita Date: Mon, 2 Nov 2020 18:01:32 -0500 Subject: Remove IF NOT EXISTS from index create statements `onCreate()` should only ever be called once, where the tables and indices are created. Any other changes need to happen via `onUpgrade()`, so we can safely remove `IF NOT EXISTS`. When importing any database into the app (e.g. if it gets corrupted and is recreated with `sqlite3 old-database.db ".dump"`), it first needs to be set back to the correct version. This can be done in sqlite with: $ sqlite3 old-database.db "PRAGMA user_version" $ sqlite3 new-database.db "PRAGMA user_version = " For more context, see this PR: https://github.com/AntennaPod/AntennaPod/pull/4585 --- .../src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 935b06cd6..539bedd9f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -195,11 +195,11 @@ public class PodDBAdapter { + TABLE_NAME_FEED_ITEMS + "_" + KEY_FEED + " ON " + TABLE_NAME_FEED_ITEMS + " (" + KEY_FEED + ")"; - static final String CREATE_INDEX_FEEDITEMS_PUBDATE = "CREATE INDEX IF NOT EXISTS " + static final String CREATE_INDEX_FEEDITEMS_PUBDATE = "CREATE INDEX " + TABLE_NAME_FEED_ITEMS + "_" + KEY_PUBDATE + " ON " + TABLE_NAME_FEED_ITEMS + " (" + KEY_PUBDATE + ")"; - static final String CREATE_INDEX_FEEDITEMS_READ = "CREATE INDEX IF NOT EXISTS " + static final String CREATE_INDEX_FEEDITEMS_READ = "CREATE INDEX " + TABLE_NAME_FEED_ITEMS + "_" + KEY_READ + " ON " + TABLE_NAME_FEED_ITEMS + " (" + KEY_READ + ")"; -- cgit v1.2.3 From ed2348570c36b77361a3d064a6676fa923002677 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 3 Nov 2020 23:55:12 +0100 Subject: Use radio buttons for column number on subscriptions screen --- .../antennapod/fragment/SubscriptionFragment.java | 17 +++++++++--- app/src/main/res/menu/subscriptions.xml | 31 +++++++++++----------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 7d3312e8e..3b4246e3a 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -27,6 +27,7 @@ import android.widget.TextView; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.joanzapata.iconify.Iconify; +import java.util.Locale; import java.util.concurrent.Callable; import de.danoeh.antennapod.R; @@ -69,6 +70,12 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem public static final String TAG = "SubscriptionFragment"; private static final String PREFS = "SubscriptionFragment"; private static final String PREF_NUM_COLUMNS = "columns"; + private static final int MIN_NUM_COLUMNS = 2; + private static final int[] COLUMN_CHECKBOX_IDS = { + R.id.subscription_num_columns_2, + R.id.subscription_num_columns_3, + R.id.subscription_num_columns_4, + R.id.subscription_num_columns_5}; private GridView subscriptionGridLayout; private DBReader.NavDrawerData navDrawerData; @@ -101,6 +108,11 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem toolbar.setOnMenuItemClickListener(this); ((MainActivity) getActivity()).setupToolbarToggle(toolbar); toolbar.inflateMenu(R.menu.subscriptions); + for (int i = 0; i < COLUMN_CHECKBOX_IDS.length; i++) { + // Do this in Java to localize numbers + toolbar.getMenu().findItem(COLUMN_CHECKBOX_IDS[i]) + .setTitle(String.format(Locale.getDefault(), "%d", i + MIN_NUM_COLUMNS)); + } refreshToolbarState(); subscriptionGridLayout = root.findViewById(R.id.subscriptions_grid); @@ -123,10 +135,7 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem private void refreshToolbarState() { int columns = prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()); - toolbar.getMenu().findItem(R.id.subscription_num_columns_2).setChecked(columns == 2); - toolbar.getMenu().findItem(R.id.subscription_num_columns_3).setChecked(columns == 3); - toolbar.getMenu().findItem(R.id.subscription_num_columns_4).setChecked(columns == 4); - toolbar.getMenu().findItem(R.id.subscription_num_columns_5).setChecked(columns == 5); + toolbar.getMenu().findItem(COLUMN_CHECKBOX_IDS[columns - MIN_NUM_COLUMNS]).setChecked(true); isUpdatingFeeds = MenuItemUtils.updateRefreshMenuItem(toolbar.getMenu(), R.id.refresh_item, updateRefreshMenuItemChecker); diff --git a/app/src/main/res/menu/subscriptions.xml b/app/src/main/res/menu/subscriptions.xml index b7dc95299..99acc4bb6 100644 --- a/app/src/main/res/menu/subscriptions.xml +++ b/app/src/main/res/menu/subscriptions.xml @@ -23,22 +23,21 @@ android:title="@string/subscription_num_columns" custom:showAsAction="never"> - - - - + + + + + + -- cgit v1.2.3 From ad56eed255789bb3ea93ea6523276befab1233a2 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Wed, 4 Nov 2020 00:20:56 +0100 Subject: Fixed crash when searching Search view was set up (and started searching) before other views were assigned. --- .../main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java index ba817650b..992b6930c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/OnlineSearchFragment.java @@ -90,7 +90,6 @@ public class OnlineSearchFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_itunes_search, container, false); - setupToolbar(root.findViewById(R.id.toolbar)); root.findViewById(R.id.spinner_country).setVisibility(INVISIBLE); gridView = root.findViewById(R.id.gridView); adapter = new ItunesAdapter(getActivity(), new ArrayList<>()); @@ -110,6 +109,7 @@ public class OnlineSearchFragment extends Fragment { txtvEmpty = root.findViewById(android.R.id.empty); TextView txtvPoweredBy = root.findViewById(R.id.search_powered_by); txtvPoweredBy.setText(getString(R.string.search_powered_by, searchProvider.getName())); + setupToolbar(root.findViewById(R.id.toolbar)); return root; } -- cgit v1.2.3 From adcab6f9832b4a77b888e6e00c3ccf8efd60f64a Mon Sep 17 00:00:00 2001 From: asdoi <36813904+asdoi@users.noreply.github.com> Date: Wed, 4 Nov 2020 10:18:44 +0100 Subject: Show "include in auto downloads" checkbox on adding podcast (#4627) --- .../activity/OnlineFeedViewActivity.java | 11 ++++ .../main/res/layout/onlinefeedview_activity.xml | 72 ++++++++++++++-------- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 3f58e4a92..2fd537159 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -13,6 +13,7 @@ import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.UiThread; @@ -509,11 +510,21 @@ public class OnlineFeedViewActivity extends AppCompatActivity { viewBinding.subscribeButton.setEnabled(true); viewBinding.subscribeButton.setText(R.string.open_podcast); if (didPressSubscribe) { + didPressSubscribe = false; + if (UserPreferences.isEnableAutodownload()) { + Feed feed1 = DBReader.getFeed(getFeedId(feed)); + FeedPreferences feedPreferences = feed1.getPreferences(); + feedPreferences.setAutoDownload(viewBinding.autoDownloadCheckBox.isChecked()); + feed1.savePreferences(); + } openFeed(); } } else { viewBinding.subscribeButton.setEnabled(true); viewBinding.subscribeButton.setText(R.string.subscribe_label); + if (UserPreferences.isEnableAutodownload()) { + viewBinding.autoDownloadCheckBox.setVisibility(View.VISIBLE); + } } } } diff --git a/app/src/main/res/layout/onlinefeedview_activity.xml b/app/src/main/res/layout/onlinefeedview_activity.xml index 88ffbb8b6..909d676f0 100644 --- a/app/src/main/res/layout/onlinefeedview_activity.xml +++ b/app/src/main/res/layout/onlinefeedview_activity.xml @@ -105,35 +105,55 @@ tools:text="Podcast author"/> - - -