From 5097919a3616b4dab44cc36e24fe8b08d7daf8dc Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 18 Dec 2019 18:35:58 +0800 Subject: Add a BottomAppBar to navigate to subscriptions and multireddits. --- .../infinityforreddit/Activity/MainActivity.java | 57 +++++++++------------ .../res/drawable-hdpi/baseline_add_white_24.png | Bin 138 -> 0 bytes .../res/drawable-mdpi/baseline_add_white_24.png | Bin 92 -> 0 bytes .../drawable-night/ic_add_bottom_app_bar_24dp.xml | 9 ++++ ...ne_check_circle_outline_bottom_app_bar_24dp.xml | 9 ++++ .../res/drawable-xhdpi/baseline_add_white_24.png | Bin 97 -> 0 bytes .../res/drawable-xxhdpi/baseline_add_white_24.png | Bin 97 -> 0 bytes .../res/drawable-xxxhdpi/baseline_add_white_24.png | Bin 102 -> 0 bytes app/src/main/res/drawable/ic_add_24dp.xml | 9 ++++ .../res/drawable/ic_add_bottom_app_bar_24dp.xml | 9 ++++ ...ne_check_circle_outline_bottom_app_bar_24dp.xml | 9 ++++ .../ic_outline_check_circle_outline_white_24px.xml | 9 ---- .../res/layout/activity_view_subreddit_detail.xml | 2 +- app/src/main/res/layout/app_bar_main.xml | 57 +++++++++++++++++++-- app/src/main/res/layout/item_subreddit_listing.xml | 2 +- app/src/main/res/layout/item_user_listing.xml | 2 +- app/src/main/res/menu/main_activity.xml | 17 ++---- 17 files changed, 130 insertions(+), 61 deletions(-) delete mode 100755 app/src/main/res/drawable-hdpi/baseline_add_white_24.png delete mode 100755 app/src/main/res/drawable-mdpi/baseline_add_white_24.png create mode 100644 app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml create mode 100644 app/src/main/res/drawable-night/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml delete mode 100755 app/src/main/res/drawable-xhdpi/baseline_add_white_24.png delete mode 100755 app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png delete mode 100755 app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png create mode 100644 app/src/main/res/drawable/ic_add_24dp.xml create mode 100644 app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml create mode 100644 app/src/main/res/drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml (limited to 'app/src/main') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java index 6b592d72..d8021fce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java @@ -45,6 +45,7 @@ import com.bumptech.glide.RequestManager; import com.bumptech.glide.request.RequestOptions; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.tabs.TabLayout; @@ -162,6 +163,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb TabLayout tabLayout; @BindView(R.id.fab_main_activity) FloatingActionButton fab; + @BindView(R.id.bottom_navigation_main_activity) + BottomAppBar bottomNavigationView; + @BindView(R.id.subscriptions_bottom_app_bar_main_activity) + TextView subscriptionsBottomAppBar; + @BindView(R.id.multi_reddit_bottom_app_bar_main_activity) + TextView multiRedditBottomAppBar; AccountViewModel accountViewModel; @Inject @Named("oauth") @@ -353,20 +360,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb mNewAccountName = null; if (newAccount == null) { mNullAccessToken = true; - - if (mMenu != null) { - mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false); - } } else { mAccessToken = newAccount.getAccessToken(); mAccountName = newAccount.getUsername(); mProfileImageUrl = newAccount.getProfileImageUrl(); mBannerImageUrl = newAccount.getBannerImageUrl(); mKarma = newAccount.getKarma(); - - if (mMenu != null) { - mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); - } } if (enableNotification) { @@ -395,10 +394,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb mBannerImageUrl = account.getBannerImageUrl(); mKarma = account.getKarma(); - if (mMenu != null) { - mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); - } - if (enableNotification) { Constraints constraints = new Constraints.Builder() .setRequiredNetworkType(NetworkType.CONNECTED) @@ -421,20 +416,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } else { if (account == null) { mNullAccessToken = true; - - if (mMenu != null) { - mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(false); - } } else { mAccessToken = account.getAccessToken(); mAccountName = account.getUsername(); mProfileImageUrl = account.getProfileImageUrl(); mBannerImageUrl = account.getBannerImageUrl(); mKarma = account.getKarma(); - - if (mMenu != null) { - mMenu.findItem(R.id.action_subscriptions_main_activity).setVisible(true); - } } if (enableNotification) { @@ -464,6 +451,21 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb return; } + if (mAccessToken == null) { + bottomNavigationView.setVisibility(View.GONE); + } else { + bottomNavigationView.setVisibility(View.VISIBLE); + subscriptionsBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class); + startActivity(intent); + }); + + multiRedditBottomAppBar.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, MultiRedditListingActivity.class); + startActivity(intent); + }); + } + sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOffscreenPageLimit(3); @@ -783,13 +785,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb getMenuInflater().inflate(R.menu.main_activity, menu); mMenu = menu; MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity); - MenuItem subscriptionsItem = mMenu.findItem(R.id.action_subscriptions_main_activity); - - if (mAccessToken != null) { - subscriptionsItem.setVisible(true); - } else { - subscriptionsItem.setVisible(false); - } if (isInLazyMode) { lazyModeItem.setTitle(R.string.action_stop_lazy_mode); @@ -807,12 +802,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { - case R.id.action_subscriptions_main_activity: - /*Intent subscriptionsIntent = new Intent(this, SubscribedThingListingActivity.class); - startActivity(subscriptionsIntent);*/ - Intent multiIntent = new Intent(this, MultiRedditListingActivity.class); - startActivity(multiIntent); - return true; case R.id.action_sort_main_activity: if (viewPager.getCurrentItem() == 1 || viewPager.getCurrentItem() == 2) { popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag()); @@ -935,11 +924,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } public void postScrollUp() { + bottomNavigationView.performShow(); fab.show(); } public void postScrollDown() { fab.hide(); + bottomNavigationView.performHide(); } @Subscribe diff --git a/app/src/main/res/drawable-hdpi/baseline_add_white_24.png b/app/src/main/res/drawable-hdpi/baseline_add_white_24.png deleted file mode 100755 index ea78104d..00000000 Binary files a/app/src/main/res/drawable-hdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/baseline_add_white_24.png b/app/src/main/res/drawable-mdpi/baseline_add_white_24.png deleted file mode 100755 index eeba9f66..00000000 Binary files a/app/src/main/res/drawable-mdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml b/app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml new file mode 100644 index 00000000..b6814bc2 --- /dev/null +++ b/app/src/main/res/drawable-night/ic_add_bottom_app_bar_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-night/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml b/app/src/main/res/drawable-night/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml new file mode 100644 index 00000000..191a8e4c --- /dev/null +++ b/app/src/main/res/drawable-night/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png deleted file mode 100755 index 67bb598e..00000000 Binary files a/app/src/main/res/drawable-xhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png deleted file mode 100755 index 0fdced8f..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png b/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png deleted file mode 100755 index d64c22e9..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/baseline_add_white_24.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_add_24dp.xml b/app/src/main/res/drawable/ic_add_24dp.xml new file mode 100644 index 00000000..ed95d188 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml b/app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml new file mode 100644 index 00000000..a032b560 --- /dev/null +++ b/app/src/main/res/drawable/ic_add_bottom_app_bar_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml b/app/src/main/res/drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml new file mode 100644 index 00000000..e518509a --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_check_circle_outline_bottom_app_bar_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml b/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml deleted file mode 100644 index 191a8e4c..00000000 --- a/app/src/main/res/drawable/ic_outline_check_circle_outline_white_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_view_subreddit_detail.xml b/app/src/main/res/layout/activity_view_subreddit_detail.xml index faa42a70..fffa6a96 100644 --- a/app/src/main/res/layout/activity_view_subreddit_detail.xml +++ b/app/src/main/res/layout/activity_view_subreddit_detail.xml @@ -132,6 +132,6 @@ android:layout_margin="@dimen/fab_margin" app:backgroundTint="@color/backgroundColorPrimary" app:tint="@android:color/white" - app:srcCompat="@drawable/baseline_add_white_24" /> + app:srcCompat="@drawable/ic_add_24dp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index c7993b14..1fcb0353 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -56,14 +56,63 @@ android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> + + + + + + + + + + + + + + app:backgroundTint="?attr/backgroundColor" + app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp" + app:tint="@null" + app:layout_anchor="@id/bottom_navigation_main_activity" /> diff --git a/app/src/main/res/layout/item_subreddit_listing.xml b/app/src/main/res/layout/item_subreddit_listing.xml index f710ca43..68157c95 100644 --- a/app/src/main/res/layout/item_subreddit_listing.xml +++ b/app/src/main/res/layout/item_subreddit_listing.xml @@ -35,7 +35,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:src="@drawable/baseline_add_white_24" + android:src="@drawable/ic_add_24dp" android:tint="@color/colorPrimaryDarkDayNightTheme" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/layout/item_user_listing.xml b/app/src/main/res/layout/item_user_listing.xml index 6ecb1ab7..a69b6a37 100644 --- a/app/src/main/res/layout/item_user_listing.xml +++ b/app/src/main/res/layout/item_user_listing.xml @@ -35,7 +35,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:src="@drawable/baseline_add_white_24" + android:src="@drawable/ic_add_24dp" android:tint="@color/colorPrimaryDarkDayNightTheme" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/menu/main_activity.xml b/app/src/main/res/menu/main_activity.xml index cfc38eff..b500d3a7 100644 --- a/app/src/main/res/menu/main_activity.xml +++ b/app/src/main/res/menu/main_activity.xml @@ -3,43 +3,36 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:application="ml.docilealligator.infinityforreddit.Activity.MainActivity"> - \ No newline at end of file -- cgit v1.2.3