From 8a6eb8e025f388c9bc23e5ef30a0991eb33b7365 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 28 Dec 2022 17:25:48 -0800 Subject: Change the style of the bottom app bar. --- .../infinityforreddit/activities/BaseActivity.java | 2 +- .../infinityforreddit/activities/MainActivity.java | 64 ++++++++++++---------- .../activities/ViewMultiRedditDetailActivity.java | 52 ++++++++++-------- .../activities/ViewSubredditDetailActivity.java | 53 +++++++++--------- .../activities/ViewUserDetailActivity.java | 52 ++++++++++-------- .../customviews/NavigationWrapper.java | 44 +++++---------- 6 files changed, 133 insertions(+), 134 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java index 02c20b77..bd94a89e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/BaseActivity.java @@ -363,7 +363,7 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo } protected void applyFABTheme(FloatingActionButton fab) { - fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorPrimaryLightTheme())); + fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent())); fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor())); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 4c8c893b..7ae7d87e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -15,7 +15,6 @@ import android.os.Bundle; import android.os.Handler; import android.text.Editable; import android.text.TextWatcher; -import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.Menu; @@ -25,15 +24,16 @@ import android.view.Window; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.widget.LinearLayout; import android.widget.Toast; -import androidx.activity.result.ActivityResultCallback; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatDelegate; +import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -54,6 +54,7 @@ import androidx.work.WorkManager; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.MaterialToolbar; +import com.google.android.material.bottomappbar.BottomAppBar; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.navigation.NavigationView; import com.google.android.material.tabs.TabLayout; @@ -254,9 +255,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); - navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), - findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar), - findViewById(R.id.option_3_bottom_app_bar), findViewById(R.id.option_4_bottom_app_bar), + navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.fab_main_activity), findViewById(R.id.navigation_rail), showBottomAppBar); @@ -285,12 +284,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb if (navBarHeight > 0) { if (navigationWrapper.navigationRailView == null) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); - params.bottomMargin += navBarHeight; + params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); navigationWrapper.floatingActionButton.setLayoutParams(params); } - if (navigationWrapper.linearLayoutBottomAppBar != null) { - navigationWrapper.linearLayoutBottomAppBar.setPadding(0, - navigationWrapper.linearLayoutBottomAppBar.getPaddingTop(), 0, navBarHeight); + if (navigationWrapper.bottomAppBar != null) { + CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.bottomAppBar.getLayoutParams(); + params.bottomMargin += navBarHeight; + navigationWrapper.bottomAppBar.setLayoutParams(params); } navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight); } @@ -591,12 +591,16 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { @@ -620,20 +624,22 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb getBottomAppBarOptionDrawableResource(option4)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option1BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); - }); - - navigationWrapper.option3BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option3); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option4); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } else if (itemId == R.id.bottom_app_bar_option_3) { + bottomAppBarOptionAction(option3); + return true; + } else if (itemId == R.id.bottom_app_bar_option_4) { + bottomAppBarOptionAction(option4); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index 97d72408..b59e9f27 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -163,9 +163,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); - navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), - findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar), - findViewById(R.id.option_3_bottom_app_bar), findViewById(R.id.option_4_bottom_app_bar), + navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.fab_view_multi_reddit_detail_activity), findViewById(R.id.navigation_rail), showBottomAppBar); @@ -194,7 +192,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT if (navBarHeight > 0) { if (navigationWrapper.navigationRailView == null) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); - params.bottomMargin += navBarHeight; + params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); navigationWrapper.floatingActionButton.setLayoutParams(params); } } @@ -242,12 +240,16 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { @@ -271,20 +273,22 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT getBottomAppBarOptionDrawableResource(option4)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option1BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); - }); - - navigationWrapper.option3BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option3); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option4); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } else if (itemId == R.id.bottom_app_bar_option_3) { + bottomAppBarOptionAction(option3); + return true; + } else if (itemId == R.id.bottom_app_bar_option_4) { + bottomAppBarOptionAction(option4); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 0a9b837b..0cf5bbf3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -241,9 +241,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); - navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), - findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar), - findViewById(R.id.option_3_bottom_app_bar), findViewById(R.id.option_4_bottom_app_bar), + navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.fab_view_subreddit_detail_activity), findViewById(R.id.navigation_rail), showBottomAppBar); @@ -270,7 +268,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp if (navBarHeight > 0) { if (navigationWrapper.navigationRailView == null) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); - params.bottomMargin += navBarHeight; + params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); navigationWrapper.floatingActionButton.setLayoutParams(params); } } @@ -761,12 +759,16 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { @@ -790,21 +792,22 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp getBottomAppBarOptionDrawableResource(option4)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option1BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - //Toast.makeText(this, "s " + collapsingToolbarLayout.getScrimVisibleHeightTrigger(), Toast.LENGTH_SHORT).show(); - }); - - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); - }); - - navigationWrapper.option3BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option3); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option4); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } else if (itemId == R.id.bottom_app_bar_option_3) { + bottomAppBarOptionAction(option3); + return true; + } else if (itemId == R.id.bottom_app_bar_option_4) { + bottomAppBarOptionAction(option4); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index 5e4626ba..72ad5960 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -243,9 +243,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); - navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar), - findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar), - findViewById(R.id.option_3_bottom_app_bar), findViewById(R.id.option_4_bottom_app_bar), + navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.fab_view_user_detail_activity), findViewById(R.id.navigation_rail), showBottomAppBar); @@ -306,7 +304,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele if (navBarHeight > 0) { if (navigationWrapper.navigationRailView == null) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); - params.bottomMargin += navBarHeight; + params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); navigationWrapper.floatingActionButton.setLayoutParams(params); } } @@ -725,12 +723,16 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { @@ -754,20 +756,22 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele getBottomAppBarOptionDrawableResource(option4)); if (navigationWrapper.navigationRailView == null) { - navigationWrapper.option1BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option1); - }); - - navigationWrapper.option2BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option2); - }); - - navigationWrapper.option3BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option3); - }); - - navigationWrapper.option4BottomAppBar.setOnClickListener(view -> { - bottomAppBarOptionAction(option4); + navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.bottom_app_bar_option_1) { + bottomAppBarOptionAction(option1); + return true; + } else if (itemId == R.id.bottom_app_bar_option_2) { + bottomAppBarOptionAction(option2); + return true; + } else if (itemId == R.id.bottom_app_bar_option_3) { + bottomAppBarOptionAction(option3); + return true; + } else if (itemId == R.id.bottom_app_bar_option_4) { + bottomAppBarOptionAction(option4); + return true; + } + return false; }); } else { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java index 1d702c19..ff082f45 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/NavigationWrapper.java @@ -5,8 +5,6 @@ import android.content.res.ColorStateList; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; import androidx.appcompat.view.menu.MenuItemImpl; import androidx.core.view.MenuItemCompat; @@ -19,26 +17,13 @@ import ml.docilealligator.infinityforreddit.R; public class NavigationWrapper { public BottomAppBar bottomAppBar; - public LinearLayout linearLayoutBottomAppBar; - public ImageView option1BottomAppBar; - public ImageView option2BottomAppBar; - public ImageView option3BottomAppBar; - public ImageView option4BottomAppBar; public NavigationRailView navigationRailView; public FloatingActionButton floatingActionButton; - public NavigationWrapper(BottomAppBar bottomAppBar, LinearLayout linearLayoutBottomAppBar, - ImageView option1BottomAppBar, ImageView option2BottomAppBar, - ImageView option3BottomAppBar, ImageView option4BottomAppBar, - FloatingActionButton floatingActionButton, NavigationRailView navigationRailView, - boolean showBottomAppBar) { + public NavigationWrapper(BottomAppBar bottomAppBar, FloatingActionButton floatingActionButton, + NavigationRailView navigationRailView, boolean showBottomAppBar) { this.bottomAppBar = bottomAppBar; - this.linearLayoutBottomAppBar = linearLayoutBottomAppBar; - this.option1BottomAppBar = option1BottomAppBar; - this.option2BottomAppBar = option2BottomAppBar; - this.option3BottomAppBar = option3BottomAppBar; - this.option4BottomAppBar = option4BottomAppBar; this.navigationRailView = navigationRailView; if (navigationRailView != null) { if (showBottomAppBar) { @@ -54,11 +39,8 @@ public class NavigationWrapper { public void applyCustomTheme(int bottomAppBarIconColor, int bottomAppBarBackgroundColor) { if (navigationRailView == null) { - option1BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - option2BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - option3BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); - option4BottomAppBar.setColorFilter(bottomAppBarIconColor, android.graphics.PorterDuff.Mode.SRC_IN); bottomAppBar.setBackgroundTint(ColorStateList.valueOf(bottomAppBarBackgroundColor)); + applyMenuItemTheme(bottomAppBar.getMenu(), bottomAppBarIconColor); } else { navigationRailView.setBackgroundColor(bottomAppBarBackgroundColor); applyMenuItemTheme(navigationRailView.getMenu(), bottomAppBarIconColor); @@ -84,12 +66,11 @@ public class NavigationWrapper { if (imageResources.length == 2) { if (navigationRailView == null) { - linearLayoutBottomAppBar.setWeightSum(3); - option1BottomAppBar.setVisibility(View.GONE); - option3BottomAppBar.setVisibility(View.GONE); - - option2BottomAppBar.setImageResource(imageResources[0]); - option4BottomAppBar.setImageResource(imageResources[1]); + Menu menu = bottomAppBar.getMenu(); + menu.findItem(R.id.bottom_app_bar_option_1).setIcon(imageResources[0]); + menu.findItem(R.id.bottom_app_bar_option_2).setIcon(imageResources[1]); + menu.findItem(R.id.bottom_app_bar_option_3).setVisible(false); + menu.findItem(R.id.bottom_app_bar_option_4).setVisible(false); } else { Menu menu = navigationRailView.getMenu(); menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]); @@ -99,10 +80,11 @@ public class NavigationWrapper { } } else { if (navigationRailView == null) { - option1BottomAppBar.setImageResource(imageResources[0]); - option2BottomAppBar.setImageResource(imageResources[1]); - option3BottomAppBar.setImageResource(imageResources[2]); - option4BottomAppBar.setImageResource(imageResources[3]); + Menu menu = bottomAppBar.getMenu(); + menu.findItem(R.id.bottom_app_bar_option_1).setIcon(imageResources[0]); + menu.findItem(R.id.bottom_app_bar_option_2).setIcon(imageResources[1]); + menu.findItem(R.id.bottom_app_bar_option_3).setIcon(imageResources[2]); + menu.findItem(R.id.bottom_app_bar_option_4).setIcon(imageResources[3]); } else { Menu menu = navigationRailView.getMenu(); menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]); -- cgit v1.2.3