diff options
Diffstat (limited to 'app/src/main')
8 files changed, 159 insertions, 194 deletions
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]); diff --git a/app/src/main/res/layout/bottom_app_bar.xml b/app/src/main/res/layout/bottom_app_bar.xml index 47a35792..7e55c2ba 100644 --- a/app/src/main/res/layout/bottom_app_bar.xml +++ b/app/src/main/res/layout/bottom_app_bar.xml @@ -3,64 +3,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/bottom_app_bar_bottom_app_bar" android:layout_width="match_parent" - android:layout_height="48dp" + android:layout_height="wrap_content" + android:layout_gravity="bottom" android:visibility="gone" - app:fabAlignmentMode="center"> - - <LinearLayout - android:id="@+id/linear_layout_bottom_app_bar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="6dp" - android:weightSum="5"> - - <ImageView - android:id="@+id/option_1_bottom_app_bar" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:paddingTop="8dp" - android:paddingBottom="8dp" - android:background="?attr/selectableItemBackgroundBorderless" /> - - <ImageView - android:id="@+id/option_2_bottom_app_bar" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:paddingTop="8dp" - android:paddingBottom="8dp" - android:background="?attr/selectableItemBackgroundBorderless" /> - - <TextView - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:background="@android:color/transparent"/> - - <ImageView - android:id="@+id/option_3_bottom_app_bar" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:paddingTop="8dp" - android:paddingBottom="8dp" - android:background="?attr/selectableItemBackgroundBorderless" /> - - <ImageView - android:id="@+id/option_4_bottom_app_bar" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_marginEnd="16dp" - android:paddingTop="8dp" - android:paddingBottom="8dp" - android:gravity="center" - android:background="?attr/selectableItemBackgroundBorderless" /> - - </LinearLayout> - -</com.google.android.material.bottomappbar.BottomAppBar>
\ No newline at end of file + style="@style/Widget.Material3.BottomAppBar" + app:hideOnScroll="true" + app:fabAlignmentMode="end" + app:menu="@menu/bottom_app_bar" />
\ No newline at end of file diff --git a/app/src/main/res/menu/bottom_app_bar.xml b/app/src/main/res/menu/bottom_app_bar.xml new file mode 100644 index 00000000..c98673c3 --- /dev/null +++ b/app/src/main/res/menu/bottom_app_bar.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + <item + android:id="@+id/bottom_app_bar_option_1" + android:enabled="true" + app:showAsAction="always" /> + <item + android:id="@+id/bottom_app_bar_option_2" + android:enabled="true" + app:showAsAction="always" /> + <item + android:id="@+id/bottom_app_bar_option_3" + android:enabled="true" + app:showAsAction="always" /> + <item + android:id="@+id/bottom_app_bar_option_4" + android:enabled="true" + app:showAsAction="always" /> +</menu>
\ No newline at end of file |