From 467b2ae1a3ac6884dac0581d9620235049258c4a Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 22 Mar 2020 23:07:59 +0100 Subject: [PATCH] Created audio player fragment --- .../antennapod/activity/MainActivity.java | 5 + .../fragment/AudioPlayerFragment.java | 37 +++ .../fragment/NavDrawerFragment.java | 1 + .../main/res/layout/audioplayer_fragment.xml | 233 ++++++++++++++++++ core/src/main/res/values/arrays.xml | 1 + 5 files changed, 277 insertions(+) create mode 100644 app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java create mode 100644 app/src/main/res/layout/audioplayer_fragment.xml diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 6dab5ab45..35328f0c3 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -31,6 +31,7 @@ import de.danoeh.antennapod.core.util.Flavors; import de.danoeh.antennapod.core.util.StorageUtils; import de.danoeh.antennapod.dialog.RatingDialog; import de.danoeh.antennapod.fragment.AddFeedFragment; +import de.danoeh.antennapod.fragment.AudioPlayerFragment; import de.danoeh.antennapod.fragment.DownloadsFragment; import de.danoeh.antennapod.fragment.EpisodesFragment; import de.danoeh.antennapod.fragment.ExternalPlayerFragment; @@ -158,6 +159,9 @@ public class MainActivity extends CastEnabledActivity { case QueueFragment.TAG: fragment = new QueueFragment(); break; + case AudioPlayerFragment.TAG: + fragment = new AudioPlayerFragment(); + break; case EpisodesFragment.TAG: fragment = new EpisodesFragment(); break; @@ -305,6 +309,7 @@ public class MainActivity extends CastEnabledActivity { switch (NavDrawerFragment.getLastNavFragment(this)) { case QueueFragment.TAG: case EpisodesFragment.TAG: + case AudioPlayerFragment.TAG: requestCastButton(MenuItem.SHOW_AS_ACTION_IF_ROOM); return retVal; case DownloadsFragment.TAG: diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java new file mode 100644 index 000000000..6b6b07d82 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java @@ -0,0 +1,37 @@ +package de.danoeh.antennapod.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; +import de.danoeh.antennapod.R; + +/** + * Shows the audio player. + */ +public class AudioPlayerFragment extends Fragment { + public static final String TAG = "AudioPlayerFragment"; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + View root = inflater.inflate(R.layout.audioplayer_fragment, container, false); + ((AppCompatActivity) getActivity()).setSupportActionBar(root.findViewById(R.id.toolbar)); + + + return root; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setRetainInstance(true); + + // So, we certainly *don't* have an options menu, + // but unless we say we do, old options menus sometimes + // persist. mfietz thinks this causes the ActionBar to be invalidated + setHasOptionsMenu(true); + } +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java index 63969345c..0ab6b78b9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java @@ -56,6 +56,7 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli public static final String TAG = "NavDrawerFragment"; public static final String[] NAV_DRAWER_TAGS = { + AudioPlayerFragment.TAG, QueueFragment.TAG, EpisodesFragment.TAG, SubscriptionFragment.TAG, diff --git a/app/src/main/res/layout/audioplayer_fragment.xml b/app/src/main/res/layout/audioplayer_fragment.xml new file mode 100644 index 000000000..bac3cb648 --- /dev/null +++ b/app/src/main/res/layout/audioplayer_fragment.xml @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index dc79905cd..45ea97eb4 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -196,6 +196,7 @@ + Audio player @string/queue_label @string/episodes_label @string/subscriptions_label