readd some settings

This commit is contained in:
arm64v8a 2021-11-03 15:01:01 +08:00
parent c972890ddd
commit 3f4ff5c9ff
4 changed files with 38 additions and 20 deletions

View File

@ -20494,7 +20494,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (NekomuraConfig.showDeleteDownloadedFile.Bool() && NekomuraUtil.messageObjectIsFile(type, selectedObject)) {
items.add(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile));
options.add(91); //TODO nkbtn here
icons.add(R.drawable.menu_clearcache);
icons.add(R.drawable.baseline_delete_sweep_24);
}
if (allowViewHistory && NekomuraConfig.showViewHistory.Bool()) {

View File

@ -70,6 +70,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
private final NekomuraTGCell ignoreBlockedRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout")));
private final NekomuraTGCell ignoreMutedCountRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.ignoreMutedCount));
private final NekomuraTGCell disableChatActionRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableChatAction));
private final NekomuraTGCell disableChoosingStickerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableChoosingSticker));
private final NekomuraTGCell disablePhotoSideActionRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disablePhotoSideAction));
private final NekomuraTGCell hideKeyboardOnChatScrollRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideKeyboardOnChatScroll));
private final NekomuraTGCell disableVibrationRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableVibration));
@ -87,7 +88,6 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
private final NekomuraTGCell takeGIFasVideoRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.takeGIFasVideo));
private final NekomuraTGCell maxRecentStickerCountRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
private final NekomuraTGCell disableSwipeToNextRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableSwipeToNext));
//private final NekomuraTGCell disableChoosingStickerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableChoosingSticker));
private final NekomuraTGCell disableRemoteEmojiInteractionsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableRemoteEmojiInteractions));
private final NekomuraTGCell mapPreviewRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.mapPreviewProvider,
new String[]{
@ -156,6 +156,9 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
}
});
// Before listAdapter
setCanNotChange();
listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(context);
@ -558,4 +561,12 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
return new RecyclerListView.Holder(view);
}
}
private void setCanNotChange() {
boolean enabled;
enabled = NekoXConfig.developerMode || NekoXConfig.customApi > 0;
((NekomuraTGTextCheck) disableChatActionRow).enabled = enabled;
((NekomuraTGTextCheck) disableChoosingStickerRow).enabled = enabled;
}
}

View File

@ -58,6 +58,7 @@ import cn.hutool.core.util.StrUtil;
import kotlin.Unit;
import tw.nekomimi.nekogram.BottomBuilder;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.PopupBuilder;
import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.transtale.TranslatorKt;
@ -125,6 +126,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
private final NekomuraTGCell useDefaultThemeRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useDefaultTheme));
private final NekomuraTGCell useSystemEmojiRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useSystemEmoji));
private final NekomuraTGCell transparentStatusBarRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.transparentStatusBar));
private final NekomuraTGCell appBarShadowRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableAppBarShadow));
private final NekomuraTGCell newYearRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.newYear));
private final NekomuraTGCell actionBarDecorationRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.actionBarDecoration, new String[]{
LocaleController.getString("DependsOnDate", R.string.DependsOnDate),
@ -196,6 +198,9 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
FrameLayout frameLayout = (FrameLayout) fragmentView;
// Before listAdapter
setCanNotChange();
listView = new RecyclerListView(context);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
@ -355,8 +360,8 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
} else if (key.equals(NekomuraConfig.largeAvatarInDrawer.getKey())) {
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
TransitionManager.beginDelayedTransition(profilePreviewCell);
listAdapter.notifyItemChanged(rows.indexOf(profilePreviewRow));
setAvatarOptionsVisibility();
setCanNotChange();
listAdapter.notifyDataSetChanged();
} else if (key.equals(NekomuraConfig.avatarBackgroundBlur.getKey())) {
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
listAdapter.notifyItemChanged(rows.indexOf(profilePreviewRow));
@ -687,7 +692,6 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
a.onBindViewHolder(holder);
}
// Other things
setAvatarOptionsVisibility();
}
}
@ -729,6 +733,14 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
}
}
private void setCanNotChange() {
boolean enabled;
enabled = NekomuraConfig.largeAvatarInDrawer.Int() > 0;
((NekomuraTGTextCheck) avatarBackgroundBlurRow).enabled = enabled;
((NekomuraTGTextCheck) avatarBackgroundDarkenRow).enabled = enabled;
}
//Custom dialogs
private void customDialog_BottomInputString(int position, NekomuraConfig.ConfigItem bind, String subtitle, String hint) {
@ -766,17 +778,4 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
keyField.requestFocus();
AndroidUtilities.showKeyboard(keyField);
}
private void setAvatarOptionsVisibility() {
//TODO hideItemFromRecyclerView
TextCheckCell cell1 = ((NekomuraTGTextCheck) avatarBackgroundBlurRow).cell;
TextCheckCell cell2 = ((NekomuraTGTextCheck) avatarBackgroundDarkenRow).cell;
if (NekomuraConfig.largeAvatarInDrawer.Int() > 0) {
Cells.hideItemFromRecyclerView(cell1, false);
Cells.hideItemFromRecyclerView(cell2, false);
} else {
Cells.hideItemFromRecyclerView(cell1, true);
Cells.hideItemFromRecyclerView(cell2, true);
}
}
}
}

View File

@ -1,5 +1,6 @@
package tw.nekomimi.nkmr;
import android.animation.Animator;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
@ -23,6 +24,7 @@ import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.util.StrUtil;
@ -77,6 +79,8 @@ public class Cells {
void onBindViewHolder(RecyclerView.ViewHolder holder);
}
//Utils
public static void hideItemFromRecyclerView(View cell, boolean hide) {
if (cell == null) return;
if (cell != null) return; //TODO hideItemFromRecyclerView
@ -181,6 +185,7 @@ public class Cells {
private final NekomuraConfig.ConfigItem bindConfig;
private final String title;
private final String subtitle;
public boolean enabled = true;
public TextCheckCell cell; //TODO getCell() in NekomuraTGCell
public NekomuraTGTextCheck(NekomuraConfig.ConfigItem bind) {
@ -200,7 +205,7 @@ public class Cells {
}
public boolean isEnabled() {
return true;
return enabled;
}
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
@ -211,9 +216,12 @@ public class Cells {
} else {
cell.setTextAndValueAndCheck(title, subtitle, bindConfig.Bool(), true, !(rows.get(rows.indexOf(this) + 1) instanceof NekomuraTGDivider));
}
cell.setEnabled(enabled, null);
}
public void onClick(TextCheckCell cell) {
if (!enabled) return;
boolean newV = bindConfig.toggleConfigBool();
cell.setChecked(newV);