From d2258a2aa96ed944e2b615454085056e0008e6c6 Mon Sep 17 00:00:00 2001 From: Kira Roubin Date: Sat, 6 Jan 2024 14:52:21 +0300 Subject: [PATCH] feat: Ability to hide bottom bar --- app/src/main/java/moe/kirao/mgx/MoexConfig.java | 6 ++++++ .../moe/kirao/mgx/ui/ChatsSettingsMoexController.java | 3 +++ .../moe/kirao/mgx/ui/GeneralSettingsMoexController.java | 7 +++++-- .../kirao/mgx/ui/InterfaceSettingsMoexController.java | 7 +++++++ .../org/thunderdog/challegram/ui/MessagesController.java | 9 ++++++--- app/src/main/res/values/moex_ids.xml | 1 + app/src/main/res/values/moex_strings.xml | 3 +++ 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/moe/kirao/mgx/MoexConfig.java b/app/src/main/java/moe/kirao/mgx/MoexConfig.java index 3f1b1c3a1a..afc168e12e 100644 --- a/app/src/main/java/moe/kirao/mgx/MoexConfig.java +++ b/app/src/main/java/moe/kirao/mgx/MoexConfig.java @@ -47,6 +47,7 @@ public class MoexConfig { public static final String KEY_CHANGE_HEADER_TEXT = "change_header_text"; public static final String KEY_TYPING_INSTEAD_CHOOSING = "typing_instead_choosing"; public static final String KEY_DISABLE_REACTIONS = "disable_reactions"; + public static final String KEY_HIDE_BOTTOM_BAR = "hide_bottom_bar"; public static final int SIZE_LIMIT_800 = 0; @@ -77,6 +78,7 @@ public class MoexConfig { public static boolean blurDrawer = instance().getBoolean(KEY_BLUR_DRAWER, false); public static boolean typingInsteadChoosing = instance().getBoolean(KEY_TYPING_INSTEAD_CHOOSING, true); public static boolean disableReactions = instance().getBoolean(KEY_DISABLE_REACTIONS, false); + public static boolean hideBottomBar = instance().getBoolean(KEY_HIDE_BOTTOM_BAR, false); private MoexConfig () { File configDir = new File(UI.getAppContext().getFilesDir(), "moexconf"); @@ -316,4 +318,8 @@ public void toggleTypingInsteadChoosing () { public void toggleDisableReactions () { putBoolean(KEY_DISABLE_REACTIONS, disableReactions ^= true); } + + public void toggleHideBottomBar () { + putBoolean(KEY_HIDE_BOTTOM_BAR, hideBottomBar ^= true); + } } diff --git a/app/src/main/java/moe/kirao/mgx/ui/ChatsSettingsMoexController.java b/app/src/main/java/moe/kirao/mgx/ui/ChatsSettingsMoexController.java index eeb8b8130e..46953ca073 100644 --- a/app/src/main/java/moe/kirao/mgx/ui/ChatsSettingsMoexController.java +++ b/app/src/main/java/moe/kirao/mgx/ui/ChatsSettingsMoexController.java @@ -89,6 +89,9 @@ public ChatsSettingsMoexController (Context context, Tdlib tdlib) { items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); items.add(new ListItem(ListItem.TYPE_DESCRIPTION, 0, 0, Lang.getMarkdownString(this, R.string.ReorderStickersInfo), false)); items.add(new ListItem(ListItem.TYPE_SHADOW_TOP)); + + items.add(new ListItem(ListItem.TYPE_HEADER, 0, 0, R.string.ActivityOptions)); + items.add(new ListItem(ListItem.TYPE_SHADOW_TOP)); items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_rememberOptions, 0, R.string.RememberOptions)); items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); items.add(new ListItem(ListItem.TYPE_DESCRIPTION, 0, 0, Lang.getMarkdownString(this, R.string.RememberOptionsInfo), false)); diff --git a/app/src/main/java/moe/kirao/mgx/ui/GeneralSettingsMoexController.java b/app/src/main/java/moe/kirao/mgx/ui/GeneralSettingsMoexController.java index 1caa10c8e7..bdf7a7adb0 100644 --- a/app/src/main/java/moe/kirao/mgx/ui/GeneralSettingsMoexController.java +++ b/app/src/main/java/moe/kirao/mgx/ui/GeneralSettingsMoexController.java @@ -104,12 +104,15 @@ private void showChangeSizeLimit () { ArrayList items = new ArrayList<>(); items.add(new ListItem(ListItem.TYPE_EMPTY_OFFSET_SMALL)); + items.add(new ListItem(ListItem.TYPE_HEADER, 0, 0, R.string.ProfileOptions)); + items.add(new ListItem(ListItem.TYPE_SHADOW_TOP)); + items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_showIdProfile, 0, R.string.showIdProfile)); + items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); + items.add(new ListItem(ListItem.TYPE_HEADER, 0, 0, R.string.DrawerOptions)); items.add(new ListItem(ListItem.TYPE_SHADOW_TOP)); items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_hidePhone, 0, R.string.hidePhoneNumber)); items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); - items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_showIdProfile, 0, R.string.showIdProfile)); - items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_hideMessagesBadge, 0, R.string.hideMessagesBadge)); items.add(new ListItem(ListItem.TYPE_SHADOW_BOTTOM)); diff --git a/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java b/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java index 101832c68b..3b824cbc7d 100644 --- a/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java +++ b/app/src/main/java/moe/kirao/mgx/ui/InterfaceSettingsMoexController.java @@ -84,6 +84,9 @@ public InterfaceSettingsMoexController (Context context, Tdlib tdlib) { } adapter.updateValuedSettingById(R.id.btn_hideMessagePanelButtons); })); + } else if (viewId == R.id.btn_hideBottomBar) { + MoexConfig.instance().toggleHideBottomBar(); + adapter.updateValuedSettingById(R.id.btn_hideBottomBar); } } @@ -153,6 +156,8 @@ public InterfaceSettingsMoexController (Context context, Tdlib tdlib) { b.append(Lang.getString(R.string.BlockedNone)); } view.setData(b.toString()); + } else if (itemId == R.id.btn_hideBottomBar) { + view.getToggler().setRadioEnabled(MoexConfig.hideBottomBar, isUpdate); } } }; @@ -176,6 +181,8 @@ public InterfaceSettingsMoexController (Context context, Tdlib tdlib) { items.add(new ListItem(ListItem.TYPE_HEADER, 0, 0, R.string.MoexHideButtons)); items.add(new ListItem(ListItem.TYPE_SHADOW_TOP)); items.add(new ListItem(ListItem.TYPE_VALUED_SETTING_COMPACT, R.id.btn_hideMessagePanelButtons, 0, R.string.HideMessagePanelButtons)); + items.add(new ListItem(ListItem.TYPE_SEPARATOR_FULL)); + items.add(new ListItem(ListItem.TYPE_RADIO_SETTING, R.id.btn_hideBottomBar, 0, R.string.HideBottomBar)); adapter.setItems(items, true); recyclerView.setAdapter(adapter); diff --git a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java index e7b6d8f10f..05c16e1664 100644 --- a/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java +++ b/app/src/main/java/org/thunderdog/challegram/ui/MessagesController.java @@ -5704,9 +5704,10 @@ private OptionDelegate newMessageOptionDelegate (final TGMessage selectedMessage private int bottomButtonAction; private boolean needBigPadding; + private int CURRENT_BOTTOM_ACTION; private void checkExtraPadding () { - boolean needBigPadding = bottomBarVisible.getValue(); // && !scrollToBottomVisible; + boolean needBigPadding = MoexConfig.hideBottomBar ? CURRENT_BOTTOM_ACTION == BOTTOM_ACTION_APPLY_WALLPAPER : bottomBarVisible.getValue(); // && !scrollToBottomVisible; if (this.needBigPadding != needBigPadding) { this.needBigPadding = needBigPadding; manager.rebuildLastItem(); @@ -5718,7 +5719,7 @@ public boolean needExtraBigPadding () { } private void showBottomButton (int bottomButtonAction, long bottomButtonData, boolean animated) { - this.bottomButtonAction = bottomButtonAction; + CURRENT_BOTTOM_ACTION = this.bottomButtonAction = bottomButtonAction; boolean animateButtonContent = animated && bottomBarVisible.getFloatValue() > 0f; switch (bottomButtonAction) { case BOTTOM_ACTION_FOLLOW: @@ -5765,6 +5766,8 @@ private void updateBottomBarStyle () { return; float bottomButtonFactor = bottomBarVisible.getFloatValue(); float detachFactor = scrollToBottomVisible.getFloatValue(); + boolean needBottomBar = CURRENT_BOTTOM_ACTION == BOTTOM_ACTION_APPLY_WALLPAPER; + boolean needHideBottomBar = MoexConfig.hideBottomBar && !needBottomBar && !scrollToBottomVisible.getValue(); int barHeight = Screen.dp(48f); int baseY = needSearchControlsTranslate() ? (int) ((float) barHeight * MathUtils.clamp(searchControlsFactor)) : 0; float fromY = bottomButtonFactor == 1f ? baseY : baseY + (int) ((float) barHeight * (1f - bottomButtonFactor)); @@ -5776,7 +5779,7 @@ private void updateBottomBarStyle () { int dx = (int) ((bottomBar.getMeasuredWidth() / 2f - Screen.dp(16f) - barHeight / 2) * detachFactor); bottomBar.setTranslationY(bottomButtonFactor == 1f && detachFactor == 0f ? fromY : fromY + (toY - fromY) * detachFactor); bottomBar.setTranslationX(dx); - int desiredVisibility = (bottomButtonFactor > 0f && searchControlsFactor != 1f) ? View.VISIBLE : View.GONE; + int desiredVisibility = (bottomButtonFactor > 0f && searchControlsFactor != 1f) && !needHideBottomBar ? View.VISIBLE : View.GONE; if (bottomBar.getVisibility() != desiredVisibility) { bottomBar.setVisibility(desiredVisibility); } diff --git a/app/src/main/res/values/moex_ids.xml b/app/src/main/res/values/moex_ids.xml index a97846c870..0fc130a606 100644 --- a/app/src/main/res/values/moex_ids.xml +++ b/app/src/main/res/values/moex_ids.xml @@ -41,4 +41,5 @@ + diff --git a/app/src/main/res/values/moex_strings.xml b/app/src/main/res/values/moex_strings.xml index 1dd80cc090..28bbcf6a0b 100755 --- a/app/src/main/res/values/moex_strings.xml +++ b/app/src/main/res/values/moex_strings.xml @@ -70,4 +70,7 @@ Moe moe, kyun! Hide reactions Hide message panel buttons + Profile + Activity + Hide bottom bar