diff options
5 files changed, 119 insertions, 44 deletions
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 @@ <activity android:name=".activity.OnlineFeedViewActivity" android:configChanges="orientation|screenSize" + android:theme="@style/Theme.AntennaPod.Dark.Translucent" android:label="@string/add_feed_label"> <meta-data android:name="android.support.PARENT_ACTIVITY" 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 5102095a7..10a315a9b 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -10,7 +10,6 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.UiThread; import androidx.core.app.NavUtils; -import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.text.TextUtils; @@ -22,10 +21,8 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ProgressBar; -import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; @@ -98,10 +95,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity { private Downloader downloader; private boolean isPaused; + private boolean didPressSubscribe = false; private Dialog dialog; - + private ListView listView; private Button subscribeButton; + private ProgressBar progressBar; private Disposable download; private Disposable parser; @@ -109,18 +108,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { - setTheme(UserPreferences.getTheme()); + setTheme(UserPreferences.getTranslucentTheme()); super.onCreate(savedInstanceState); - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - } - - if (actionBar != null && getIntent() != null && getIntent().hasExtra(ARG_TITLE)) { - actionBar.setTitle(getIntent().getStringExtra(ARG_TITLE)); - } - StorageUtils.checkStorageAvailability(this); + setContentView(R.layout.onlinefeedview_activity); + listView = findViewById(R.id.listview); + progressBar = findViewById(R.id.progressBar); String feedUrl = null; if (getIntent().hasExtra(ARG_FEEDURL)) { @@ -129,9 +122,6 @@ public class OnlineFeedViewActivity extends AppCompatActivity { || TextUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) { feedUrl = TextUtils.equals(getIntent().getAction(), Intent.ACTION_SEND) ? getIntent().getStringExtra(Intent.EXTRA_TEXT) : getIntent().getDataString(); - if (actionBar != null) { - actionBar.setTitle(R.string.add_feed_label); - } } if (feedUrl == null) { @@ -156,19 +146,8 @@ public class OnlineFeedViewActivity extends AppCompatActivity { * Displays a progress indicator. */ private void setLoadingLayout() { - RelativeLayout rl = new RelativeLayout(this); - RelativeLayout.LayoutParams rlLayoutParams = new RelativeLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT); - - ProgressBar pb = new ProgressBar(this); - pb.setIndeterminate(true); - RelativeLayout.LayoutParams pbLayoutParams = new RelativeLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - LinearLayout.LayoutParams.WRAP_CONTENT); - pbLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); - rl.addView(pb, pbLayoutParams); - addContentView(rl, rlLayoutParams); + progressBar.setVisibility(View.VISIBLE); + listView.setVisibility(View.GONE); } @Override @@ -222,6 +201,12 @@ public class OnlineFeedViewActivity extends AppCompatActivity { } @Override + public void finish() { + super.finish(); + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); + } + + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: @@ -291,7 +276,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { .subscribe( feeds -> { 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<String, String> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <androidx.cardview.widget.CardView + android:layout_width="match_parent" + android:layout_height="match_parent" + app:cardCornerRadius="4dp" + android:layout_margin="16dp" + android:elevation="16dp"> + + <FrameLayout + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ProgressBar + style="?android:attr/progressBarStyle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/progressBar" + android:layout_gravity="center"/> + <ListView + android:id="@+id/listview" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + + </FrameLayout> + </androidx.cardview.widget.CardView> +</LinearLayout>
\ 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<String> 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 @@ <?xml version="1.0" encoding="utf-8"?> -<resources xmlns:android="http://schemas.android.com/apk/res/android"> +<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme.AntennaPod.Light" parent="Theme.Base.AntennaPod.Light"> <!-- Room for API dependent attributes --> @@ -224,6 +224,43 @@ <item name="windowActionModeOverlay">true</item> </style> + <style name="Theme.AntennaPod.Light.Translucent" parent="Theme.AntennaPod.Light.NoTitle"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:background">@android:color/transparent</item> + <item name="android:windowContentOverlay">@null</item> + <item name="android:backgroundDimEnabled">true</item> + <item name="android:windowAnimationStyle">@style/AnimationFade</item> + <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> + <item name="android:fitsSystemWindows">true</item> + </style> + + <style name="Theme.AntennaPod.Dark.Translucent" parent="Theme.AntennaPod.Dark.NoTitle"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:background">@android:color/transparent</item> + <item name="android:windowContentOverlay">@null</item> + <item name="android:backgroundDimEnabled">true</item> + <item name="android:windowAnimationStyle">@style/AnimationFade</item> + <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> + <item name="android:fitsSystemWindows">true</item> + </style> + + <style name="Theme.AntennaPod.TrueBlack.Translucent" parent="Theme.Base.AntennaPod.TrueBlack"> + <item name="android:windowIsTranslucent">true</item> + <item name="android:windowBackground">@android:color/transparent</item> + <item name="android:background">@android:color/transparent</item> + <item name="android:windowContentOverlay">@null</item> + <item name="android:backgroundDimEnabled">true</item> + <item name="android:windowAnimationStyle">@style/AnimationFade</item> + <item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item> + <item name="android:fitsSystemWindows">true</item> + </style> + + <style name="AnimationFade"> + <item name="android:windowEnterAnimation">@android:anim/fade_in</item> + <item name="android:windowExitAnimation">@android:anim/fade_out</item> + </style> <style name="Theme.AntennaPod.Dark.Splash" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowBackground">@drawable/bg_splash</item> |