From 8aff9709c379664625eb5c0b4e672115fb9385d4 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Tue, 5 Nov 2019 15:28:29 +0100 Subject: [PATCH] Style OnlineFeedViewActivity like a dialog User study showed that new users do not get the difference between the actual feed list and the preview. If the preview is a dialog, this is a lot easier to see. Additionally, the "dialog" now closes after the subscription succeeded. --- app/src/main/AndroidManifest.xml | 1 + .../activity/OnlineFeedViewActivity.java | 79 +++++++++---------- .../res/layout/onlinefeedview_activity.xml | 33 ++++++++ .../core/preferences/UserPreferences.java | 11 +++ core/src/main/res/values/styles.xml | 39 ++++++++- 5 files changed, 119 insertions(+), 44 deletions(-) create mode 100644 app/src/main/res/layout/onlinefeedview_activity.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8224407a2..ba5f84a14 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -237,6 +237,7 @@ { OnlineFeedViewActivity.this.feeds = feeds; - setSubscribeButtonState(feed); + handleUpdatedFeedStatus(feed); }, error -> Log.e(TAG, Log.getStackTraceString(error)) ); } @@ -299,7 +284,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(DownloadEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); - setSubscribeButtonState(feed); + handleUpdatedFeedStatus(feed); } private void parseFeed() { @@ -374,11 +359,10 @@ public class OnlineFeedViewActivity extends AppCompatActivity { * This method is executed on the GUI thread. */ private void showFeedInformation(final Feed feed, Map alternateFeedUrls) { - setContentView(R.layout.listview_activity); - + progressBar.setVisibility(View.GONE); + listView.setVisibility(View.VISIBLE); this.feed = feed; this.selectedDownloadUrl = feed.getDownload_url(); - ListView listView = findViewById(R.id.listview); listView.setSelector(android.R.color.transparent); LayoutInflater inflater = LayoutInflater.from(this); View header = inflater.inflate(R.layout.onlinefeedview_header, listView, false); @@ -424,11 +408,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity { description.setText(feed.getDescription()); subscribeButton.setOnClickListener(v -> { - if(feedInFeedlist(feed)) { - // feed.getId() is always 0, we have to retrieve the id from the feed list from - // the database - Intent intent = MainActivity.getIntentToOpenFeed(this, getFeedId(feed)); - startActivity(intent); + if (feedInFeedlist(feed)) { + openFeed(); } else { Feed f = new Feed(selectedDownloadUrl, null, feed.getTitle()); f.setPreferences(feed.getPreferences()); @@ -439,7 +420,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity { Log.e(TAG, Log.getStackTraceString(e)); DownloadRequestErrorDialogCreator.newRequestErrorDialog(this, e.getMessage()); } - setSubscribeButtonState(feed); + didPressSubscribe = true; + handleUpdatedFeedStatus(feed); } }); @@ -485,10 +467,18 @@ public class OnlineFeedViewActivity extends AppCompatActivity { } }); } - setSubscribeButtonState(feed); + handleUpdatedFeedStatus(feed); } - private void setSubscribeButtonState(Feed feed) { + private void openFeed() { + // feed.getId() is always 0, we have to retrieve the id from the feed list from + // the database + Intent intent = MainActivity.getIntentToOpenFeed(this, getFeedId(feed)); + finish(); + startActivity(intent); + } + + private void handleUpdatedFeedStatus(Feed feed) { if (subscribeButton != null && feed != null) { if (DownloadRequester.getInstance().isDownloadingFile(feed.getDownload_url())) { subscribeButton.setEnabled(false); @@ -496,6 +486,9 @@ public class OnlineFeedViewActivity extends AppCompatActivity { } else if (feedInFeedlist(feed)) { subscribeButton.setEnabled(true); subscribeButton.setText(R.string.open_podcast); + if (didPressSubscribe) { + openFeed(); + } } else { subscribeButton.setEnabled(true); subscribeButton.setText(R.string.subscribe_label); diff --git a/app/src/main/res/layout/onlinefeedview_activity.xml b/app/src/main/res/layout/onlinefeedview_activity.xml new file mode 100644 index 000000000..b55993fcf --- /dev/null +++ b/app/src/main/res/layout/onlinefeedview_activity.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + \ No newline at end of file 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 be130c00f..86cae3247 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 @@ -182,6 +182,17 @@ public class UserPreferences { } } + public static int getTranslucentTheme() { + int theme = getTheme(); + if (theme == R.style.Theme_AntennaPod_Dark) { + return R.style.Theme_AntennaPod_Dark_Translucent; + } else if (theme == R.style.Theme_AntennaPod_TrueBlack) { + return R.style.Theme_AntennaPod_TrueBlack_Translucent; + } else { + return R.style.Theme_AntennaPod_Light_Translucent; + } + } + public static List getHiddenDrawerItems() { String hiddenItems = prefs.getString(PREF_HIDDEN_DRAWER_ITEMS, ""); return new ArrayList<>(Arrays.asList(TextUtils.split(hiddenItems, ","))); diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index d2ba4bb50..e3f351d05 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -1,5 +1,5 @@ - + + + + + + + +