Skip to content

Commit

Permalink
feat: Ability to hide bottom bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jplie committed Jan 6, 2024
1 parent 9b3274c commit d2258a2
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/moe/kirao/mgx/MoexConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,15 @@ private void showChangeSizeLimit () {

ArrayList<ListItem> 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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}
};
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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:
Expand Down Expand Up @@ -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));
Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/moex_ids.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
<item name="btn_typingInstead" type="id"/>
<item name="btn_disableReactions" type="id"/>
<item name="btn_hideMessagePanelButtons" type="id" />
<item name="btn_hideBottomBar" type="id" />
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/moex_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@
<string name="cuteToast" translatable="false">Moe moe, kyun!</string>
<string name="DisableReactions">Hide reactions</string>
<string name="HideMessagePanelButtons">Hide message panel buttons</string>
<string name="ProfileOptions">Profile</string>
<string name="ActivityOptions">Activity</string>
<string name="HideBottomBar">Hide bottom bar</string>
</resources>

0 comments on commit d2258a2

Please sign in to comment.