diff options
author | ueen <ueli.sarnighausen@online.de> | 2024-01-20 17:31:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 17:31:16 +0100 |
commit | 34fb2050b257d81438374bd39d4625be4b580325 (patch) | |
tree | eafa399c05b306289e5fd657f19b9af39084ef56 /app | |
parent | 6e2a8b86a7d59a2e18cebab4cf8e057d8dcfa9e4 (diff) | |
download | AntennaPod-34fb2050b257d81438374bd39d4625be4b580325.zip |
Hide refresh from toolbar (#6850)
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java | 33 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java | 33 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java | 29 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java | 13 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java | 16 | ||||
-rw-r--r-- | app/src/main/res/menu/downloads_completed.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/episodes.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/feedlist.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/home.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/inbox.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/queue.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/menu/subscriptions.xml | 3 | ||||
-rw-r--r-- | app/src/main/res/values/integers.xml | 1 |
13 files changed, 59 insertions, 87 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java index 00d671d36..0cbc23a56 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -2,8 +2,6 @@ package de.danoeh.antennapod.fragment; import android.content.DialogInterface; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.util.Log; import android.view.ContextMenu; import android.view.KeyEvent; @@ -13,6 +11,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; + import androidx.annotation.NonNull; import androidx.appcompat.widget.Toolbar; import androidx.core.util.Pair; @@ -20,9 +19,19 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SimpleItemAnimator; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; @@ -51,13 +60,6 @@ import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; /** * Shows unread or recently published episodes @@ -77,6 +79,7 @@ public abstract class EpisodesListFragment extends Fragment EmptyViewHandler emptyView; SpeedDialView speedDialView; MaterialToolbar toolbar; + SwipeRefreshLayout swipeRefreshLayout; SwipeActions swipeActions; private ProgressBar progressBar; @@ -180,13 +183,9 @@ public abstract class EpisodesListFragment extends Fragment ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } - SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> { - FeedUpdateManager.runOnceOrAsk(requireContext()); - new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), - getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms)); - }); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); listAdapter = new EpisodeItemListAdapter((MainActivity) getActivity()) { @Override @@ -456,9 +455,7 @@ public abstract class EpisodesListFragment extends Fragment @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(FeedUpdateRunningEvent event) { - if (toolbar.getMenu().findItem(R.id.refresh_item) != null) { - MenuItemUtils.updateRefreshMenuItem(toolbar.getMenu(), R.id.refresh_item, event.isFeedUpdateRunning); - } + swipeRefreshLayout.setRefreshing(event.isFeedUpdateRunning); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java index 4853c3dae..8020235b9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java @@ -4,8 +4,6 @@ import android.content.Context; import android.content.res.Configuration; import android.graphics.LightingColorFilter; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.util.Log; import android.view.ContextMenu; import android.view.KeyEvent; @@ -15,17 +13,30 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.Toast; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; + import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.snackbar.Snackbar; import com.joanzapata.iconify.Iconify; import com.leinardi.android.speeddial.SpeedDialView; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; @@ -72,15 +83,6 @@ import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.Validate; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; /** * Displays a list of FeedItems. @@ -189,11 +191,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem EventBus.getDefault().register(this); viewBinding.swipeRefresh.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - viewBinding.swipeRefresh.setOnRefreshListener(() -> { - FeedUpdateManager.runOnceOrAsk(requireContext(), feed); - new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.swipeRefresh.setRefreshing(false), - getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms)); - }); + viewBinding.swipeRefresh.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext(), feed)); loadItems(); @@ -431,8 +429,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem if (!event.isFeedUpdateRunning) { nextPageLoader.getRoot().setVisibility(View.GONE); } - MenuItemUtils.updateRefreshMenuItem(viewBinding.toolbar.getMenu(), - R.id.refresh_item, event.isFeedUpdateRunning); + viewBinding.swipeRefresh.setRefreshing(event.isFeedUpdateRunning); } private void refreshHeaderView() { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 1e32ee465..aacd05fcd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -4,8 +4,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.util.Log; import android.view.ContextMenu; import android.view.KeyEvent; @@ -16,6 +14,7 @@ import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.ProgressBar; import android.widget.TextView; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; @@ -23,10 +22,19 @@ import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SimpleItemAnimator; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; import com.leinardi.android.speeddial.SpeedDialView; + +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; +import java.util.Locale; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.adapter.EpisodeItemListAdapter; @@ -62,12 +70,6 @@ import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; import io.reactivex.schedulers.Schedulers; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; -import org.greenrobot.eventbus.ThreadMode; - -import java.util.List; -import java.util.Locale; /** * Shows all items in the queue. @@ -82,6 +84,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte private QueueRecyclerAdapter recyclerAdapter; private EmptyViewHandler emptyView; private MaterialToolbar toolbar; + private SwipeRefreshLayout swipeRefreshLayout; private boolean displayUpArrow; private List<FeedItem> queue; @@ -265,7 +268,7 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(FeedUpdateRunningEvent event) { - MenuItemUtils.updateRefreshMenuItem(toolbar.getMenu(), R.id.refresh_item, event.isFeedUpdateRunning); + swipeRefreshLayout.setRefreshing(event.isFeedUpdateRunning); } @Override @@ -425,13 +428,9 @@ public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuIte recyclerAdapter.setOnSelectModeListener(this); recyclerView.setAdapter(recyclerAdapter); - SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> { - FeedUpdateManager.runOnceOrAsk(requireContext()); - new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), - getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms)); - }); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); emptyView = new EmptyViewHandler(getContext()); emptyView.attachToRecyclerView(recyclerView); 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 7006edca9..e86cd58b9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -3,8 +3,6 @@ package de.danoeh.antennapod.fragment; import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.util.Log; import android.view.ContextMenu; import android.view.LayoutInflater; @@ -81,6 +79,7 @@ public class SubscriptionFragment extends Fragment private EmptyViewHandler emptyView; private LinearLayout feedsFilteredMsg; private MaterialToolbar toolbar; + private SwipeRefreshLayout swipeRefreshLayout; private ProgressBar progressBar; private String displayedFolder = null; private boolean displayUpArrow; @@ -169,13 +168,9 @@ public class SubscriptionFragment extends Fragment feedsFilteredMsg.setOnClickListener((l) -> new SubscriptionsFilterDialog().show(getChildFragmentManager(), "filter")); - SwipeRefreshLayout swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); + swipeRefreshLayout = root.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - swipeRefreshLayout.setOnRefreshListener(() -> { - FeedUpdateManager.runOnceOrAsk(requireContext()); - new Handler(Looper.getMainLooper()).postDelayed(() -> swipeRefreshLayout.setRefreshing(false), - getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms)); - }); + swipeRefreshLayout.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); speedDialView = root.findViewById(R.id.fabSD); speedDialView.setOverlayLayout(root.findViewById(R.id.fabSDOverlay)); @@ -212,7 +207,7 @@ public class SubscriptionFragment extends Fragment @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(FeedUpdateRunningEvent event) { - MenuItemUtils.updateRefreshMenuItem(toolbar.getMenu(), R.id.refresh_item, event.isFeedUpdateRunning); + swipeRefreshLayout.setRefreshing(event.isFeedUpdateRunning); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java index 86c084a67..6f43a8ff4 100644 --- a/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/ui/home/HomeFragment.java @@ -6,8 +6,6 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -21,8 +19,6 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentContainerView; -import de.danoeh.antennapod.ui.echo.EchoActivity; -import de.danoeh.antennapod.ui.home.sections.EchoSection; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -34,7 +30,6 @@ import java.util.List; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; -import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.databinding.HomeFragmentBinding; @@ -42,8 +37,10 @@ import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.FeedUpdateRunningEvent; import de.danoeh.antennapod.fragment.SearchFragment; import de.danoeh.antennapod.storage.preferences.UserPreferences; +import de.danoeh.antennapod.ui.echo.EchoActivity; import de.danoeh.antennapod.ui.home.sections.AllowNotificationsSection; import de.danoeh.antennapod.ui.home.sections.DownloadsSection; +import de.danoeh.antennapod.ui.home.sections.EchoSection; import de.danoeh.antennapod.ui.home.sections.EpisodesSurpriseSection; import de.danoeh.antennapod.ui.home.sections.InboxSection; import de.danoeh.antennapod.ui.home.sections.QueueSection; @@ -86,11 +83,7 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis updateWelcomeScreenVisibility(); viewBinding.swipeRefresh.setDistanceToTriggerSync(getResources().getInteger(R.integer.swipe_refresh_distance)); - viewBinding.swipeRefresh.setOnRefreshListener(() -> { - FeedUpdateManager.runOnceOrAsk(requireContext()); - new Handler(Looper.getMainLooper()).postDelayed(() -> viewBinding.swipeRefresh.setRefreshing(false), - getResources().getInteger(R.integer.swipe_to_refresh_duration_in_ms)); - }); + viewBinding.swipeRefresh.setOnRefreshListener(() -> FeedUpdateManager.runOnceOrAsk(requireContext())); return viewBinding.getRoot(); } @@ -154,8 +147,7 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) public void onEventMainThread(FeedUpdateRunningEvent event) { - MenuItemUtils.updateRefreshMenuItem(viewBinding.toolbar.getMenu(), - R.id.refresh_item, event.isFeedUpdateRunning); + viewBinding.swipeRefresh.setRefreshing(event.isFeedUpdateRunning); } @Override diff --git a/app/src/main/res/menu/downloads_completed.xml b/app/src/main/res/menu/downloads_completed.xml index e4d82696f..a7753d080 100644 --- a/app/src/main/res/menu/downloads_completed.xml +++ b/app/src/main/res/menu/downloads_completed.xml @@ -20,8 +20,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - android:icon="@drawable/ic_refresh" - app:showAsAction="always" /> + app:showAsAction="never" /> <item android:id="@+id/downloads_sort" android:title="@string/sort" /> diff --git a/app/src/main/res/menu/episodes.xml b/app/src/main/res/menu/episodes.xml index 5c7bd7351..4c8e0dbb3 100644 --- a/app/src/main/res/menu/episodes.xml +++ b/app/src/main/res/menu/episodes.xml @@ -13,8 +13,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="always" - android:icon="@drawable/ic_refresh"/> + custom:showAsAction="never" /> <item android:id="@+id/filter_items" diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index 2086ff547..0baf434f1 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -10,10 +10,9 @@ </item> <item android:id="@+id/refresh_item" - android:icon="@drawable/ic_refresh" android:menuCategory="container" android:title="@string/refresh_label" - custom:showAsAction="always"> + custom:showAsAction="never"> </item> <item android:id="@+id/refresh_complete_item" diff --git a/app/src/main/res/menu/home.xml b/app/src/main/res/menu/home.xml index f80218c0c..a0bca6d50 100644 --- a/app/src/main/res/menu/home.xml +++ b/app/src/main/res/menu/home.xml @@ -12,8 +12,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="always" - android:icon="@drawable/ic_refresh"/> + custom:showAsAction="never" /> <item android:id="@+id/homesettings_items" diff --git a/app/src/main/res/menu/inbox.xml b/app/src/main/res/menu/inbox.xml index 50aee25f3..725d6e90e 100644 --- a/app/src/main/res/menu/inbox.xml +++ b/app/src/main/res/menu/inbox.xml @@ -12,8 +12,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="always" - android:icon="@drawable/ic_refresh"/> + custom:showAsAction="never" /> <item android:id="@+id/inbox_sort" diff --git a/app/src/main/res/menu/queue.xml b/app/src/main/res/menu/queue.xml index 256069148..5f34d0a96 100644 --- a/app/src/main/res/menu/queue.xml +++ b/app/src/main/res/menu/queue.xml @@ -12,8 +12,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="always" - android:icon="@drawable/ic_refresh"/> + custom:showAsAction="never" /> <item android:id="@+id/queue_lock" diff --git a/app/src/main/res/menu/subscriptions.xml b/app/src/main/res/menu/subscriptions.xml index 845ee92a2..3a2614149 100644 --- a/app/src/main/res/menu/subscriptions.xml +++ b/app/src/main/res/menu/subscriptions.xml @@ -15,8 +15,7 @@ android:id="@+id/refresh_item" android:title="@string/refresh_label" android:menuCategory="container" - custom:showAsAction="always" - android:icon="@drawable/ic_refresh"/> + custom:showAsAction="never" /> <item android:id="@+id/subscriptions_filter" android:title="@string/filter" diff --git a/app/src/main/res/values/integers.xml b/app/src/main/res/values/integers.xml index 03da6c669..dab3a062c 100644 --- a/app/src/main/res/values/integers.xml +++ b/app/src/main/res/values/integers.xml @@ -2,6 +2,5 @@ <resources> <integer name="subscriptions_default_num_of_columns">3</integer> <integer name="nav_drawer_screen_size_percent">80</integer> - <integer name="swipe_to_refresh_duration_in_ms">750</integer> <integer name="swipe_refresh_distance">300</integer> </resources>
\ No newline at end of file |