Revert bottom app bar style.

This commit is contained in:
Docile-Alligator 2023-02-06 11:46:40 -05:00
parent d0bf1aa19c
commit e69f778de4
7 changed files with 194 additions and 140 deletions

View File

@ -80,7 +80,7 @@ dependencies {
implementation "androidx.room:room-guava:$roomVersion" implementation "androidx.room:room-guava:$roomVersion"
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
implementation 'androidx.work:work-runtime:2.7.1' implementation 'androidx.work:work-runtime:2.7.1'
implementation 'com.google.android.material:material:1.8.0-beta01' implementation 'com.google.android.material:material:1.8.0'
/** ExoPlayer **/ /** ExoPlayer **/
def exoplayerVersion = "2.18.2" def exoplayerVersion = "2.18.2"

View File

@ -5,7 +5,6 @@ import static androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
@ -15,6 +14,7 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
@ -23,8 +23,6 @@ import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.Toast; import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
@ -33,10 +31,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.drawerlayout.widget.DrawerLayout; import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@ -54,7 +54,6 @@ import androidx.work.WorkManager;
import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.appbar.MaterialToolbar; 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.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
@ -255,7 +254,9 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), 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),
findViewById(R.id.fab_main_activity), findViewById(R.id.fab_main_activity),
findViewById(R.id.navigation_rail), showBottomAppBar); findViewById(R.id.navigation_rail), showBottomAppBar);
@ -284,13 +285,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (navBarHeight > 0) { if (navBarHeight > 0) {
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams();
params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); params.bottomMargin += navBarHeight;
navigationWrapper.floatingActionButton.setLayoutParams(params); navigationWrapper.floatingActionButton.setLayoutParams(params);
} }
if (navigationWrapper.bottomAppBar != null) { if (navigationWrapper.bottomAppBar != null) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.bottomAppBar.getLayoutParams(); navigationWrapper.linearLayoutBottomAppBar.setPadding(navigationWrapper.linearLayoutBottomAppBar.getPaddingLeft(),
params.bottomMargin += navBarHeight; navigationWrapper.linearLayoutBottomAppBar.getPaddingTop(), navigationWrapper.linearLayoutBottomAppBar.getPaddingRight(), navBarHeight);
navigationWrapper.bottomAppBar.setLayoutParams(params);
} }
navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight); navDrawerRecyclerView.setPadding(0, 0, 0, navBarHeight);
} }
@ -591,16 +591,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2);
return true;
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {
@ -624,22 +620,20 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
getBottomAppBarOptionDrawableResource(option4)); getBottomAppBarOptionDrawableResource(option4));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option1BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2); });
return true;
} else if (itemId == R.id.bottom_app_bar_option_3) { navigationWrapper.option3BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option3); bottomAppBarOptionAction(option3);
return true; });
} else if (itemId == R.id.bottom_app_bar_option_4) {
bottomAppBarOptionAction(option4); navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
return true; bottomAppBarOptionAction(option4);
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {

View File

@ -161,7 +161,9 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), 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),
findViewById(R.id.fab_view_multi_reddit_detail_activity), findViewById(R.id.fab_view_multi_reddit_detail_activity),
findViewById(R.id.navigation_rail), showBottomAppBar); findViewById(R.id.navigation_rail), showBottomAppBar);
@ -190,7 +192,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
if (navBarHeight > 0) { if (navBarHeight > 0) {
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams();
params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); params.bottomMargin += navBarHeight;
navigationWrapper.floatingActionButton.setLayoutParams(params); navigationWrapper.floatingActionButton.setLayoutParams(params);
} }
} }
@ -238,16 +240,12 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2);
return true;
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {
@ -271,22 +269,20 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
getBottomAppBarOptionDrawableResource(option4)); getBottomAppBarOptionDrawableResource(option4));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option1BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2); });
return true;
} else if (itemId == R.id.bottom_app_bar_option_3) { navigationWrapper.option3BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option3); bottomAppBarOptionAction(option3);
return true; });
} else if (itemId == R.id.bottom_app_bar_option_4) {
bottomAppBarOptionAction(option4); navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
return true; bottomAppBarOptionAction(option4);
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {

View File

@ -241,7 +241,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), 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),
findViewById(R.id.fab_view_subreddit_detail_activity), findViewById(R.id.fab_view_subreddit_detail_activity),
findViewById(R.id.navigation_rail), showBottomAppBar); findViewById(R.id.navigation_rail), showBottomAppBar);
@ -268,7 +270,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (navBarHeight > 0) { if (navBarHeight > 0) {
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams();
params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); params.bottomMargin += navBarHeight;
navigationWrapper.floatingActionButton.setLayoutParams(params); navigationWrapper.floatingActionButton.setLayoutParams(params);
} }
} }
@ -759,16 +761,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2);
return true;
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {
@ -792,22 +790,20 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
getBottomAppBarOptionDrawableResource(option4)); getBottomAppBarOptionDrawableResource(option4));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option1BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2); });
return true;
} else if (itemId == R.id.bottom_app_bar_option_3) { navigationWrapper.option3BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option3); bottomAppBarOptionAction(option3);
return true; });
} else if (itemId == R.id.bottom_app_bar_option_4) {
bottomAppBarOptionAction(option4); navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
return true; bottomAppBarOptionAction(option4);
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {

View File

@ -244,7 +244,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false); hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false); showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), 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),
findViewById(R.id.fab_view_user_detail_activity), findViewById(R.id.fab_view_user_detail_activity),
findViewById(R.id.navigation_rail), showBottomAppBar); findViewById(R.id.navigation_rail), showBottomAppBar);
@ -305,7 +307,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (navBarHeight > 0) { if (navBarHeight > 0) {
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) navigationWrapper.floatingActionButton.getLayoutParams();
params.bottomMargin += (int) (navBarHeight - Utils.convertDpToPixel(4, this)); params.bottomMargin += navBarHeight;
navigationWrapper.floatingActionButton.setLayoutParams(params); navigationWrapper.floatingActionButton.setLayoutParams(params);
} }
} }
@ -724,16 +726,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2)); navigationWrapper.bindOptionDrawableResource(getBottomAppBarOptionDrawableResource(option1), getBottomAppBarOptionDrawableResource(option2));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2);
return true;
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {
@ -757,22 +755,20 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
getBottomAppBarOptionDrawableResource(option4)); getBottomAppBarOptionDrawableResource(option4));
if (navigationWrapper.navigationRailView == null) { if (navigationWrapper.navigationRailView == null) {
navigationWrapper.bottomAppBar.setOnMenuItemClickListener(item -> { navigationWrapper.option1BottomAppBar.setOnClickListener(view -> {
int itemId = item.getItemId(); bottomAppBarOptionAction(option1);
if (itemId == R.id.bottom_app_bar_option_1) { });
bottomAppBarOptionAction(option1);
return true; navigationWrapper.option2BottomAppBar.setOnClickListener(view -> {
} else if (itemId == R.id.bottom_app_bar_option_2) { bottomAppBarOptionAction(option2);
bottomAppBarOptionAction(option2); });
return true;
} else if (itemId == R.id.bottom_app_bar_option_3) { navigationWrapper.option3BottomAppBar.setOnClickListener(view -> {
bottomAppBarOptionAction(option3); bottomAppBarOptionAction(option3);
return true; });
} else if (itemId == R.id.bottom_app_bar_option_4) {
bottomAppBarOptionAction(option4); navigationWrapper.option4BottomAppBar.setOnClickListener(view -> {
return true; bottomAppBarOptionAction(option4);
}
return false;
}); });
} else { } else {
navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> { navigationWrapper.navigationRailView.setOnItemSelectedListener(item -> {

View File

@ -5,6 +5,8 @@ import android.content.res.ColorStateList;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.appcompat.view.menu.MenuItemImpl; import androidx.appcompat.view.menu.MenuItemImpl;
import androidx.core.view.MenuItemCompat; import androidx.core.view.MenuItemCompat;
@ -17,13 +19,26 @@ import ml.docilealligator.infinityforreddit.R;
public class NavigationWrapper { public class NavigationWrapper {
public BottomAppBar bottomAppBar; public BottomAppBar bottomAppBar;
public LinearLayout linearLayoutBottomAppBar;
public ImageView option1BottomAppBar;
public ImageView option2BottomAppBar;
public ImageView option3BottomAppBar;
public ImageView option4BottomAppBar;
public NavigationRailView navigationRailView; public NavigationRailView navigationRailView;
public FloatingActionButton floatingActionButton; public FloatingActionButton floatingActionButton;
public NavigationWrapper(BottomAppBar bottomAppBar, FloatingActionButton floatingActionButton, public NavigationWrapper(BottomAppBar bottomAppBar, LinearLayout linearLayoutBottomAppBar,
NavigationRailView navigationRailView, boolean showBottomAppBar) { ImageView option1BottomAppBar, ImageView option2BottomAppBar,
ImageView option3BottomAppBar, ImageView option4BottomAppBar,
FloatingActionButton floatingActionButton, NavigationRailView navigationRailView,
boolean showBottomAppBar) {
this.bottomAppBar = bottomAppBar; this.bottomAppBar = bottomAppBar;
this.linearLayoutBottomAppBar = linearLayoutBottomAppBar;
this.option1BottomAppBar = option1BottomAppBar;
this.option2BottomAppBar = option2BottomAppBar;
this.option3BottomAppBar = option3BottomAppBar;
this.option4BottomAppBar = option4BottomAppBar;
this.navigationRailView = navigationRailView; this.navigationRailView = navigationRailView;
if (navigationRailView != null) { if (navigationRailView != null) {
if (showBottomAppBar) { if (showBottomAppBar) {
@ -39,8 +54,11 @@ public class NavigationWrapper {
public void applyCustomTheme(int bottomAppBarIconColor, int bottomAppBarBackgroundColor) { public void applyCustomTheme(int bottomAppBarIconColor, int bottomAppBarBackgroundColor) {
if (navigationRailView == null) { 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)); bottomAppBar.setBackgroundTint(ColorStateList.valueOf(bottomAppBarBackgroundColor));
applyMenuItemTheme(bottomAppBar.getMenu(), bottomAppBarIconColor);
} else { } else {
navigationRailView.setBackgroundColor(bottomAppBarBackgroundColor); navigationRailView.setBackgroundColor(bottomAppBarBackgroundColor);
applyMenuItemTheme(navigationRailView.getMenu(), bottomAppBarIconColor); applyMenuItemTheme(navigationRailView.getMenu(), bottomAppBarIconColor);
@ -66,11 +84,12 @@ public class NavigationWrapper {
if (imageResources.length == 2) { if (imageResources.length == 2) {
if (navigationRailView == null) { if (navigationRailView == null) {
Menu menu = bottomAppBar.getMenu(); linearLayoutBottomAppBar.setWeightSum(3);
menu.findItem(R.id.bottom_app_bar_option_1).setIcon(imageResources[0]); option1BottomAppBar.setVisibility(View.GONE);
menu.findItem(R.id.bottom_app_bar_option_2).setIcon(imageResources[1]); option3BottomAppBar.setVisibility(View.GONE);
menu.findItem(R.id.bottom_app_bar_option_3).setVisible(false);
menu.findItem(R.id.bottom_app_bar_option_4).setVisible(false); option2BottomAppBar.setImageResource(imageResources[0]);
option4BottomAppBar.setImageResource(imageResources[1]);
} else { } else {
Menu menu = navigationRailView.getMenu(); Menu menu = navigationRailView.getMenu();
menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]); menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]);
@ -80,11 +99,10 @@ public class NavigationWrapper {
} }
} else { } else {
if (navigationRailView == null) { if (navigationRailView == null) {
Menu menu = bottomAppBar.getMenu(); option1BottomAppBar.setImageResource(imageResources[0]);
menu.findItem(R.id.bottom_app_bar_option_1).setIcon(imageResources[0]); option2BottomAppBar.setImageResource(imageResources[1]);
menu.findItem(R.id.bottom_app_bar_option_2).setIcon(imageResources[1]); option3BottomAppBar.setImageResource(imageResources[2]);
menu.findItem(R.id.bottom_app_bar_option_3).setIcon(imageResources[2]); option4BottomAppBar.setImageResource(imageResources[3]);
menu.findItem(R.id.bottom_app_bar_option_4).setIcon(imageResources[3]);
} else { } else {
Menu menu = navigationRailView.getMenu(); Menu menu = navigationRailView.getMenu();
menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]); menu.findItem(R.id.navigation_rail_option_1).setIcon(imageResources[0]);

View File

@ -3,10 +3,64 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bottom_app_bar_bottom_app_bar" android:id="@+id/bottom_app_bar_bottom_app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="48dp"
android:layout_gravity="bottom"
android:visibility="gone" android:visibility="gone"
style="@style/Widget.Material3.BottomAppBar" app:fabAlignmentMode="center">
app:hideOnScroll="true"
app:fabAlignmentMode="end" <LinearLayout
app:menu="@menu/bottom_app_bar" /> android:id="@+id/linear_layout_bottom_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:layout_marginEnd="8dp"
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:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center"
android:background="?attr/selectableItemBackgroundBorderless" />
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>