Migrate Toolbars to Material3

This commit is contained in:
ByteHamster 2022-08-04 23:09:38 +02:00
parent a12854a96b
commit ac8114342c
37 changed files with 266 additions and 177 deletions

View File

@ -19,7 +19,7 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
@ -198,7 +198,7 @@ public class MainActivity extends CastEnabledActivity {
}
};
public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) {
public void setupToolbarToggle(@NonNull MaterialToolbar toolbar, boolean displayUpArrow) {
if (drawerLayout != null) { // Tablet layout does not have a drawer
if (drawerToggle != null) {
drawerLayout.removeDrawerListener(drawerToggle);

View File

@ -8,7 +8,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.joanzapata.iconify.Iconify;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.dialog.AllEpisodesFilterDialog;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
@ -88,8 +87,6 @@ public class AllEpisodesFragment extends EpisodesListFragment {
private void updateFilterUi() {
swipeActions.setFilter(getFilter());
if (getFilter().getValues().length > 0) {
txtvInformation.setText("{md-info-outline} " + this.getString(R.string.filtered_label));
Iconify.addIcons(txtvInformation);
txtvInformation.setVisibility(View.VISIBLE);
emptyView.setMessage(R.string.no_all_episodes_filtered_label);
} else {

View File

@ -15,7 +15,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
@ -23,6 +23,7 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.elevation.SurfaceColors;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
@ -73,7 +74,7 @@ import io.reactivex.schedulers.Schedulers;
* Shows the audio player.
*/
public class AudioPlayerFragment extends Fragment implements
ChapterSeekBar.OnSeekBarChangeListener, Toolbar.OnMenuItemClickListener {
ChapterSeekBar.OnSeekBarChangeListener, MaterialToolbar.OnMenuItemClickListener {
public static final String TAG = "AudioPlayerFragment";
public static final int POS_COVER = 0;
public static final int POS_DESCRIPTION = 1;
@ -91,7 +92,7 @@ public class AudioPlayerFragment extends Fragment implements
private ImageButton butFF;
private TextView txtvFF;
private ImageButton butSkip;
private Toolbar toolbar;
private MaterialToolbar toolbar;
private ProgressBar progressIndicator;
private CardView cardViewSeek;
private TextView txtvSeek;
@ -120,6 +121,7 @@ public class AudioPlayerFragment extends Fragment implements
getChildFragmentManager().beginTransaction()
.replace(R.id.playerFragment, externalPlayerFragment, ExternalPlayerFragment.TAG)
.commit();
root.findViewById(R.id.playerFragment).setBackgroundColor(SurfaceColors.getColorForElevation(getContext(), 8));
butPlaybackSpeed = root.findViewById(R.id.butPlaybackSpeed);
txtvPlaybackSpeed = root.findViewById(R.id.txtvPlaybackSpeed);

View File

@ -10,7 +10,7 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import com.google.android.material.snackbar.Snackbar;
import com.leinardi.android.speeddial.SpeedDialView;
@ -35,6 +35,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
import de.danoeh.antennapod.view.EmptyViewHandler;
import de.danoeh.antennapod.view.EpisodeItemListRecyclerView;
import de.danoeh.antennapod.view.LiftOnScrollListener;
import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -53,7 +54,7 @@ import java.util.List;
* Displays all completed downloads and provides a button to delete them.
*/
public class CompletedDownloadsFragment extends Fragment
implements EpisodeItemListAdapter.OnSelectModeListener, Toolbar.OnMenuItemClickListener {
implements EpisodeItemListAdapter.OnSelectModeListener, MaterialToolbar.OnMenuItemClickListener {
public static final String TAG = "DownloadsFragment";
public static final String ARG_SHOW_LOGS = "show_logs";
private static final String KEY_UP_ARROW = "up_arrow";
@ -73,7 +74,7 @@ public class CompletedDownloadsFragment extends Fragment
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.simple_list_fragment, container, false);
Toolbar toolbar = root.findViewById(R.id.toolbar);
MaterialToolbar toolbar = root.findViewById(R.id.toolbar);
toolbar.setTitle(R.string.downloads_label);
toolbar.inflateMenu(R.menu.downloads_completed);
toolbar.setOnMenuItemClickListener(this);
@ -96,6 +97,7 @@ public class CompletedDownloadsFragment extends Fragment
.getInt(PREF_PREVIOUS_EPISODE_COUNT, 5);
adapter.setDummyViews(Math.max(1, previousEpisodesCount));
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
swipeActions = new SwipeActions(this, TAG).attachTo(recyclerView);
swipeActions.setFilter(new FeedItemFilter(FeedItemFilter.DOWNLOADED));

View File

@ -15,7 +15,7 @@ import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.net.discovery.ItunesTopListLoader;
@ -103,7 +103,7 @@ public class DiscoveryFragment extends Fragment {
adapter = new ItunesAdapter(getActivity(), new ArrayList<>());
gridView.setAdapter(adapter);
Toolbar toolbar = root.findViewById(R.id.toolbar);
MaterialToolbar toolbar = root.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
//Show information about the podcast when the list item is clicked

View File

@ -11,7 +11,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
@ -40,7 +40,7 @@ import java.util.List;
* Shows the download log
*/
public class DownloadLogFragment extends BottomSheetDialogFragment
implements AdapterView.OnItemClickListener, Toolbar.OnMenuItemClickListener {
implements AdapterView.OnItemClickListener, MaterialToolbar.OnMenuItemClickListener {
private static final String TAG = "DownloadLogFragment";
private List<DownloadStatus> downloadLog = new ArrayList<>();

View File

@ -20,6 +20,7 @@ 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 de.danoeh.antennapod.R;
@ -45,6 +46,7 @@ import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
import de.danoeh.antennapod.view.EmptyViewHandler;
import de.danoeh.antennapod.view.EpisodeItemListRecyclerView;
import de.danoeh.antennapod.view.LiftOnScrollListener;
import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder;
import io.reactivex.Completable;
import io.reactivex.Observable;
@ -77,7 +79,7 @@ public abstract class EpisodesListFragment extends Fragment
EpisodeItemListAdapter listAdapter;
EmptyViewHandler emptyView;
SpeedDialView speedDialView;
Toolbar toolbar;
MaterialToolbar toolbar;
SwipeActions swipeActions;
@NonNull
@ -170,9 +172,10 @@ public abstract class EpisodesListFragment extends Fragment
}
((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
recyclerView = root.findViewById(android.R.id.list);
recyclerView = root.findViewById(R.id.recyclerView);
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
setupLoadMoreScrollListener();
recyclerView.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
swipeActions = new SwipeActions(this, getFragmentTag()).attachTo(recyclerView);
swipeActions.setFilter(getFilter());

View File

@ -25,7 +25,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.documentfile.provider.DocumentFile;
import androidx.fragment.app.Fragment;
import com.bumptech.glide.Glide;
@ -62,7 +62,7 @@ import java.util.Iterator;
/**
* Displays information about a feed.
*/
public class FeedInfoFragment extends Fragment implements Toolbar.OnMenuItemClickListener {
public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenuItemClickListener {
private static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feedId";
private static final String TAG = "FeedInfoActivity";
@ -81,7 +81,7 @@ public class FeedInfoFragment extends Fragment implements Toolbar.OnMenuItemClic
private ImageView imgvBackground;
private View infoContainer;
private View header;
private Toolbar toolbar;
private MaterialToolbar toolbar;
public static FeedInfoFragment newInstance(Feed feed) {
FeedInfoFragment fragment = new FeedInfoFragment();

View File

@ -18,7 +18,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@ -81,7 +81,7 @@ import java.util.List;
* Displays a list of FeedItems.
*/
public class FeedItemlistFragment extends Fragment implements AdapterView.OnItemClickListener,
Toolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener {
MaterialToolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener {
public static final String TAG = "ItemlistFragment";
private static final String ARGUMENT_FEED_ID = "argument.de.danoeh.antennapod.feed_id";
private static final String KEY_UP_ARROW = "up_arrow";

View File

@ -8,7 +8,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
@ -61,7 +61,7 @@ public class FeedSettingsFragment extends Fragment {
View root = inflater.inflate(R.layout.feedsettings, container, false);
long feedId = getArguments().getLong(EXTRA_FEED_ID);
Toolbar toolbar = root.findViewById(R.id.toolbar);
MaterialToolbar toolbar = root.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
getParentFragmentManager().beginTransaction()

View File

@ -8,7 +8,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
@ -31,7 +31,7 @@ import io.reactivex.schedulers.Schedulers;
/**
* Displays information about a list of FeedItems.
*/
public class ItemPagerFragment extends Fragment implements Toolbar.OnMenuItemClickListener {
public class ItemPagerFragment extends Fragment implements MaterialToolbar.OnMenuItemClickListener {
private static final String ARG_FEEDITEMS = "feeditems";
private static final String ARG_FEEDITEM_POS = "feeditem_pos";
private static final String KEY_PAGER_ID = "pager_id";
@ -56,7 +56,7 @@ public class ItemPagerFragment extends Fragment implements Toolbar.OnMenuItemCli
private long[] feedItems;
private FeedItem item;
private Disposable disposable;
private Toolbar toolbar;
private MaterialToolbar toolbar;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,

View File

@ -5,7 +5,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.widget.AbsListView;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.appcompat.widget.SearchView;
@ -142,7 +142,7 @@ public class OnlineSearchFragment extends Fragment {
adapter = null;
}
private void setupToolbar(Toolbar toolbar) {
private void setupToolbar(MaterialToolbar toolbar) {
toolbar.inflateMenu(R.menu.online_search);
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());

View File

@ -17,7 +17,7 @@ import android.widget.CheckBox;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
@ -54,6 +54,7 @@ import de.danoeh.antennapod.model.feed.FeedItemFilter;
import de.danoeh.antennapod.model.feed.SortOrder;
import de.danoeh.antennapod.view.EmptyViewHandler;
import de.danoeh.antennapod.view.EpisodeItemListRecyclerView;
import de.danoeh.antennapod.view.LiftOnScrollListener;
import de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -69,7 +70,7 @@ import java.util.Locale;
/**
* Shows all items in the queue.
*/
public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickListener,
public class QueueFragment extends Fragment implements MaterialToolbar.OnMenuItemClickListener,
EpisodeItemListAdapter.OnSelectModeListener {
public static final String TAG = "QueueFragment";
private static final String KEY_UP_ARROW = "up_arrow";
@ -78,7 +79,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
private EpisodeItemListRecyclerView recyclerView;
private QueueRecyclerAdapter recyclerAdapter;
private EmptyViewHandler emptyView;
private Toolbar toolbar;
private MaterialToolbar toolbar;
private boolean displayUpArrow;
private List<FeedItem> queue;
@ -453,6 +454,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
}
recyclerView.setRecycledViewPool(((MainActivity) getActivity()).getRecycledViewPool());
registerForContextMenu(recyclerView);
recyclerView.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
recyclerAdapter = new QueueRecyclerAdapter((MainActivity) getActivity(), swipeActions) {
@Override

View File

@ -17,7 +17,7 @@ import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -189,7 +189,7 @@ public class SearchFragment extends Fragment {
EventBus.getDefault().unregister(this);
}
private void setupToolbar(Toolbar toolbar) {
private void setupToolbar(MaterialToolbar toolbar) {
toolbar.setTitle(R.string.search_label);
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
toolbar.inflateMenu(R.menu.search);

View File

@ -17,7 +17,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -29,6 +29,7 @@ import com.leinardi.android.speeddial.SpeedDialView;
import de.danoeh.antennapod.dialog.TagSettingsDialog;
import de.danoeh.antennapod.ui.statistics.StatisticsFragment;
import de.danoeh.antennapod.view.LiftOnScrollListener;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
@ -69,7 +70,7 @@ import io.reactivex.schedulers.Schedulers;
* Fragment for displaying feed subscriptions
*/
public class SubscriptionFragment extends Fragment
implements Toolbar.OnMenuItemClickListener,
implements MaterialToolbar.OnMenuItemClickListener,
SubscriptionsRecyclerAdapter.OnSelectModeListener {
public static final String TAG = "SubscriptionFragment";
private static final String PREFS = "SubscriptionFragment";
@ -87,10 +88,9 @@ public class SubscriptionFragment extends Fragment
private RecyclerView subscriptionRecycler;
private SubscriptionsRecyclerAdapter subscriptionAdapter;
private FloatingActionButton subscriptionAddButton;
private EmptyViewHandler emptyView;
private TextView feedsFilteredMsg;
private Toolbar toolbar;
private MaterialToolbar toolbar;
private String displayedFolder = null;
private boolean displayUpArrow;
@ -152,6 +152,7 @@ public class SubscriptionFragment extends Fragment
setColumnNumber(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()));
subscriptionRecycler.addItemDecoration(new SubscriptionsRecyclerAdapter.GridDividerItemDecorator());
registerForContextMenu(subscriptionRecycler);
subscriptionRecycler.addOnScrollListener(new LiftOnScrollListener(root.findViewById(R.id.appbar)));
subscriptionAdapter = new SubscriptionsRecyclerAdapter((MainActivity) getActivity()) {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
@ -164,7 +165,7 @@ public class SubscriptionFragment extends Fragment
subscriptionRecycler.setAdapter(subscriptionAdapter);
setupEmptyView();
subscriptionAddButton = root.findViewById(R.id.subscriptions_add);
FloatingActionButton subscriptionAddButton = root.findViewById(R.id.subscriptions_add);
subscriptionAddButton.setOnClickListener(view -> {
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).loadChildFragment(new AddFeedFragment());

View File

@ -28,6 +28,7 @@ import de.danoeh.antennapod.ui.home.sections.EpisodesSurpriseSection;
import de.danoeh.antennapod.ui.home.sections.InboxSection;
import de.danoeh.antennapod.ui.home.sections.QueueSection;
import de.danoeh.antennapod.ui.home.sections.SubscriptionsSection;
import de.danoeh.antennapod.view.LiftOnScrollListener;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
@ -64,6 +65,7 @@ public class HomeFragment extends Fragment implements Toolbar.OnMenuItemClickLis
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
}
viewBinding.homeScrollView.setOnScrollChangeListener(new LiftOnScrollListener(viewBinding.appbar));
((MainActivity) requireActivity()).setupToolbarToggle(viewBinding.toolbar, displayUpArrow);
refreshToolbarState();
populateSectionList();

View File

@ -7,6 +7,7 @@ import android.widget.AbsListView;
import android.widget.FrameLayout;
import android.widget.ListAdapter;
import androidx.annotation.DrawableRes;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
@ -90,6 +91,13 @@ public class EmptyViewHandler {
layoutParams.gravity = Gravity.CENTER;
emptyView.setLayoutParams(layoutParams);
break;
} else if (parent instanceof CoordinatorLayout) {
parent.addView(emptyView);
CoordinatorLayout.LayoutParams layoutParams =
(CoordinatorLayout.LayoutParams) emptyView.getLayoutParams();
layoutParams.gravity = Gravity.CENTER;
emptyView.setLayoutParams(layoutParams);
break;
}
parent = (ViewGroup) parent.getParent();
}

View File

@ -0,0 +1,58 @@
package de.danoeh.antennapod.view;
import android.animation.ValueAnimator;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* Workaround for app:liftOnScroll flickering when in SwipeRefreshLayout
*/
public class LiftOnScrollListener extends RecyclerView.OnScrollListener
implements NestedScrollView.OnScrollChangeListener {
private final ValueAnimator animator;
private boolean animatingToScrolled = false;
public LiftOnScrollListener(View appBar) {
animator = ValueAnimator.ofFloat(0, appBar.getContext().getResources().getDisplayMetrics().density * 8);
animator.addUpdateListener(animation -> ViewCompat.setElevation(appBar, (float) animation.getAnimatedValue()));
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
elevate(isScrolled(recyclerView));
}
private boolean isScrolled(RecyclerView recyclerView) {
int firstItem = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
if (firstItem != 0) {
return true;
}
View firstItemView = recyclerView.getLayoutManager().findViewByPosition(firstItem);
if (firstItemView == null) {
return false;
} else {
return firstItemView.getTop() < 0;
}
}
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
elevate(scrollY != 0);
}
private void elevate(boolean isScrolled) {
if (isScrolled == animatingToScrolled) {
return;
}
animatingToScrolled = isScrolled;
if (isScrolled) {
animator.start();
} else {
animator.reverse();
}
}
}

View File

@ -5,7 +5,7 @@ import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.view.ContextThemeWrapper;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import de.danoeh.antennapod.R;
@ -13,10 +13,10 @@ import de.danoeh.antennapod.R;
public abstract class ToolbarIconTintManager implements AppBarLayout.OnOffsetChangedListener {
private final Context context;
private final CollapsingToolbarLayout collapsingToolbar;
private final Toolbar toolbar;
private final MaterialToolbar toolbar;
private boolean isTinted = false;
public ToolbarIconTintManager(Context context, Toolbar toolbar, CollapsingToolbarLayout collapsingToolbar) {
public ToolbarIconTintManager(Context context, MaterialToolbar toolbar, CollapsingToolbarLayout collapsingToolbar) {
this.context = context;
this.collapsingToolbar = collapsingToolbar;
this.toolbar = toolbar;

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -6,7 +6,7 @@
android:layout_height="match_parent"
android:minHeight="300dp">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -4,47 +4,45 @@
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:navigationIcon="?homeAsUpIndicator" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/txtvInformation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:layout_below="@id/toolbar"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:visibility="gone"
tools:text="(i) Information" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="?homeAsUpIndicator" />
<TextView
android:id="@+id/txtvInformation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:paddingBottom="8dp"
android:text="@string/filtered_label"
android:layout_marginTop="-12dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:visibility="gone"
tools:visibility="visible" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/txtvInformation">
android:layout_below="@id/appbar">
<de.danoeh.antennapod.view.EpisodeItemListRecyclerView
android:id="@android:id/list"
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:paddingTop="@dimen/list_vertical_padding"
android:paddingBottom="@dimen/list_vertical_padding"
android:paddingHorizontal="@dimen/additional_horizontal_spacing"
tools:itemCount="13"
tools:listitem="@layout/feeditemlist_item" />
android:paddingHorizontal="@dimen/additional_horizontal_spacing" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View File

@ -14,8 +14,6 @@
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground"
app:contentScrim="?android:attr/windowBackground"
app:scrimAnimationDuration="200"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
@ -33,12 +31,11 @@
layout="@layout/feeditemlist_header"
app:layout_collapseMode="parallax" />
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true"
app:navigationIcon="?homeAsUpIndicator"
app:layout_collapseMode="pin" />

View File

@ -34,7 +34,7 @@
layout="@layout/feeditemlist_header"
app:layout_collapseMode="parallax" />
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -6,7 +6,7 @@
android:layout_width="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"

View File

@ -5,7 +5,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"

View File

@ -13,7 +13,7 @@
android:orientation="horizontal"
android:layout_alignParentTop="true">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -4,38 +4,40 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true"
app:title="@string/subscriptions_label"
app:navigationIcon="?homeAsUpIndicator" />
android:layout_height="wrap_content">
<TextView
android:id="@+id/feeds_filtered_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:background="?android:attr/selectableItemBackground"
android:gravity="start"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/text_size_small" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="@string/subscriptions_label"
app:navigationIcon="?homeAsUpIndicator" />
<TextView
android:id="@+id/feeds_filtered_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="8dp"
android:text="@string/filtered_label"
android:layout_marginTop="-12dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:background="?android:attr/selectableItemBackground"
android:visibility="gone"
tools:visibility="visible" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/feeds_filtered_message">
android:layout_below="@id/appbar">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/subscriptions_grid"
@ -54,9 +56,9 @@
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_margin="16dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:contentDescription="@string/add_feed_label"
app:srcCompat="@drawable/ic_add" />

View File

@ -6,14 +6,20 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:title="@string/home_label"
app:navigationIcon="?homeAsUpIndicator" />
android:fitsSystemWindows="true"
android:elevation="0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="@string/home_label" />
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="@+id/welcomeContainer"
@ -60,6 +66,7 @@
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/homeScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">

View File

@ -6,40 +6,38 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true"
app:title="@string/queue_label"
app:navigationIcon="?homeAsUpIndicator" />
android:elevation="0dp">
<TextView
android:id="@+id/info_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:textSize="12sp"
android:layout_marginTop="-8dp"
android:layout_marginLeft="72dp"
android:layout_marginStart="72dp"
android:layout_marginBottom="4dp"
tools:text="12 Episodes - Time remaining: 12 hours" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="?homeAsUpIndicator"
app:title="@string/queue_label" />
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/info_bar"
android:background="?android:attr/listDivider" />
<TextView
android:id="@+id/info_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar"
android:textSize="12sp"
android:layout_marginTop="-12dp"
android:layout_marginLeft="60dp"
android:layout_marginStart="60dp"
android:layout_marginBottom="8dp"
tools:text="12 Episodes - Time remaining: 12 hours" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/divider">
android:layout_below="@id/appbar">
<de.danoeh.antennapod.view.EpisodeItemListRecyclerView
android:id="@+id/recyclerView"

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -1,35 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
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.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true"
app:navigationIcon="?homeAsUpIndicator" />
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:navigationIcon="?homeAsUpIndicator" />
</com.google.android.material.appbar.AppBarLayout>
<de.danoeh.antennapod.view.EpisodeItemListRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="@dimen/additional_horizontal_spacing"
android:layout_below="@id/toolbar" />
android:layout_below="@id/appbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<ProgressBar
android:id="@+id/progLoading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:indeterminateOnly="true"
android:visibility="gone" />
<include
layout="@layout/multi_select_speed_dial" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -20,7 +20,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -1,7 +1,7 @@
package de.danoeh.antennapod.ui.common;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;
@ -10,7 +10,7 @@ import androidx.viewpager2.widget.ViewPager2;
* All items share the same general menu items and are just allowed to show/hide them.
*/
public abstract class PagedToolbarFragment extends Fragment {
private Toolbar toolbar;
private MaterialToolbar toolbar;
private ViewPager2 viewPager;
/**
@ -24,7 +24,7 @@ public abstract class PagedToolbarFragment extends Fragment {
}
}
protected void setupPagedToolbar(Toolbar toolbar, ViewPager2 viewPager) {
protected void setupPagedToolbar(MaterialToolbar toolbar, ViewPager2 viewPager) {
this.toolbar = toolbar;
this.viewPager = viewPager;

View File

@ -1,31 +1,37 @@
<?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"
android:orientation="vertical">
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"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:navigationIcon="?homeAsUpIndicator"
android:id="@+id/toolbar"/>
android:layout_height="?attr/actionBarSize"
app:navigationIcon="?homeAsUpIndicator" />
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:tabBackground="?attr/selectableItemBackground"
app:tabMode="fixed"
app:tabGravity="fill"/>
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:tabBackground="?attr/selectableItemBackground"
app:tabMode="fixed"
app:tabGravity="fill" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -10,7 +10,7 @@ import android.view.ViewGroup;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
@ -48,7 +48,7 @@ public class StatisticsFragment extends PagedToolbarFragment {
private TabLayout tabLayout;
private ViewPager2 viewPager;
private Toolbar toolbar;
private MaterialToolbar toolbar;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,