mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2025-01-19 09:31:18 +01:00
Refactoring Config Cells
This commit is contained in:
parent
575dc800c2
commit
c139e60d06
@ -46,76 +46,78 @@ import java.util.stream.Collectors;
|
||||
import kotlin.Unit;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
import tw.nekomimi.nekogram.PopupBuilder;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.Cells;
|
||||
import tw.nekomimi.nkmr.Cells.*;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGCustom;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGDivider;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGHeader;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGSelectBox;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGTextCheck;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGTextDetail;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGTextInput;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private ActionBarMenuItem menuItem;
|
||||
private StickerSizeCell stickerSizeCell;
|
||||
|
||||
private ArrayList<NekomuraTGCell> rows = new ArrayList<>();
|
||||
private Cells nkmrCells = new Cells(this, rows);
|
||||
|
||||
private final NekomuraTGCell header0 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("StickerSize")));
|
||||
private final NekomuraTGCell stickerSizeRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(998, true));
|
||||
private final NekomuraTGCell divider0 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header1 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Chat")));
|
||||
private final NekomuraTGCell unreadBadgeOnBackButton = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.unreadBadgeOnBackButton));
|
||||
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));
|
||||
private final NekomuraTGCell skipOpenLinkConfirmRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.skipOpenLinkConfirm));
|
||||
private final NekomuraTGCell rearVideoMessagesRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.rearVideoMessages));
|
||||
private final NekomuraTGCell confirmAVRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.confirmAVMessage));
|
||||
private final NekomuraTGCell useChatAttachMediaMenuRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useChatAttachMediaMenu, LocaleController.getString("UseChatAttachEnterMenuNotice")));
|
||||
private final NekomuraTGCell disableLinkPreviewByDefaultRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableLinkPreviewByDefault, LocaleController.getString("DisableLinkPreviewByDefaultNotice")));
|
||||
private final NekomuraTGCell sendCommentAfterForwardRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.sendCommentAfterForward));
|
||||
private final NekomuraTGCell disableProximityEventsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableProximityEvents));
|
||||
private final NekomuraTGCell disableTrendingRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableTrending));
|
||||
private final NekomuraTGCell dontSendGreetingStickerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.dontSendGreetingSticker));
|
||||
private final NekomuraTGCell hideTimeForStickerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideTimeForSticker));
|
||||
private final NekomuraTGCell hideGroupStickerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideGroupSticker));
|
||||
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 disableRemoteEmojiInteractionsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableRemoteEmojiInteractions));
|
||||
private final NekomuraTGCell mapPreviewRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.mapPreviewProvider,
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
private final boolean showCensoredFeatures = NekoXConfig.developerMode || NekoXConfig.customApi > 0 || Arrays.stream(NekoXConfig.developers).anyMatch(id -> id == getUserConfig().getCurrentUser().id);
|
||||
private final NekomuraTGCell header0 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("StickerSize")));
|
||||
private final NekomuraTGCell stickerSizeRow = cellGroup.appendCell(new NekomuraTGCustom(998, true));
|
||||
private final NekomuraTGCell divider0 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final NekomuraTGCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Chat")));
|
||||
private final NekomuraTGCell unreadBadgeOnBackButton = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unreadBadgeOnBackButton));
|
||||
private final NekomuraTGCell ignoreBlockedRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout")));
|
||||
private final NekomuraTGCell ignoreMutedCountRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.ignoreMutedCount));
|
||||
private final NekomuraTGCell disableChatActionRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableChatAction));
|
||||
private final NekomuraTGCell disableChoosingStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableChoosingSticker));
|
||||
private final NekomuraTGCell disablePhotoSideActionRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disablePhotoSideAction));
|
||||
private final NekomuraTGCell hideKeyboardOnChatScrollRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideKeyboardOnChatScroll));
|
||||
private final NekomuraTGCell disableVibrationRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableVibration));
|
||||
private final NekomuraTGCell skipOpenLinkConfirmRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.skipOpenLinkConfirm));
|
||||
private final NekomuraTGCell rearVideoMessagesRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.rearVideoMessages));
|
||||
private final NekomuraTGCell confirmAVRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.confirmAVMessage));
|
||||
private final NekomuraTGCell useChatAttachMediaMenuRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useChatAttachMediaMenu, LocaleController.getString("UseChatAttachEnterMenuNotice")));
|
||||
private final NekomuraTGCell disableLinkPreviewByDefaultRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableLinkPreviewByDefault, LocaleController.getString("DisableLinkPreviewByDefaultNotice")));
|
||||
private final NekomuraTGCell sendCommentAfterForwardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.sendCommentAfterForward));
|
||||
private final NekomuraTGCell disableProximityEventsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableProximityEvents));
|
||||
private final NekomuraTGCell disableTrendingRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableTrending));
|
||||
private final NekomuraTGCell dontSendGreetingStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.dontSendGreetingSticker));
|
||||
private final NekomuraTGCell hideTimeForStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideTimeForSticker));
|
||||
private final NekomuraTGCell hideGroupStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideGroupSticker));
|
||||
private final NekomuraTGCell takeGIFasVideoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.takeGIFasVideo));
|
||||
private final NekomuraTGCell maxRecentStickerCountRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell disableSwipeToNextRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableSwipeToNext));
|
||||
private final NekomuraTGCell disableRemoteEmojiInteractionsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableRemoteEmojiInteractions));
|
||||
private final NekomuraTGCell mapPreviewRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.mapPreviewProvider,
|
||||
new String[]{
|
||||
LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram),
|
||||
LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex),
|
||||
LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody)
|
||||
}, null));
|
||||
private final NekomuraTGCell messageMenuRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> {
|
||||
private final NekomuraTGCell messageMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> {
|
||||
showMessageMenuAlert();
|
||||
}));
|
||||
private final NekomuraTGCell divider1 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header2 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("AutoDownload")));
|
||||
private final NekomuraTGCell win32Row = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingWin32Executable));
|
||||
private final NekomuraTGCell archiveRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingArchive));
|
||||
private final NekomuraTGCell divider2 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header3 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Folder")));
|
||||
private final NekomuraTGCell showTabsOnForwardRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.showTabsOnForward));
|
||||
private final NekomuraTGCell hideAllTabRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideAllTab, LocaleController.getString("HideAllTabAbout")));
|
||||
private final NekomuraTGCell pressTitleToOpenAllChatsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.pressTitleToOpenAllChats));
|
||||
private final NekomuraTGCell tabsTitleTypeRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.tabsTitleType,
|
||||
private final NekomuraTGCell divider1 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final NekomuraTGCell header2 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("AutoDownload")));
|
||||
private final NekomuraTGCell win32Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingWin32Executable));
|
||||
private final NekomuraTGCell archiveRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingArchive));
|
||||
private final NekomuraTGCell divider2 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final NekomuraTGCell header3 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Folder")));
|
||||
private final NekomuraTGCell showTabsOnForwardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.showTabsOnForward));
|
||||
private final NekomuraTGCell hideAllTabRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideAllTab, LocaleController.getString("HideAllTabAbout")));
|
||||
private final NekomuraTGCell pressTitleToOpenAllChatsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.pressTitleToOpenAllChats));
|
||||
private final NekomuraTGCell tabsTitleTypeRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.tabsTitleType,
|
||||
new String[]{
|
||||
LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText),
|
||||
LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon),
|
||||
LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix)
|
||||
}, null));
|
||||
private final NekomuraTGCell divider3 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell divider3 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private ActionBarMenuItem menuItem;
|
||||
private StickerSizeCell stickerSizeCell;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
@ -157,7 +159,9 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
});
|
||||
|
||||
// Before listAdapter
|
||||
setCanNotChange();
|
||||
((NekomuraTGTextCheck) disableChatActionRow).enabled = showCensoredFeatures;
|
||||
((NekomuraTGTextCheck) disableChoosingStickerRow).enabled = showCensoredFeatures;
|
||||
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
||||
@ -173,7 +177,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
|
||||
// Fragment: Set OnClick Callbacks
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
@ -189,7 +193,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
}
|
||||
}
|
||||
} else if (a instanceof NekomuraTGCustom) { // Custom onclick
|
||||
if (position == rows.indexOf(maxRecentStickerCountRow)) {
|
||||
if (position == cellGroup.rows.indexOf(maxRecentStickerCountRow)) {
|
||||
final int[] counts = {20, 30, 40, 50, 80, 100, 120, 150, 180, 200};
|
||||
List<String> types = Arrays.stream(counts)
|
||||
.filter(i -> i <= getMessagesController().maxRecentStickersCount)
|
||||
@ -207,7 +211,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
});
|
||||
|
||||
// Cells: Set OnSettingChanged Callbacks
|
||||
nkmrCells.callBackSettingsChanged = (key, newValue) -> {
|
||||
cellGroup.callBackSettingsChanged = (key, newValue) -> {
|
||||
if (key.equals(NekomuraConfig.hideAllTab.getKey())) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
|
||||
} else if (key.equals(NekomuraConfig.pressTitleToOpenAllChats.getKey())) {
|
||||
@ -220,16 +224,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
};
|
||||
|
||||
//Cells: Set ListAdapter
|
||||
nkmrCells.setListAdapter(listView, listAdapter);
|
||||
cellGroup.setListAdapter(listView, listAdapter);
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public NekomuraTGCell addNekomuraTGCell(NekomuraTGCell a) {
|
||||
rows.add(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -416,12 +415,12 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
|
||||
private class StickerSizeCell extends FrameLayout {
|
||||
|
||||
private StickerSizePreviewMessagesCell messagesCell;
|
||||
private SeekBarView sizeBar;
|
||||
private int startStickerSize = 2;
|
||||
private int endStickerSize = 20;
|
||||
private final StickerSizePreviewMessagesCell messagesCell;
|
||||
private final SeekBarView sizeBar;
|
||||
private final int startStickerSize = 2;
|
||||
private final int endStickerSize = 20;
|
||||
|
||||
private TextPaint textPaint;
|
||||
private final TextPaint textPaint;
|
||||
|
||||
public StickerSizeCell(Context context) {
|
||||
super(context);
|
||||
@ -475,7 +474,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
//impl ListAdapter
|
||||
private class ListAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
|
||||
public ListAdapter(Context context) {
|
||||
mContext = context;
|
||||
@ -483,13 +482,13 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return rows.size();
|
||||
return cellGroup.rows.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
@ -498,22 +497,22 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
return Cells.ITEM_TYPE_TEXT_DETAIL;
|
||||
return CellGroup.ITEM_TYPE_TEXT_DETAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
if (holder.itemView instanceof TextSettingsCell) {
|
||||
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
|
||||
if (position == rows.indexOf(maxRecentStickerCountRow)) {
|
||||
if (position == cellGroup.rows.indexOf(maxRecentStickerCountRow)) {
|
||||
textCell.setTextAndValue(LocaleController.getString("maxRecentStickerCount", R.string.maxRecentStickerCount), String.valueOf(NekomuraConfig.maxRecentStickerCount.Int()), true);
|
||||
}
|
||||
}
|
||||
@ -528,26 +527,26 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = null;
|
||||
switch (viewType) {
|
||||
case Cells.ITEM_TYPE_DIVIDER:
|
||||
case CellGroup.ITEM_TYPE_DIVIDER:
|
||||
view = new ShadowSectionCell(mContext);
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
view = new TextSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_CHECK:
|
||||
case CellGroup.ITEM_TYPE_TEXT_CHECK:
|
||||
view = new TextCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_HEADER:
|
||||
case CellGroup.ITEM_TYPE_HEADER:
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_DETAIL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_DETAIL:
|
||||
view = new TextDetailSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT:
|
||||
case CellGroup.ITEM_TYPE_TEXT:
|
||||
view = new TextInfoPrivacyCell(mContext);
|
||||
// view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
break;
|
||||
@ -561,12 +560,4 @@ 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;
|
||||
}
|
||||
}
|
@ -42,8 +42,9 @@ import kotlin.Unit;
|
||||
|
||||
import tw.nekomimi.nekogram.PopupBuilder;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.Cells;
|
||||
import tw.nekomimi.nkmr.Cells.*;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.*;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
@ -55,22 +56,21 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
private boolean sensitiveCanChange = false;
|
||||
private boolean sensitiveEnabled = false;
|
||||
|
||||
private ArrayList<NekomuraTGCell> rows = new ArrayList<>();
|
||||
private Cells nkmrCells = new Cells(this, rows);
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
|
||||
private final NekomuraTGCell header1 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Experiment")));
|
||||
private final NekomuraTGCell smoothKeyboardRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.smoothKeyboard));
|
||||
private final NekomuraTGCell increaseVoiceMessageQualityRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.increaseVoiceMessageQuality));
|
||||
private final NekomuraTGCell mediaPreviewRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.mediaPreview));
|
||||
private final NekomuraTGCell proxyAutoSwitchRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.proxyAutoSwitch));
|
||||
private final NekomuraTGCell disableFilteringRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_CHECK, true));
|
||||
private final NekomuraTGCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Experiment")));
|
||||
private final NekomuraTGCell smoothKeyboardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.smoothKeyboard));
|
||||
private final NekomuraTGCell increaseVoiceMessageQualityRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.increaseVoiceMessageQuality));
|
||||
private final NekomuraTGCell mediaPreviewRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.mediaPreview));
|
||||
private final NekomuraTGCell proxyAutoSwitchRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.proxyAutoSwitch));
|
||||
private final NekomuraTGCell disableFilteringRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_CHECK, true));
|
||||
// private final NekomuraTGCell ignoreContentRestrictionsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.ignoreContentRestrictions, LocaleController.getString("IgnoreContentRestrictionsNotice")));
|
||||
private final NekomuraTGCell unlimitedFavedStickersRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.unlimitedFavedStickers, LocaleController.getString("UnlimitedFavoredStickersAbout")));
|
||||
private final NekomuraTGCell unlimitedPinnedDialogsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.unlimitedPinnedDialogs, LocaleController.getString("UnlimitedPinnedDialogsAbout")));
|
||||
private final NekomuraTGCell enableStickerPinRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.enableStickerPin, LocaleController.getString("EnableStickerPinAbout")));
|
||||
private final NekomuraTGCell useMediaStreamInVoipRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useMediaStreamInVoip));
|
||||
private final NekomuraTGCell customAudioBitrateRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell divider0 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell unlimitedFavedStickersRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unlimitedFavedStickers, LocaleController.getString("UnlimitedFavoredStickersAbout")));
|
||||
private final NekomuraTGCell unlimitedPinnedDialogsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unlimitedPinnedDialogs, LocaleController.getString("UnlimitedPinnedDialogsAbout")));
|
||||
private final NekomuraTGCell enableStickerPinRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.enableStickerPin, LocaleController.getString("EnableStickerPinAbout")));
|
||||
private final NekomuraTGCell useMediaStreamInVoipRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useMediaStreamInVoip));
|
||||
private final NekomuraTGCell customAudioBitrateRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell divider0 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private UndoView tooltip;
|
||||
|
||||
@ -115,7 +115,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
|
||||
// Fragment: Set OnClick Callbacks
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
@ -131,7 +131,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
} else if (a instanceof NekomuraTGCustom) { // Custom onclick
|
||||
if (position == rows.indexOf(disableFilteringRow)) {
|
||||
if (position == cellGroup.rows.indexOf(disableFilteringRow)) {
|
||||
sensitiveEnabled = !sensitiveEnabled;
|
||||
TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings();
|
||||
req.sensitive_enabled = sensitiveEnabled;
|
||||
@ -147,7 +147,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
AndroidUtilities.runOnUIThread(() -> AlertsCreator.processError(currentAccount, error, this, req));
|
||||
}
|
||||
}));
|
||||
} else if (position == rows.indexOf(customAudioBitrateRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(customAudioBitrateRow)) {
|
||||
PopupBuilder builder = new PopupBuilder(view);
|
||||
builder.setItems(new String[]{
|
||||
"32 (" + LocaleController.getString("Default", R.string.Default) + ")",
|
||||
@ -186,7 +186,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
// Cells: Set OnSettingChanged Callbacks
|
||||
nkmrCells.callBackSettingsChanged = (key, newValue) -> {
|
||||
cellGroup.callBackSettingsChanged = (key, newValue) -> {
|
||||
if (key.equals(NekomuraConfig.smoothKeyboard.getKey())) {
|
||||
if ((boolean) newValue != NekomuraConfig.smoothKeyboard.Bool()) {
|
||||
SharedConfig.toggleSmoothKeyboard();
|
||||
@ -213,7 +213,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
};
|
||||
|
||||
//Cells: Set ListAdapter
|
||||
nkmrCells.setListAdapter(listView, listAdapter);
|
||||
cellGroup.setListAdapter(listView, listAdapter);
|
||||
|
||||
tooltip = new UndoView(context);
|
||||
frameLayout.addView(tooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
||||
@ -221,12 +221,6 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public NekomuraTGCell addNekomuraTGCell(NekomuraTGCell a) {
|
||||
rows.add(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@ -296,7 +290,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
View child = listView.getChildAt(a);
|
||||
RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.getChildViewHolder(child);
|
||||
int position = holder.getAdapterPosition();
|
||||
if (position == rows.indexOf(disableFilteringRow)) {
|
||||
if (position == cellGroup.rows.indexOf(disableFilteringRow)) {
|
||||
TextCheckCell checkCell = (TextCheckCell) holder.itemView;
|
||||
checkCell.setChecked(sensitiveEnabled);
|
||||
checkCell.setEnabled(sensitiveCanChange, animators);
|
||||
@ -338,13 +332,13 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return rows.size();
|
||||
return cellGroup.rows.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
@ -353,30 +347,30 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
return Cells.ITEM_TYPE_TEXT_DETAIL;
|
||||
return CellGroup.ITEM_TYPE_TEXT_DETAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
if (holder.itemView instanceof TextCheckCell) {
|
||||
TextCheckCell textCell = (TextCheckCell) holder.itemView;
|
||||
textCell.setEnabled(true, null);
|
||||
if (position == rows.indexOf(disableFilteringRow)) {
|
||||
if (position == cellGroup.rows.indexOf(disableFilteringRow)) {
|
||||
textCell.setTextAndValueAndCheck(LocaleController.getString("SensitiveDisableFiltering", R.string.SensitiveDisableFiltering), LocaleController.getString("SensitiveAbout", R.string.SensitiveAbout), sensitiveEnabled, true, true);
|
||||
textCell.setEnabled(sensitiveCanChange, null);
|
||||
}
|
||||
} else if (holder.itemView instanceof TextSettingsCell) {
|
||||
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
|
||||
textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
if (position == rows.indexOf(customAudioBitrateRow)) {
|
||||
if (position == cellGroup.rows.indexOf(customAudioBitrateRow)) {
|
||||
String value = String.valueOf(NekomuraConfig.customAudioBitrate.Int()) + "kbps";
|
||||
if (NekomuraConfig.customAudioBitrate.Int() == 32)
|
||||
value += " (" + LocaleController.getString("Default", R.string.Default) + ")";
|
||||
@ -386,7 +380,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
} else {
|
||||
// Default binds
|
||||
a.onBindViewHolder(holder);
|
||||
if (position == rows.indexOf(smoothKeyboardRow) && AndroidUtilities.isTablet()) {
|
||||
if (position == cellGroup.rows.indexOf(smoothKeyboardRow) && AndroidUtilities.isTablet()) {
|
||||
holder.itemView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@ -398,26 +392,26 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = null;
|
||||
switch (viewType) {
|
||||
case Cells.ITEM_TYPE_DIVIDER:
|
||||
case CellGroup.ITEM_TYPE_DIVIDER:
|
||||
view = new ShadowSectionCell(mContext);
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
view = new TextSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_CHECK:
|
||||
case CellGroup.ITEM_TYPE_TEXT_CHECK:
|
||||
view = new TextCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_HEADER:
|
||||
case CellGroup.ITEM_TYPE_HEADER:
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_DETAIL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_DETAIL:
|
||||
view = new TextDetailSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT:
|
||||
case CellGroup.ITEM_TYPE_TEXT:
|
||||
view = new TextInfoPrivacyCell(mContext);
|
||||
// view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
break;
|
||||
|
@ -58,16 +58,17 @@ 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;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
import tw.nekomimi.nekogram.utils.PGPUtil;
|
||||
|
||||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.Cells;
|
||||
import tw.nekomimi.nkmr.Cells.*;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.*;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
@ -77,90 +78,89 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
private ValueAnimator statusBarColorAnimator;
|
||||
private DrawerProfilePreviewCell profilePreviewCell;
|
||||
|
||||
private ArrayList<NekomuraTGCell> rows = new ArrayList<>();
|
||||
private Cells nkmrCells = new Cells(this, rows);
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
|
||||
private final NekomuraTGCell profilePreviewRow = addNekomuraTGCell(new NkmrDrawerProfilePreviewCell());
|
||||
private final NekomuraTGCell largeAvatarInDrawerRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null));
|
||||
private final NekomuraTGCell avatarBackgroundBlurRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundBlur));
|
||||
private final NekomuraTGCell avatarBackgroundDarkenRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundDarken));
|
||||
private final NekomuraTGCell hidePhoneRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hidePhone));
|
||||
private final NekomuraTGCell divider0 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell profilePreviewRow = cellGroup.appendCell(new NkmrDrawerProfilePreviewCell());
|
||||
private final NekomuraTGCell largeAvatarInDrawerRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null));
|
||||
private final NekomuraTGCell avatarBackgroundBlurRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundBlur));
|
||||
private final NekomuraTGCell avatarBackgroundDarkenRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundDarken));
|
||||
private final NekomuraTGCell hidePhoneRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hidePhone));
|
||||
private final NekomuraTGCell divider0 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header1 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Connection")));
|
||||
private final NekomuraTGCell useIPv6Row = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useIPv6));
|
||||
private final NekomuraTGCell disableProxyWhenVpnEnabledRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableProxyWhenVpnEnabled));
|
||||
private final NekomuraTGCell useProxyItemRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useProxyItem));
|
||||
private final NekomuraTGCell hideProxyByDefaultRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideProxyByDefault));
|
||||
private final NekomuraTGCell useSystemDNSRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.useSystemDNS));
|
||||
private final NekomuraTGCell customDoHRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextInput(null, NekomuraConfig.customDoH, "https://1.0.0.1/dns-query", null));
|
||||
private final NekomuraTGCell customPublicProxyIPRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextDetail(NekomuraConfig.customPublicProxyIP, (view, position) -> {
|
||||
private final NekomuraTGCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Connection")));
|
||||
private final NekomuraTGCell useIPv6Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useIPv6));
|
||||
private final NekomuraTGCell disableProxyWhenVpnEnabledRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableProxyWhenVpnEnabled));
|
||||
private final NekomuraTGCell useProxyItemRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useProxyItem));
|
||||
private final NekomuraTGCell hideProxyByDefaultRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideProxyByDefault));
|
||||
private final NekomuraTGCell useSystemDNSRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useSystemDNS));
|
||||
private final NekomuraTGCell customDoHRow = cellGroup.appendCell(new NekomuraTGTextInput(null, NekomuraConfig.customDoH, "https://1.0.0.1/dns-query", null));
|
||||
private final NekomuraTGCell customPublicProxyIPRow = cellGroup.appendCell(new NekomuraTGTextDetail(NekomuraConfig.customPublicProxyIP, (view, position) -> {
|
||||
customDialog_BottomInputString(position, NekomuraConfig.customPublicProxyIP, LocaleController.getString("customPublicProxyIPNotice"), "IP");
|
||||
}, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty)));
|
||||
private final NekomuraTGCell divider1 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell divider1 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header2 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Translate")));
|
||||
private final NekomuraTGCell translationProviderRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell translateToLangRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell translateInputToLangRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell googleCloudTranslateKeyRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextDetail(NekomuraConfig.googleCloudTranslateKey, (view, position) -> {
|
||||
private final NekomuraTGCell header2 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Translate")));
|
||||
private final NekomuraTGCell translationProviderRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell translateToLangRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell translateInputToLangRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell googleCloudTranslateKeyRow = cellGroup.appendCell(new NekomuraTGTextDetail(NekomuraConfig.googleCloudTranslateKey, (view, position) -> {
|
||||
customDialog_BottomInputString(position, NekomuraConfig.googleCloudTranslateKey, LocaleController.getString("GoogleCloudTransKeyNotice"), "Key");
|
||||
}, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty)));
|
||||
private final NekomuraTGCell divider2 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell divider2 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header3 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("OpenKayChain")));
|
||||
private final NekomuraTGCell pgpAppRow = addNekomuraTGCell(nkmrCells.new NekomuraTGCustom(Cells.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell keyRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextDetail(NekomuraConfig.openPGPKeyId, (view, position) -> {
|
||||
private final NekomuraTGCell header3 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("OpenKayChain")));
|
||||
private final NekomuraTGCell pgpAppRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final NekomuraTGCell keyRow = cellGroup.appendCell(new NekomuraTGTextDetail(NekomuraConfig.openPGPKeyId, (view, position) -> {
|
||||
requestKey(new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID));
|
||||
}, "0"));
|
||||
private final NekomuraTGCell divider3 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell divider3 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header4 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("DialogsSettings")));
|
||||
private final NekomuraTGCell sortMenuRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(LocaleController.getString("SortMenu"), null, null, () -> {
|
||||
private final NekomuraTGCell header4 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("DialogsSettings")));
|
||||
private final NekomuraTGCell sortMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("SortMenu"), null, null, () -> {
|
||||
showSortMenuAlert();
|
||||
}));
|
||||
private final NekomuraTGCell acceptSecretChatRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.acceptSecretChat));
|
||||
private final NekomuraTGCell divider4 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell acceptSecretChatRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.acceptSecretChat));
|
||||
private final NekomuraTGCell divider4 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header5 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("Appearance")));
|
||||
private final NekomuraTGCell typefaceRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.typeface));
|
||||
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[]{
|
||||
private final NekomuraTGCell header5 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Appearance")));
|
||||
private final NekomuraTGCell typefaceRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.typeface));
|
||||
private final NekomuraTGCell useDefaultThemeRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useDefaultTheme));
|
||||
private final NekomuraTGCell useSystemEmojiRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useSystemEmoji));
|
||||
private final NekomuraTGCell transparentStatusBarRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.transparentStatusBar));
|
||||
private final NekomuraTGCell appBarShadowRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAppBarShadow));
|
||||
private final NekomuraTGCell newYearRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.newYear));
|
||||
private final NekomuraTGCell actionBarDecorationRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.actionBarDecoration, new String[]{
|
||||
LocaleController.getString("DependsOnDate", R.string.DependsOnDate),
|
||||
LocaleController.getString("Snowflakes", R.string.Snowflakes),
|
||||
LocaleController.getString("Fireworks", R.string.Fireworks)
|
||||
}, null));
|
||||
private final NekomuraTGCell tabletModeRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.tabletMode, new String[]{
|
||||
private final NekomuraTGCell tabletModeRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.tabletMode, new String[]{
|
||||
LocaleController.getString("TabletModeDefault", R.string.TabletModeDefault),
|
||||
LocaleController.getString("Enable", R.string.Enable),
|
||||
LocaleController.getString("Disable", R.string.Disable)
|
||||
}, null));
|
||||
private final NekomuraTGCell divider5 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell divider5 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header6 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("PrivacyTitle")));
|
||||
private final NekomuraTGCell disableSystemAccountRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableSystemAccount));
|
||||
private final NekomuraTGCell divider6 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell header6 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("PrivacyTitle")));
|
||||
private final NekomuraTGCell disableSystemAccountRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableSystemAccount));
|
||||
private final NekomuraTGCell divider6 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header7 = addNekomuraTGCell(nkmrCells.new NekomuraTGHeader(LocaleController.getString("General")));
|
||||
private final NekomuraTGCell disableUndoRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableUndo));
|
||||
private final NekomuraTGCell showIdAndDcRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.showIdAndDc));
|
||||
private final NekomuraTGCell inappCameraRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.inappCamera));
|
||||
private final NekomuraTGCell hideProxySponsorChannelRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.hideProxySponsorChannel));
|
||||
private final NekomuraTGCell askBeforeCallRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.askBeforeCall));
|
||||
private final NekomuraTGCell autoPauseVideoRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.autoPauseVideo, LocaleController.getString("AutoPauseVideoAbout")));
|
||||
private final NekomuraTGCell disableNumberRoundingRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.disableNumberRounding, "4.8K -> 4777"));
|
||||
private final NekomuraTGCell openArchiveOnPullRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.openArchiveOnPull));
|
||||
private final NekomuraTGCell nameOrderRow = addNekomuraTGCell(nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.nameOrder, new String[]{
|
||||
private final NekomuraTGCell header7 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("General")));
|
||||
private final NekomuraTGCell disableUndoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableUndo));
|
||||
private final NekomuraTGCell showIdAndDcRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.showIdAndDc));
|
||||
private final NekomuraTGCell inappCameraRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.inappCamera));
|
||||
private final NekomuraTGCell hideProxySponsorChannelRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideProxySponsorChannel));
|
||||
private final NekomuraTGCell askBeforeCallRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.askBeforeCall));
|
||||
private final NekomuraTGCell autoPauseVideoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.autoPauseVideo, LocaleController.getString("AutoPauseVideoAbout")));
|
||||
private final NekomuraTGCell disableNumberRoundingRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableNumberRounding, "4.8K -> 4777"));
|
||||
private final NekomuraTGCell openArchiveOnPullRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.openArchiveOnPull));
|
||||
private final NekomuraTGCell nameOrderRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.nameOrder, new String[]{
|
||||
LocaleController.getString("LastFirst", R.string.LastFirst),
|
||||
LocaleController.getString("FirstLast", R.string.FirstLast)
|
||||
}, null));
|
||||
private final NekomuraTGCell usePersianCalendarRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.usePersianCalendar, LocaleController.getString("UsePersiancalendarInfo")));
|
||||
private final NekomuraTGCell displayPersianCalendarByLatinRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekomuraConfig.displayPersianCalendarByLatin));
|
||||
private final NekomuraTGCell divider7 = addNekomuraTGCell(nkmrCells.new NekomuraTGDivider());
|
||||
private final NekomuraTGCell usePersianCalendarRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.usePersianCalendar, LocaleController.getString("UsePersiancalendarInfo")));
|
||||
private final NekomuraTGCell displayPersianCalendarByLatinRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.displayPersianCalendarByLatin));
|
||||
private final NekomuraTGCell divider7 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
|
||||
private UndoView restartTooltip;
|
||||
@ -212,7 +212,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
|
||||
// Fragment: Set OnClick Callbacks
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
@ -228,7 +228,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
} else if (a instanceof NekomuraTGCustom) { // Custom OnClick
|
||||
if (position == rows.indexOf(pgpAppRow)) {
|
||||
if (position == cellGroup.rows.indexOf(pgpAppRow)) {
|
||||
PopupBuilder builder = new PopupBuilder(view);
|
||||
|
||||
builder.addSubItem(0, LocaleController.getString("None", R.string.None));
|
||||
@ -257,14 +257,14 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
builder.setDelegate((i) -> {
|
||||
NekomuraConfig.openPGPApp.setConfigString(appsMap.get(i));
|
||||
NekomuraConfig.openPGPKeyId.setConfigLong(0L);
|
||||
listAdapter.notifyItemChanged(rows.indexOf(pgpAppRow));
|
||||
listAdapter.notifyItemChanged(rows.indexOf(keyRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(pgpAppRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow));
|
||||
|
||||
if (i > 0) PGPUtil.recreateConnection();
|
||||
});
|
||||
|
||||
builder.show();
|
||||
} else if (position == rows.indexOf(translationProviderRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(translationProviderRow)) {
|
||||
PopupBuilder builder = new PopupBuilder(view);
|
||||
|
||||
builder.setItems(new String[]{
|
||||
@ -275,53 +275,35 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderMicrosoftTranslator),
|
||||
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderYouDao),
|
||||
LocaleController.getString("ProviderMicrosoftTranslator", R.string.ProviderDeepLTranslate)
|
||||
|
||||
}, (i, __) -> {
|
||||
|
||||
boolean needReset = NekomuraConfig.translationProvider.Int() - 1 != i && (NekomuraConfig.translationProvider.Int() == 1 || i == 0);
|
||||
|
||||
NekomuraConfig.translationProvider.setConfigInt(i + 1);
|
||||
|
||||
if (needReset) {
|
||||
|
||||
updateRows(true);
|
||||
|
||||
} else {
|
||||
|
||||
listAdapter.notifyItemChanged(position);
|
||||
|
||||
}
|
||||
|
||||
return Unit.INSTANCE;
|
||||
|
||||
});
|
||||
|
||||
builder.show();
|
||||
} else if (position == rows.indexOf(translateToLangRow) || position == rows.indexOf(translateInputToLangRow)) {
|
||||
Translator.showTargetLangSelect(view, position == rows.indexOf(translateInputToLangRow), (locale) -> {
|
||||
|
||||
if (position == rows.indexOf(translateToLangRow)) {
|
||||
|
||||
} else if (position == cellGroup.rows.indexOf(translateToLangRow) || position == cellGroup.rows.indexOf(translateInputToLangRow)) {
|
||||
Translator.showTargetLangSelect(view, position == cellGroup.rows.indexOf(translateInputToLangRow), (locale) -> {
|
||||
if (position == cellGroup.rows.indexOf(translateToLangRow)) {
|
||||
NekomuraConfig.translateToLang.setConfigString(TranslatorKt.getLocale2code(locale));
|
||||
|
||||
} else {
|
||||
|
||||
NekomuraConfig.translateInputLang.setConfigString(TranslatorKt.getLocale2code(locale));
|
||||
|
||||
}
|
||||
|
||||
listAdapter.notifyItemChanged(position);
|
||||
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
} else if (position == rows.indexOf(nameOrderRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(nameOrderRow)) {
|
||||
LocaleController.getInstance().recreateFormatters();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Cells: Set OnSettingChanged Callbacks
|
||||
nkmrCells.callBackSettingsChanged = (key, newValue) -> {
|
||||
cellGroup.callBackSettingsChanged = (key, newValue) -> {
|
||||
if (key.equals(NekomuraConfig.useIPv6.getKey())) {
|
||||
for (int a : SharedConfig.activeAccounts) {
|
||||
if (UserConfig.getInstance(a).isClientActivated()) {
|
||||
@ -334,7 +316,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
} else if (key.equals(NekomuraConfig.hidePhone.getKey())) {
|
||||
parentLayout.rebuildAllFragmentViews(false, false);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
listAdapter.notifyItemChanged(rows.indexOf(profilePreviewRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
||||
} else if (key.equals(NekomuraConfig.transparentStatusBar.getKey())) {
|
||||
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false));
|
||||
} else if (key.equals(NekomuraConfig.hideProxySponsorChannel.getKey())) {
|
||||
@ -368,10 +350,10 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
} else if (key.equals(NekomuraConfig.avatarBackgroundBlur.getKey())) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
listAdapter.notifyItemChanged(rows.indexOf(profilePreviewRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
||||
} else if (key.equals(NekomuraConfig.avatarBackgroundDarken.getKey())) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
listAdapter.notifyItemChanged(rows.indexOf(profilePreviewRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow));
|
||||
} else if (key.equals(NekomuraConfig.disableAppBarShadow.getKey())) {
|
||||
ActionBarLayout.headerShadowDrawable = (boolean) newValue ? null : parentLayout.getResources().getDrawable(R.drawable.header_shadow).mutate();
|
||||
parentLayout.rebuildAllFragmentViews(true, true);
|
||||
@ -379,7 +361,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
};
|
||||
|
||||
//Cells: Set ListAdapter
|
||||
nkmrCells.setListAdapter(listView, listAdapter);
|
||||
cellGroup.setListAdapter(listView, listAdapter);
|
||||
|
||||
restartTooltip = new UndoView(context);
|
||||
frameLayout.addView(restartTooltip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
||||
@ -387,12 +369,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public NekomuraTGCell addNekomuraTGCell(NekomuraTGCell a) {
|
||||
rows.add(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
private class NkmrDrawerProfilePreviewCell implements NekomuraTGCell {
|
||||
private class NkmrDrawerProfilePreviewCell extends NekomuraTGCell {
|
||||
public int getType() {
|
||||
return 999;
|
||||
}
|
||||
@ -419,7 +396,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L);
|
||||
NekomuraConfig.openPGPKeyId.setConfigLong(keyId);
|
||||
|
||||
listAdapter.notifyItemChanged(rows.indexOf(keyRow));
|
||||
listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow));
|
||||
|
||||
break;
|
||||
}
|
||||
@ -450,13 +427,9 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
if (requestCode == 114 && resultCode == Activity.RESULT_OK) {
|
||||
|
||||
requestKey(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class OpenPgpProviderEntry {
|
||||
@ -625,13 +598,13 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return rows.size();
|
||||
return cellGroup.rows.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
@ -640,22 +613,22 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
return Cells.ITEM_TYPE_TEXT_DETAIL;
|
||||
return CellGroup.ITEM_TYPE_TEXT_DETAIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = rows.get(position);
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
if (holder.itemView instanceof TextSettingsCell) {
|
||||
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
|
||||
if (position == rows.indexOf(translationProviderRow)) {
|
||||
if (position == cellGroup.rows.indexOf(translationProviderRow)) {
|
||||
String value;
|
||||
switch (NekomuraConfig.translationProvider.Int()) {
|
||||
case 1:
|
||||
@ -683,11 +656,11 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
value = "Unknown";
|
||||
}
|
||||
textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true);
|
||||
} else if (position == rows.indexOf(pgpAppRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(pgpAppRow)) {
|
||||
textCell.setTextAndValue(LocaleController.getString("OpenPGPApp", R.string.OpenPGPApp), NekoConfig.getOpenPGPAppName(), true);
|
||||
} else if (position == rows.indexOf(translateToLangRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(translateToLangRow)) {
|
||||
textCell.setTextAndValue(LocaleController.getString("TransToLang", R.string.TransToLang), NekoConfig.formatLang(NekomuraConfig.translateToLang.String()), true);
|
||||
} else if (position == rows.indexOf(translateInputToLangRow)) {
|
||||
} else if (position == cellGroup.rows.indexOf(translateInputToLangRow)) {
|
||||
textCell.setTextAndValue(LocaleController.getString("TransInputToLang", R.string.TransInputToLang), NekoConfig.formatLang(NekomuraConfig.translateInputLang.String()), true);
|
||||
}
|
||||
}
|
||||
@ -703,26 +676,26 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = null;
|
||||
switch (viewType) {
|
||||
case Cells.ITEM_TYPE_DIVIDER:
|
||||
case CellGroup.ITEM_TYPE_DIVIDER:
|
||||
view = new ShadowSectionCell(mContext);
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL:
|
||||
view = new TextSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_CHECK:
|
||||
case CellGroup.ITEM_TYPE_TEXT_CHECK:
|
||||
view = new TextCheckCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_HEADER:
|
||||
case CellGroup.ITEM_TYPE_HEADER:
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT_DETAIL:
|
||||
case CellGroup.ITEM_TYPE_TEXT_DETAIL:
|
||||
view = new TextDetailSettingsCell(mContext);
|
||||
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
break;
|
||||
case Cells.ITEM_TYPE_TEXT:
|
||||
case CellGroup.ITEM_TYPE_TEXT:
|
||||
view = new TextInfoPrivacyCell(mContext);
|
||||
// view.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
break;
|
||||
@ -747,7 +720,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
||||
|
||||
//Custom dialogs
|
||||
|
||||
private void customDialog_BottomInputString(int position, NekomuraConfig.ConfigItem bind, String subtitle, String hint) {
|
||||
private void customDialog_BottomInputString(int position, ConfigItem bind, String subtitle, String hint) {
|
||||
BottomBuilder builder = new BottomBuilder(getParentActivity());
|
||||
|
||||
builder.addTitle(
|
||||
|
111
TMessagesProj/src/main/java/tw/nekomimi/nkmr/CellGroup.java
Normal file
111
TMessagesProj/src/main/java/tw/nekomimi/nkmr/CellGroup.java
Normal file
@ -0,0 +1,111 @@
|
||||
package tw.nekomimi.nkmr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.RadioColorCell;
|
||||
import org.telegram.ui.Cells.TextCheckCell;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import tw.nekomimi.nekogram.settings.NekoGeneralSettingsActivity;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGDivider;
|
||||
|
||||
public class CellGroup {
|
||||
public static final int ITEM_TYPE_DIVIDER = 1;
|
||||
public static final int ITEM_TYPE_TEXT_SETTINGS_CELL = 2;
|
||||
public static final int ITEM_TYPE_TEXT_CHECK = 3;
|
||||
public static final int ITEM_TYPE_HEADER = 4;
|
||||
public static final int ITEM_TYPE_TEXT_DETAIL = 5;
|
||||
public static final int ITEM_TYPE_TEXT = 6;
|
||||
|
||||
public BaseFragment thisFragment;
|
||||
public RecyclerListView listView;
|
||||
public RecyclerListView.SelectionAdapter listAdapter;
|
||||
public ArrayList<NekomuraTGCell> rows;
|
||||
|
||||
public CallBackSettingsChanged callBackSettingsChanged;
|
||||
|
||||
public CellGroup(BaseFragment thisFragment) {
|
||||
this.thisFragment = thisFragment;
|
||||
this.rows = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setListAdapter(RecyclerListView lv, RecyclerListView.SelectionAdapter la) {
|
||||
this.listView = lv;
|
||||
this.listAdapter = la;
|
||||
}
|
||||
|
||||
public NekomuraTGCell appendCell(NekomuraTGCell cell) {
|
||||
cell.bindCellGroup(this);
|
||||
this.rows.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
public NekomuraTGCell appendCell(NekomuraTGCell cell, boolean display) {
|
||||
cell.bindCellGroup(this);
|
||||
if (display)
|
||||
this.rows.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
public interface CallBackSettingsChanged {
|
||||
void run(String key, Object newValue);
|
||||
}
|
||||
|
||||
public void runCallback(String key, Object newValue) {
|
||||
if (callBackSettingsChanged == null) return;
|
||||
try {
|
||||
callBackSettingsChanged.run(key, newValue);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnBindViewHolder {
|
||||
void onBindViewHolder(RecyclerView.ViewHolder holder);
|
||||
}
|
||||
|
||||
//Utils
|
||||
public static void hideItemFromRecyclerView(View cell, boolean hide) {
|
||||
if (cell == null) return;
|
||||
if (cell != null) return; //TODO hideItemFromRecyclerView
|
||||
ViewGroup.LayoutParams params = cell.getLayoutParams();
|
||||
if (hide) {
|
||||
cell.setVisibility(View.GONE);
|
||||
params.height = 0;
|
||||
} else {
|
||||
cell.setVisibility(View.VISIBLE);
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
cell.setLayoutParams(params);
|
||||
}
|
||||
|
||||
public boolean needSetDivider(NekomuraTGCell cell) {
|
||||
return !(rows.get(rows.indexOf(cell) + 1) instanceof NekomuraTGDivider);
|
||||
}
|
||||
|
||||
//TG Cells
|
||||
|
||||
|
||||
//TextDetailSettingsCell
|
||||
|
||||
|
||||
}
|
@ -1,400 +0,0 @@
|
||||
package tw.nekomimi.nkmr;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.RadioColorCell;
|
||||
import org.telegram.ui.Cells.TextCheckCell;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class Cells {
|
||||
public static final int ITEM_TYPE_DIVIDER = 1;
|
||||
public static final int ITEM_TYPE_TEXT_SETTINGS_CELL = 2;
|
||||
public static final int ITEM_TYPE_TEXT_CHECK = 3;
|
||||
public static final int ITEM_TYPE_HEADER = 4;
|
||||
public static final int ITEM_TYPE_TEXT_DETAIL = 5;
|
||||
public static final int ITEM_TYPE_TEXT = 6;
|
||||
|
||||
|
||||
private BaseFragment thisFragment;
|
||||
private RecyclerListView listView;
|
||||
private RecyclerListView.SelectionAdapter listAdapter;
|
||||
private ArrayList<NekomuraTGCell> rows;
|
||||
|
||||
public CallBackSettingsChanged callBackSettingsChanged;
|
||||
|
||||
public Cells(BaseFragment thisFragment, ArrayList<NekomuraTGCell> rows) {
|
||||
this.thisFragment = thisFragment;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void setListAdapter(RecyclerListView lv, RecyclerListView.SelectionAdapter la) {
|
||||
this.listView = lv;
|
||||
this.listAdapter = la;
|
||||
}
|
||||
|
||||
public interface CallBackSettingsChanged {
|
||||
void run(String key, Object newValue);
|
||||
}
|
||||
|
||||
private void runCallback(String key, Object newValue) {
|
||||
if (callBackSettingsChanged == null) return;
|
||||
try {
|
||||
callBackSettingsChanged.run(key, newValue);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnBindViewHolder {
|
||||
void onBindViewHolder(RecyclerView.ViewHolder holder);
|
||||
}
|
||||
|
||||
public interface NekomuraTGCell {
|
||||
int getType();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
void onBindViewHolder(RecyclerView.ViewHolder holder);
|
||||
}
|
||||
|
||||
//Utils
|
||||
|
||||
public static void hideItemFromRecyclerView(View cell, boolean hide) {
|
||||
if (cell == null) return;
|
||||
if (cell != null) return; //TODO hideItemFromRecyclerView
|
||||
ViewGroup.LayoutParams params = cell.getLayoutParams();
|
||||
if (hide) {
|
||||
cell.setVisibility(View.GONE);
|
||||
params.height = 0;
|
||||
} else {
|
||||
cell.setVisibility(View.VISIBLE);
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
cell.setLayoutParams(params);
|
||||
}
|
||||
|
||||
public boolean needSetDivider(NekomuraTGCell cell) {
|
||||
return !(rows.get(rows.indexOf(cell) + 1) instanceof NekomuraTGDivider);
|
||||
}
|
||||
|
||||
//TG Cells
|
||||
|
||||
public class NekomuraTGDivider implements NekomuraTGCell {
|
||||
public int getType() {
|
||||
return ITEM_TYPE_DIVIDER;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
}
|
||||
}
|
||||
|
||||
public class NekomuraTGCustom implements NekomuraTGCell {
|
||||
public final int type;
|
||||
public final boolean enabled;
|
||||
|
||||
public NekomuraTGCustom(int type, boolean enabled) {
|
||||
this.type = type;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
// Not Used
|
||||
}
|
||||
}
|
||||
|
||||
public class NekomuraTGHeader implements NekomuraTGCell {
|
||||
private final String title;
|
||||
|
||||
public NekomuraTGHeader(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return ITEM_TYPE_HEADER;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
||||
headerCell.setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
//TextDetailSettingsCell
|
||||
public class NekomuraTGTextDetail implements NekomuraTGCell {
|
||||
private final NekomuraConfig.ConfigItem bindConfig;
|
||||
private final String title;
|
||||
private final String hint;
|
||||
public final RecyclerListView.OnItemClickListener onItemClickListener;
|
||||
|
||||
public NekomuraTGTextDetail(NekomuraConfig.ConfigItem bind, RecyclerListView.OnItemClickListener onItemClickListener, String hint) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.hint = hint == null ? "" : hint;
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return ITEM_TYPE_TEXT_DETAIL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextDetailSettingsCell cell = (TextDetailSettingsCell) holder.itemView;
|
||||
cell.setTextAndValue(title, StrUtil.isNotBlank(bindConfig.String()) ? bindConfig.String() : hint, needSetDivider(this));
|
||||
}
|
||||
}
|
||||
|
||||
public class NekomuraTGTextCheck implements NekomuraTGCell {
|
||||
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) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.subtitle = null;
|
||||
}
|
||||
|
||||
public NekomuraTGTextCheck(NekomuraConfig.ConfigItem bind, String subtitle) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return ITEM_TYPE_TEXT_CHECK;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextCheckCell cell = (TextCheckCell) holder.itemView;
|
||||
this.cell = cell;
|
||||
if (subtitle == null) {
|
||||
cell.setTextAndCheck(title, bindConfig.Bool(), needSetDivider(this));
|
||||
} else {
|
||||
cell.setTextAndValueAndCheck(title, subtitle, bindConfig.Bool(), true, needSetDivider(this));
|
||||
}
|
||||
cell.setEnabled(enabled, null);
|
||||
}
|
||||
|
||||
public void onClick(TextCheckCell cell) {
|
||||
if (!enabled) return;
|
||||
|
||||
boolean newV = bindConfig.toggleConfigBool();
|
||||
cell.setChecked(newV);
|
||||
|
||||
runCallback(bindConfig.getKey(), newV);
|
||||
}
|
||||
}
|
||||
|
||||
// TextSettingsCell, select from a list
|
||||
// Can be used without select list(custom)
|
||||
public class NekomuraTGSelectBox implements NekomuraTGCell {
|
||||
private final NekomuraConfig.ConfigItem bindConfig;
|
||||
private final String[] selectList; // split by \n
|
||||
private final String title;
|
||||
private Runnable onClickCustom;
|
||||
|
||||
|
||||
// default: customTitle=null customOnClick=null
|
||||
public NekomuraTGSelectBox(String customTitle, NekomuraConfig.ConfigItem bind, Object selectList_s, Runnable customOnClick) {
|
||||
this.bindConfig = bind;
|
||||
if (selectList_s == null) {
|
||||
this.selectList = null;
|
||||
} else if (selectList_s instanceof String) {
|
||||
this.selectList = ((String) selectList_s).split("\n");
|
||||
} else if (selectList_s instanceof String[]) {
|
||||
this.selectList = (String[]) selectList_s;
|
||||
} else {
|
||||
this.selectList = null;
|
||||
}
|
||||
if (customTitle == null) {
|
||||
title = LocaleController.getString(bindConfig.getKey());
|
||||
} else {
|
||||
title = customTitle;
|
||||
}
|
||||
this.onClickCustom = customOnClick;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return ITEM_TYPE_TEXT_SETTINGS_CELL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
|
||||
String valueText = "";
|
||||
if (selectList != null && bindConfig.Int() < selectList.length) {
|
||||
valueText = selectList[bindConfig.Int()];
|
||||
}
|
||||
cell.setTextAndValue(title, valueText, needSetDivider(this));
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
if (onClickCustom != null) {
|
||||
try {
|
||||
onClickCustom.run();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = thisFragment.getParentActivity();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); //TODO Replace with pop-up menu
|
||||
builder.setTitle(LocaleController.getString(bindConfig.getKey()));
|
||||
final LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
builder.setView(linearLayout);
|
||||
|
||||
for (int i = 0; i < selectList.length; i++) {
|
||||
RadioColorCell cell = new RadioColorCell(context);
|
||||
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
cell.setTag(i);
|
||||
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
|
||||
cell.setTextAndValue(selectList[i], bindConfig.Int() == i);
|
||||
linearLayout.addView(cell);
|
||||
cell.setOnClickListener(v -> {
|
||||
Integer which = (Integer) v.getTag();
|
||||
bindConfig.setConfigInt(which);
|
||||
|
||||
listAdapter.notifyItemChanged(rows.indexOf(this));
|
||||
builder.getDismissRunnable().run();
|
||||
thisFragment.parentLayout.rebuildAllFragmentViews(false, false);
|
||||
|
||||
runCallback(bindConfig.getKey(), which);
|
||||
});
|
||||
}
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
thisFragment.showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
|
||||
public class NekomuraTGTextInput implements NekomuraTGCell {
|
||||
private final NekomuraConfig.ConfigItem bindConfig;
|
||||
private final String hint;
|
||||
private final String title;
|
||||
private Runnable onClickCustom;
|
||||
|
||||
|
||||
// default: customTitle=null customOnClick=null
|
||||
public NekomuraTGTextInput(String customTitle, NekomuraConfig.ConfigItem bind, String hint, Runnable customOnClick) {
|
||||
this.bindConfig = bind;
|
||||
if (hint == null) {
|
||||
this.hint = "";
|
||||
} else {
|
||||
this.hint = hint;
|
||||
}
|
||||
if (customTitle == null) {
|
||||
title = LocaleController.getString(bindConfig.getKey());
|
||||
} else {
|
||||
title = customTitle;
|
||||
}
|
||||
this.onClickCustom = customOnClick;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return ITEM_TYPE_TEXT_SETTINGS_CELL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
|
||||
cell.setTextAndValue(title, bindConfig.String(), needSetDivider(this));
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
if (onClickCustom != null) {
|
||||
try {
|
||||
onClickCustom.run();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = thisFragment.getParentActivity();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(LocaleController.getString(bindConfig.getKey()));
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
EditTextBoldCursor editText = new EditTextBoldCursor(context);
|
||||
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
editText.setHint(hint);
|
||||
editText.setText(bindConfig.String());
|
||||
linearLayout.addView(editText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(10), 0));
|
||||
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (d, v) -> {
|
||||
String newV = editText.getText().toString();
|
||||
bindConfig.setConfigString(newV);
|
||||
|
||||
//refresh
|
||||
listAdapter.notifyItemChanged(rows.indexOf(this));
|
||||
builder.getDismissRunnable().run();
|
||||
thisFragment.parentLayout.rebuildAllFragmentViews(false, false);
|
||||
|
||||
runCallback(bindConfig.getKey(), newV);
|
||||
});
|
||||
builder.setView(linearLayout);
|
||||
thisFragment.showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
}
|
133
TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java
Normal file
133
TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java
Normal file
@ -0,0 +1,133 @@
|
||||
package tw.nekomimi.nkmr;
|
||||
|
||||
import static tw.nekomimi.nkmr.NekomuraConfig.saveConfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class ConfigItem {
|
||||
String key;
|
||||
int type;
|
||||
|
||||
Object defaultValue;
|
||||
Object value;
|
||||
boolean forceDefault;//针对某些人的垃圾选项,应该不允许改变默认值
|
||||
|
||||
ConfigItem(String k, int t, Object d) {
|
||||
key = k;
|
||||
type = t;
|
||||
defaultValue = d;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
// 读配置
|
||||
|
||||
public boolean Bool() {
|
||||
return (boolean) value;
|
||||
}
|
||||
|
||||
public int Int() {
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
public Long Long() {
|
||||
return (Long) value;
|
||||
}
|
||||
|
||||
public Float Float() {
|
||||
return (Float) value;
|
||||
}
|
||||
|
||||
public String String() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public HashSet<Integer> SetInt() {
|
||||
return (HashSet<Integer>) value;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> MapIntInt() {
|
||||
return (HashMap<Integer, Integer>) value;
|
||||
}
|
||||
|
||||
public boolean SetIntContains(Integer v) {
|
||||
return ((HashSet<Integer>) value).contains(v);
|
||||
}
|
||||
|
||||
|
||||
public void changed(Object o) {
|
||||
value = o;
|
||||
}
|
||||
|
||||
//写配置
|
||||
//这里没有检查类型哦
|
||||
|
||||
public boolean toggleConfigBool() {
|
||||
value = !this.Bool();
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
return this.Bool();//返回toggle之后的
|
||||
}
|
||||
|
||||
public void setConfigBool(boolean v) {
|
||||
value = v;
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigInt(int v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigLong(Long v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigFloat(Float v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigString(String v) {
|
||||
if (v == null) {
|
||||
value = "";
|
||||
} else {
|
||||
value = v;
|
||||
}
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigSetInt(HashSet<Integer> v) {
|
||||
value = v;
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigMapInt(HashMap<Integer, Integer> v) {
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package tw.nekomimi.nkmr;
|
||||
|
||||
import static tw.nekomimi.nekogram.NekoConfig.TITLE_TYPE_TEXT;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@ -21,6 +19,8 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
@SuppressLint("ApplySharedPref")
|
||||
public class NekomuraConfig {
|
||||
private static final int configTypeBool = 0;
|
||||
@ -31,133 +31,6 @@ public class NekomuraConfig {
|
||||
private static final int configTypeLong = 5;
|
||||
private static final int configTypeFloat = 6;
|
||||
|
||||
public static class ConfigItem {
|
||||
private String key;
|
||||
private int type;
|
||||
|
||||
private Object defaultValue;
|
||||
private Object value;
|
||||
private boolean forceDefault;//针对某些人的垃圾选项,应该不允许改变默认值
|
||||
|
||||
private ConfigItem(String k, int t, Object d) {
|
||||
key = k;
|
||||
type = t;
|
||||
defaultValue = d;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
// 读配置
|
||||
|
||||
public boolean Bool() {
|
||||
return (boolean) value;
|
||||
}
|
||||
|
||||
public int Int() {
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
public Long Long() {
|
||||
return (Long) value;
|
||||
}
|
||||
|
||||
public Float Float() {
|
||||
return (Float) value;
|
||||
}
|
||||
|
||||
public String String() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public HashSet<Integer> SetInt() {
|
||||
return (HashSet<Integer>) value;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> MapIntInt() {
|
||||
return (HashMap<Integer, Integer>) value;
|
||||
}
|
||||
|
||||
public boolean SetIntContains(Integer v) {
|
||||
return ((HashSet<Integer>) value).contains(v);
|
||||
}
|
||||
|
||||
|
||||
public void changed(Object o) {
|
||||
value = o;
|
||||
}
|
||||
|
||||
//写配置
|
||||
//这里没有检查类型哦
|
||||
|
||||
public boolean toggleConfigBool() {
|
||||
value = !this.Bool();
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
return this.Bool();//返回toggle之后的
|
||||
}
|
||||
|
||||
public void setConfigBool(boolean v) {
|
||||
value = v;
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigInt(int v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigLong(Long v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigFloat(Float v) {
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigString(String v) {
|
||||
if (v == null) {
|
||||
value = "";
|
||||
} else {
|
||||
value = v;
|
||||
}
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigSetInt(HashSet<Integer> v) {
|
||||
value = v;
|
||||
if (forceDefault) {
|
||||
value = defaultValue;
|
||||
}
|
||||
saveConfig(this);
|
||||
}
|
||||
|
||||
public void setConfigMapInt(HashMap<Integer, Integer> v) {
|
||||
value = v;
|
||||
saveConfig(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean configLoaded;
|
||||
private static final Object sync = new Object();
|
||||
private static final ArrayList<ConfigItem> configs = new ArrayList<>();
|
||||
@ -247,7 +120,7 @@ public class NekomuraConfig {
|
||||
public static ConfigItem ccToLang = addConfig("opencc_to_lang", configTypeString, "");
|
||||
public static ConfigItem ccInputLang = addConfig("opencc_input_to_lang", configTypeString, "");
|
||||
|
||||
public static ConfigItem tabsTitleType = addConfig("TabTitleType", configTypeInt, TITLE_TYPE_TEXT);
|
||||
public static ConfigItem tabsTitleType = addConfig("TabTitleType", configTypeInt, NekoConfig.TITLE_TYPE_TEXT);
|
||||
public static ConfigItem confirmAVMessage = addConfig("ConfirmAVMessage", configTypeBool, false);
|
||||
public static ConfigItem askBeforeCall = addConfig("AskBeforeCalling", configTypeBool, false);
|
||||
public static ConfigItem disableNumberRounding = addConfig("DisableNumberRounding", configTypeBool, false);
|
||||
@ -297,226 +170,7 @@ public class NekomuraConfig {
|
||||
|
||||
static {
|
||||
loadConfig(false);
|
||||
|
||||
// TODO remove this after some versions.
|
||||
if (!migrate.Bool()) {
|
||||
migrate.setConfigBool(true);
|
||||
|
||||
// NekoConfig.java read & migrate
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
|
||||
if (preferences.contains("typeface"))
|
||||
typeface.setConfigBool(preferences.getInt("typeface", 0) != 0);
|
||||
if (preferences.contains("nameOrder"))
|
||||
nameOrder.setConfigInt(preferences.getInt("nameOrder", 1));
|
||||
if (preferences.contains("mapPreviewProvider"))
|
||||
mapPreviewProvider.setConfigInt(preferences.getInt("mapPreviewProvider", 0));
|
||||
if (preferences.contains("transparentStatusBar"))
|
||||
transparentStatusBar.setConfigBool(preferences.getBoolean("transparentStatusBar", false));
|
||||
if (preferences.contains("residentNotification"))
|
||||
residentNotification.setConfigBool(preferences.getBoolean("residentNotification", false));
|
||||
if (preferences.contains("hideProxySponsorChannel"))
|
||||
hideProxySponsorChannel.setConfigBool(preferences.getBoolean("hideProxySponsorChannel", false));
|
||||
if (preferences.contains("showAddToSavedMessages"))
|
||||
showAddToSavedMessages.setConfigBool(preferences.getBoolean("showAddToSavedMessages", true));
|
||||
if (preferences.contains("showReport"))
|
||||
showReport.setConfigBool(preferences.getBoolean("showReport", true));
|
||||
if (preferences.contains("showViewHistory"))
|
||||
showViewHistory.setConfigBool(preferences.getBoolean("showViewHistory", true));
|
||||
if (preferences.contains("showAdminActions"))
|
||||
showAdminActions.setConfigBool(preferences.getBoolean("showAdminActions", true));
|
||||
if (preferences.contains("showChangePermissions"))
|
||||
showChangePermissions.setConfigBool(preferences.getBoolean("showChangePermissions", true));
|
||||
if (preferences.contains("showDeleteDownloadedFile"))
|
||||
showDeleteDownloadedFile.setConfigBool(preferences.getBoolean("showDeleteDownloadedFile", true));
|
||||
if (preferences.contains("showMessageDetails"))
|
||||
showMessageDetails.setConfigBool(preferences.getBoolean("showMessageDetails", false));
|
||||
if (preferences.contains("showTranslate"))
|
||||
showTranslate.setConfigBool(preferences.getBoolean("showTranslate", true));
|
||||
if (preferences.contains("showRepeat"))
|
||||
showRepeat.setConfigBool(preferences.getBoolean("showRepeat", false));
|
||||
if (preferences.contains("showMessageHide"))
|
||||
showMessageHide.setConfigBool(preferences.getBoolean("showMessageHide", false));
|
||||
|
||||
if (preferences.contains("eventType"))
|
||||
eventType.setConfigInt(preferences.getInt("eventType", 0));
|
||||
if (preferences.contains("actionBarDecoration"))
|
||||
actionBarDecoration.setConfigInt(preferences.getInt("actionBarDecoration", 0));
|
||||
if (preferences.contains("newYear"))
|
||||
newYear.setConfigBool(preferences.getBoolean("newYear", false));
|
||||
if (preferences.contains("stickerSize"))
|
||||
stickerSize.setConfigFloat(preferences.getFloat("stickerSize", 14.0f));
|
||||
if (preferences.contains("unlimitedFavedStickers"))
|
||||
unlimitedFavedStickers.setConfigBool(preferences.getBoolean("unlimitedFavedStickers", false));
|
||||
if (preferences.contains("unlimitedPinnedDialogs"))
|
||||
unlimitedPinnedDialogs.setConfigBool(preferences.getBoolean("unlimitedPinnedDialogs", false));
|
||||
if (preferences.contains("translationProvider"))
|
||||
translationProvider.setConfigInt(preferences.getInt("translationProvider", 1));
|
||||
if (preferences.contains("disablePhotoSideAction"))
|
||||
disablePhotoSideAction.setConfigBool(preferences.getBoolean("disablePhotoSideAction", true));
|
||||
if (preferences.contains("openArchiveOnPull"))
|
||||
openArchiveOnPull.setConfigBool(preferences.getBoolean("openArchiveOnPull", false));
|
||||
if (preferences.contains("showHiddenFeature")) //showHiddenFeature.setConfigBool(preferences.getBoolean("showHiddenFeature", false));
|
||||
if (preferences.contains("hideKeyboardOnChatScroll"))
|
||||
hideKeyboardOnChatScroll.setConfigBool(preferences.getBoolean("hideKeyboardOnChatScroll", false));
|
||||
if (preferences.contains("avatarBackgroundBlur"))
|
||||
avatarBackgroundBlur.setConfigBool(preferences.getBoolean("avatarBackgroundBlur", false));
|
||||
if (preferences.contains("avatarBackgroundDarken"))
|
||||
avatarBackgroundDarken.setConfigBool(preferences.getBoolean("avatarBackgroundDarken", false));
|
||||
if (preferences.contains("useSystemEmoji"))
|
||||
useSystemEmoji.setConfigBool(preferences.getBoolean("useSystemEmoji", false));
|
||||
if (preferences.contains("showTabsOnForward"))
|
||||
showTabsOnForward.setConfigBool(preferences.getBoolean("showTabsOnForward", false));
|
||||
if (preferences.contains("rearVideoMessages"))
|
||||
rearVideoMessages.setConfigBool(preferences.getBoolean("rearVideoMessages", false));
|
||||
if (preferences.contains("hideAllTab"))
|
||||
hideAllTab.setConfigBool(preferences.getBoolean("hideAllTab", false));
|
||||
if (preferences.contains("pressTitleToOpenAllChats"))
|
||||
pressTitleToOpenAllChats.setConfigBool(preferences.getBoolean("pressTitleToOpenAllChats", false));
|
||||
|
||||
if (preferences.contains("disable_chat_action"))
|
||||
disableChatAction.setConfigBool(preferences.getBoolean("disable_chat_action", false));
|
||||
if (preferences.contains("sort_by_unread"))
|
||||
sortByUnread.setConfigBool(preferences.getBoolean("sort_by_unread", false));
|
||||
if (preferences.contains("sort_by_unmuted"))
|
||||
sortByUnmuted.setConfigBool(preferences.getBoolean("sort_by_unmuted", true));
|
||||
if (preferences.contains("sort_by_user"))
|
||||
sortByUser.setConfigBool(preferences.getBoolean("sort_by_user", true));
|
||||
if (preferences.contains("sort_by_contacts"))
|
||||
sortByContacts.setConfigBool(preferences.getBoolean("sort_by_contacts", true));
|
||||
|
||||
if (preferences.contains("disable_undo"))
|
||||
disableUndo.setConfigBool(preferences.getBoolean("disable_undo", false));
|
||||
|
||||
if (preferences.contains("filter_users"))
|
||||
filterUsers.setConfigBool(preferences.getBoolean("filter_users", true));
|
||||
if (preferences.contains("filter_contacts"))
|
||||
filterContacts.setConfigBool(preferences.getBoolean("filter_contacts", true));
|
||||
if (preferences.contains("filter_groups"))
|
||||
filterGroups.setConfigBool(preferences.getBoolean("filter_groups", true));
|
||||
if (preferences.contains("filter_channels"))
|
||||
filterChannels.setConfigBool(preferences.getBoolean("filter_channels", true));
|
||||
if (preferences.contains("filter_bots"))
|
||||
filterBots.setConfigBool(preferences.getBoolean("filter_bots", true));
|
||||
if (preferences.contains("filter_admins"))
|
||||
filterAdmins.setConfigBool(preferences.getBoolean("filter_admins", true));
|
||||
if (preferences.contains("filter_unmuted"))
|
||||
filterUnmuted.setConfigBool(preferences.getBoolean("filter_unmuted", true));
|
||||
if (preferences.contains("filter_unread"))
|
||||
filterUnread.setConfigBool(preferences.getBoolean("filter_unread", true));
|
||||
if (preferences.contains("filter_unmuted_and_unread"))
|
||||
filterUnmutedAndUnread.setConfigBool(preferences.getBoolean("filter_unmuted_and_unread", true));
|
||||
|
||||
if (preferences.contains("disable_system_account"))
|
||||
disableSystemAccount.setConfigBool(preferences.getBoolean("disable_system_account", false));
|
||||
if (preferences.contains("disable_proxy_when_vpn_enabled"))
|
||||
disableProxyWhenVpnEnabled.setConfigBool(preferences.getBoolean("disable_proxy_when_vpn_enabled", false));
|
||||
if (preferences.contains("skip_open_link_confirm"))
|
||||
skipOpenLinkConfirm.setConfigBool(preferences.getBoolean("skip_open_link_confirm", false));
|
||||
|
||||
if (preferences.contains("ignore_muted_count"))
|
||||
ignoreMutedCount.setConfigBool(preferences.getBoolean("ignore_muted_count", true));
|
||||
if (preferences.contains("use_default_theme"))
|
||||
useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false));
|
||||
if (preferences.contains("show_id_and_dc"))
|
||||
showIdAndDc.setConfigBool(preferences.getBoolean("show_id_and_dc", false));
|
||||
|
||||
if (preferences.contains("google_cloud_translate_key"))
|
||||
googleCloudTranslateKey.setConfigString(preferences.getString("google_cloud_translate_key", null));
|
||||
if (preferences.contains("cache_path"))
|
||||
cachePath.setConfigString(preferences.getString("cache_path", null));
|
||||
|
||||
if (preferences.contains("trans_to_lang"))
|
||||
translateToLang.setConfigString(preferences.getString("trans_to_lang", ""));
|
||||
if (preferences.contains("trans_input_to_lang"))
|
||||
translateInputLang.setConfigString(preferences.getString("trans_input_to_lang", "en"));
|
||||
|
||||
if (preferences.contains("opencc_to_lang"))
|
||||
ccToLang.setConfigString(preferences.getString("opencc_to_lang", null));
|
||||
if (preferences.contains("opencc_input_to_lang"))
|
||||
ccInputLang.setConfigString(preferences.getString("opencc_input_to_lang", null));
|
||||
|
||||
if (preferences.contains("tabsTitleType"))
|
||||
tabsTitleType.setConfigInt(preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT));
|
||||
if (preferences.contains("confirmAVMessage"))
|
||||
confirmAVMessage.setConfigBool(preferences.getBoolean("confirmAVMessage", false));
|
||||
if (preferences.contains("askBeforeCall"))
|
||||
askBeforeCall.setConfigBool(preferences.getBoolean("askBeforeCall", false));
|
||||
if (preferences.contains("disableNumberRounding"))
|
||||
disableNumberRounding.setConfigBool(preferences.getBoolean("disableNumberRounding", false));
|
||||
|
||||
if (preferences.contains("useSystemDNS"))
|
||||
useSystemDNS.setConfigBool(preferences.getBoolean("useSystemDNS", false));
|
||||
if (preferences.contains("customDoH"))
|
||||
customDoH.setConfigString(preferences.getString("customDoH", ""));
|
||||
if (preferences.contains("hide_proxy_by_default"))
|
||||
hideProxyByDefault.setConfigBool(preferences.getBoolean("hide_proxy_by_default", false));
|
||||
if (preferences.contains("use_proxy_item"))
|
||||
useProxyItem.setConfigBool(preferences.getBoolean("use_proxy_item", true));
|
||||
|
||||
if (preferences.contains("disableAppBarShadow"))
|
||||
disableAppBarShadow.setConfigBool(preferences.getBoolean("disableAppBarShadow", false));
|
||||
if (preferences.contains("mediaPreview"))
|
||||
mediaPreview.setConfigBool(preferences.getBoolean("mediaPreview", true));
|
||||
|
||||
if (preferences.contains("proxy_auto_switch"))
|
||||
proxyAutoSwitch.setConfigBool(preferences.getBoolean("proxy_auto_switch", false));
|
||||
|
||||
if (preferences.contains("openPGPApp"))
|
||||
openPGPApp.setConfigString(preferences.getString("openPGPApp", ""));
|
||||
if (preferences.contains("openPGPKeyId"))
|
||||
openPGPKeyId.setConfigLong(preferences.getLong("openPGPKeyId", 0L));
|
||||
|
||||
if (preferences.contains("disableVibration"))
|
||||
disableVibration.setConfigBool(preferences.getBoolean("disableVibration", false));
|
||||
if (preferences.contains("autoPauseVideo"))
|
||||
autoPauseVideo.setConfigBool(preferences.getBoolean("autoPauseVideo", false));
|
||||
if (preferences.contains("disableProximityEvents"))
|
||||
disableProximityEvents.setConfigBool(preferences.getBoolean("disableProximityEvents", false));
|
||||
|
||||
if (preferences.contains("ignoreContentRestrictions"))
|
||||
ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay));
|
||||
if (preferences.contains("useChatAttachMediaMenu"))
|
||||
useChatAttachMediaMenu.setConfigBool(preferences.getBoolean("useChatAttachMediaMenu", true));
|
||||
if (preferences.contains("disableLinkPreviewByDefault"))
|
||||
disableLinkPreviewByDefault.setConfigBool(preferences.getBoolean("disableLinkPreviewByDefault", false));
|
||||
if (preferences.contains("sendCommentAfterForward"))
|
||||
sendCommentAfterForward.setConfigBool(preferences.getBoolean("sendCommentAfterForward", true));
|
||||
if (preferences.contains("increaseVoiceMessageQuality"))
|
||||
increaseVoiceMessageQuality.setConfigBool(preferences.getBoolean("increaseVoiceMessageQuality", true));
|
||||
if (preferences.contains("acceptSecretChat"))
|
||||
acceptSecretChat.setConfigBool(preferences.getBoolean("acceptSecretChat", true));
|
||||
if (preferences.contains("disableTrending"))
|
||||
disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true));
|
||||
if (preferences.contains("dontSendGreetingSticker"))
|
||||
dontSendGreetingSticker.setConfigBool(preferences.getBoolean("dontSendGreetingSticker", false));
|
||||
if (preferences.contains("hideTimeForSticker"))
|
||||
hideTimeForSticker.setConfigBool(preferences.getBoolean("hideTimeForSticker", false));
|
||||
if (preferences.contains("takeGIFasVideo"))
|
||||
takeGIFasVideo.setConfigBool(preferences.getBoolean("takeGIFasVideo", false));
|
||||
if (preferences.contains("maxRecentStickerCount"))
|
||||
maxRecentStickerCount.setConfigInt(preferences.getInt("maxRecentStickerCount", 20));
|
||||
if (preferences.contains("disableSwipeToNext"))
|
||||
disableSwipeToNext.setConfigBool(preferences.getBoolean("disableSwipeToNext", true));
|
||||
if (preferences.contains("disableRemoteEmojiInteractions"))
|
||||
disableRemoteEmojiInteractions.setConfigBool(preferences.getBoolean("disableRemoteEmojiInteractions", true));
|
||||
if (preferences.contains("disableChoosingSticker"))
|
||||
disableChoosingSticker.setConfigBool(preferences.getBoolean("disableChoosingSticker", false));
|
||||
|
||||
if (preferences.contains("disableAutoDownloadingWin32Executable"))
|
||||
disableAutoDownloadingWin32Executable.setConfigBool(preferences.getBoolean("disableAutoDownloadingWin32Executable", true));
|
||||
if (preferences.contains("disableAutoDownloadingArchive"))
|
||||
disableAutoDownloadingArchive.setConfigBool(preferences.getBoolean("disableAutoDownloadingArchive", true));
|
||||
|
||||
if (preferences.contains("enableStickerPin"))
|
||||
enableStickerPin.setConfigBool(preferences.getBoolean("enableStickerPin", false));
|
||||
if (preferences.contains("useMediaStreamInVoip"))
|
||||
useMediaStreamInVoip.setConfigBool(preferences.getBoolean("useMediaStreamInVoip", false));
|
||||
if (preferences.contains("customAudioBitrate"))
|
||||
customAudioBitrate.setConfigInt(preferences.getInt("customAudioBitrate", 32));
|
||||
if (preferences.contains("disableGroupVoipAudioProcessing"))
|
||||
disableGroupVoipAudioProcessing.setConfigBool(preferences.getBoolean("disableGroupVoipAudioProcessing", false));
|
||||
}
|
||||
checkMigrage(false);
|
||||
}
|
||||
|
||||
public static ConfigItem addConfig(String k, int t, Object d) {
|
||||
@ -598,42 +252,42 @@ public class NekomuraConfig {
|
||||
}
|
||||
|
||||
// save one item
|
||||
public static void saveConfig(ConfigItem o) {
|
||||
public static void saveConfig(ConfigItem item) {
|
||||
synchronized (sync) {
|
||||
try {
|
||||
if (o == null) return;
|
||||
if (item == null) return;
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nkmrcfg", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
if (o.type == configTypeBool) {
|
||||
editor.putBoolean(o.key, (boolean) o.value);
|
||||
if (item.type == configTypeBool) {
|
||||
editor.putBoolean(item.key, (boolean) item.value);
|
||||
}
|
||||
if (o.type == configTypeInt) {
|
||||
editor.putInt(o.key, (int) o.value);
|
||||
if (item.type == configTypeInt) {
|
||||
editor.putInt(item.key, (int) item.value);
|
||||
}
|
||||
if (o.type == configTypeLong) {
|
||||
editor.putLong(o.key, (Long) o.value);
|
||||
if (item.type == configTypeLong) {
|
||||
editor.putLong(item.key, (Long) item.value);
|
||||
}
|
||||
if (o.type == configTypeFloat) {
|
||||
editor.putFloat(o.key, (Float) o.value);
|
||||
if (item.type == configTypeFloat) {
|
||||
editor.putFloat(item.key, (Float) item.value);
|
||||
}
|
||||
if (o.type == configTypeString) {
|
||||
editor.putString(o.key, o.value.toString());
|
||||
if (item.type == configTypeString) {
|
||||
editor.putString(item.key, item.value.toString());
|
||||
}
|
||||
if (o.type == configTypeSetInt) {
|
||||
if (item.type == configTypeSetInt) {
|
||||
HashSet<String> ss = new HashSet<>();
|
||||
for (Integer n : (Set<Integer>) o.value) {
|
||||
for (Integer n : (Set<Integer>) item.value) {
|
||||
ss.add(Integer.toString(n));
|
||||
}
|
||||
editor.putStringSet(o.key, ss);
|
||||
editor.putStringSet(item.key, ss);
|
||||
}
|
||||
if (o.type == configTypeMapIntInt) {
|
||||
if (item.type == configTypeMapIntInt) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(o.value);
|
||||
oos.writeObject(item.value);
|
||||
oos.close();
|
||||
editor.putString(o.key, Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString(item.key, Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT));
|
||||
}
|
||||
|
||||
editor.commit();
|
||||
@ -642,4 +296,228 @@ public class NekomuraConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkMigrage(boolean force) {
|
||||
// TODO remove this after some versions.
|
||||
if (migrate.Bool() || force)
|
||||
return;
|
||||
|
||||
migrate.setConfigBool(true);
|
||||
|
||||
// NekoConfig.java read & migrate
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
|
||||
if (preferences.contains("typeface"))
|
||||
typeface.setConfigBool(preferences.getInt("typeface", 0) != 0);
|
||||
if (preferences.contains("nameOrder"))
|
||||
nameOrder.setConfigInt(preferences.getInt("nameOrder", 1));
|
||||
if (preferences.contains("mapPreviewProvider"))
|
||||
mapPreviewProvider.setConfigInt(preferences.getInt("mapPreviewProvider", 0));
|
||||
if (preferences.contains("transparentStatusBar"))
|
||||
transparentStatusBar.setConfigBool(preferences.getBoolean("transparentStatusBar", false));
|
||||
if (preferences.contains("residentNotification"))
|
||||
residentNotification.setConfigBool(preferences.getBoolean("residentNotification", false));
|
||||
if (preferences.contains("hideProxySponsorChannel"))
|
||||
hideProxySponsorChannel.setConfigBool(preferences.getBoolean("hideProxySponsorChannel", false));
|
||||
if (preferences.contains("showAddToSavedMessages"))
|
||||
showAddToSavedMessages.setConfigBool(preferences.getBoolean("showAddToSavedMessages", true));
|
||||
if (preferences.contains("showReport"))
|
||||
showReport.setConfigBool(preferences.getBoolean("showReport", true));
|
||||
if (preferences.contains("showViewHistory"))
|
||||
showViewHistory.setConfigBool(preferences.getBoolean("showViewHistory", true));
|
||||
if (preferences.contains("showAdminActions"))
|
||||
showAdminActions.setConfigBool(preferences.getBoolean("showAdminActions", true));
|
||||
if (preferences.contains("showChangePermissions"))
|
||||
showChangePermissions.setConfigBool(preferences.getBoolean("showChangePermissions", true));
|
||||
if (preferences.contains("showDeleteDownloadedFile"))
|
||||
showDeleteDownloadedFile.setConfigBool(preferences.getBoolean("showDeleteDownloadedFile", true));
|
||||
if (preferences.contains("showMessageDetails"))
|
||||
showMessageDetails.setConfigBool(preferences.getBoolean("showMessageDetails", false));
|
||||
if (preferences.contains("showTranslate"))
|
||||
showTranslate.setConfigBool(preferences.getBoolean("showTranslate", true));
|
||||
if (preferences.contains("showRepeat"))
|
||||
showRepeat.setConfigBool(preferences.getBoolean("showRepeat", false));
|
||||
if (preferences.contains("showMessageHide"))
|
||||
showMessageHide.setConfigBool(preferences.getBoolean("showMessageHide", false));
|
||||
|
||||
if (preferences.contains("eventType"))
|
||||
eventType.setConfigInt(preferences.getInt("eventType", 0));
|
||||
if (preferences.contains("actionBarDecoration"))
|
||||
actionBarDecoration.setConfigInt(preferences.getInt("actionBarDecoration", 0));
|
||||
if (preferences.contains("newYear"))
|
||||
newYear.setConfigBool(preferences.getBoolean("newYear", false));
|
||||
if (preferences.contains("stickerSize"))
|
||||
stickerSize.setConfigFloat(preferences.getFloat("stickerSize", 14.0f));
|
||||
if (preferences.contains("unlimitedFavedStickers"))
|
||||
unlimitedFavedStickers.setConfigBool(preferences.getBoolean("unlimitedFavedStickers", false));
|
||||
if (preferences.contains("unlimitedPinnedDialogs"))
|
||||
unlimitedPinnedDialogs.setConfigBool(preferences.getBoolean("unlimitedPinnedDialogs", false));
|
||||
if (preferences.contains("translationProvider"))
|
||||
translationProvider.setConfigInt(preferences.getInt("translationProvider", 1));
|
||||
if (preferences.contains("disablePhotoSideAction"))
|
||||
disablePhotoSideAction.setConfigBool(preferences.getBoolean("disablePhotoSideAction", true));
|
||||
if (preferences.contains("openArchiveOnPull"))
|
||||
openArchiveOnPull.setConfigBool(preferences.getBoolean("openArchiveOnPull", false));
|
||||
if (preferences.contains("showHiddenFeature")) //showHiddenFeature.setConfigBool(preferences.getBoolean("showHiddenFeature", false));
|
||||
if (preferences.contains("hideKeyboardOnChatScroll"))
|
||||
hideKeyboardOnChatScroll.setConfigBool(preferences.getBoolean("hideKeyboardOnChatScroll", false));
|
||||
if (preferences.contains("avatarBackgroundBlur"))
|
||||
avatarBackgroundBlur.setConfigBool(preferences.getBoolean("avatarBackgroundBlur", false));
|
||||
if (preferences.contains("avatarBackgroundDarken"))
|
||||
avatarBackgroundDarken.setConfigBool(preferences.getBoolean("avatarBackgroundDarken", false));
|
||||
if (preferences.contains("useSystemEmoji"))
|
||||
useSystemEmoji.setConfigBool(preferences.getBoolean("useSystemEmoji", false));
|
||||
if (preferences.contains("showTabsOnForward"))
|
||||
showTabsOnForward.setConfigBool(preferences.getBoolean("showTabsOnForward", false));
|
||||
if (preferences.contains("rearVideoMessages"))
|
||||
rearVideoMessages.setConfigBool(preferences.getBoolean("rearVideoMessages", false));
|
||||
if (preferences.contains("hideAllTab"))
|
||||
hideAllTab.setConfigBool(preferences.getBoolean("hideAllTab", false));
|
||||
if (preferences.contains("pressTitleToOpenAllChats"))
|
||||
pressTitleToOpenAllChats.setConfigBool(preferences.getBoolean("pressTitleToOpenAllChats", false));
|
||||
|
||||
if (preferences.contains("disable_chat_action"))
|
||||
disableChatAction.setConfigBool(preferences.getBoolean("disable_chat_action", false));
|
||||
if (preferences.contains("sort_by_unread"))
|
||||
sortByUnread.setConfigBool(preferences.getBoolean("sort_by_unread", false));
|
||||
if (preferences.contains("sort_by_unmuted"))
|
||||
sortByUnmuted.setConfigBool(preferences.getBoolean("sort_by_unmuted", true));
|
||||
if (preferences.contains("sort_by_user"))
|
||||
sortByUser.setConfigBool(preferences.getBoolean("sort_by_user", true));
|
||||
if (preferences.contains("sort_by_contacts"))
|
||||
sortByContacts.setConfigBool(preferences.getBoolean("sort_by_contacts", true));
|
||||
|
||||
if (preferences.contains("disable_undo"))
|
||||
disableUndo.setConfigBool(preferences.getBoolean("disable_undo", false));
|
||||
|
||||
if (preferences.contains("filter_users"))
|
||||
filterUsers.setConfigBool(preferences.getBoolean("filter_users", true));
|
||||
if (preferences.contains("filter_contacts"))
|
||||
filterContacts.setConfigBool(preferences.getBoolean("filter_contacts", true));
|
||||
if (preferences.contains("filter_groups"))
|
||||
filterGroups.setConfigBool(preferences.getBoolean("filter_groups", true));
|
||||
if (preferences.contains("filter_channels"))
|
||||
filterChannels.setConfigBool(preferences.getBoolean("filter_channels", true));
|
||||
if (preferences.contains("filter_bots"))
|
||||
filterBots.setConfigBool(preferences.getBoolean("filter_bots", true));
|
||||
if (preferences.contains("filter_admins"))
|
||||
filterAdmins.setConfigBool(preferences.getBoolean("filter_admins", true));
|
||||
if (preferences.contains("filter_unmuted"))
|
||||
filterUnmuted.setConfigBool(preferences.getBoolean("filter_unmuted", true));
|
||||
if (preferences.contains("filter_unread"))
|
||||
filterUnread.setConfigBool(preferences.getBoolean("filter_unread", true));
|
||||
if (preferences.contains("filter_unmuted_and_unread"))
|
||||
filterUnmutedAndUnread.setConfigBool(preferences.getBoolean("filter_unmuted_and_unread", true));
|
||||
|
||||
if (preferences.contains("disable_system_account"))
|
||||
disableSystemAccount.setConfigBool(preferences.getBoolean("disable_system_account", false));
|
||||
if (preferences.contains("disable_proxy_when_vpn_enabled"))
|
||||
disableProxyWhenVpnEnabled.setConfigBool(preferences.getBoolean("disable_proxy_when_vpn_enabled", false));
|
||||
if (preferences.contains("skip_open_link_confirm"))
|
||||
skipOpenLinkConfirm.setConfigBool(preferences.getBoolean("skip_open_link_confirm", false));
|
||||
|
||||
if (preferences.contains("ignore_muted_count"))
|
||||
ignoreMutedCount.setConfigBool(preferences.getBoolean("ignore_muted_count", true));
|
||||
if (preferences.contains("use_default_theme"))
|
||||
useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false));
|
||||
if (preferences.contains("show_id_and_dc"))
|
||||
showIdAndDc.setConfigBool(preferences.getBoolean("show_id_and_dc", false));
|
||||
|
||||
if (preferences.contains("google_cloud_translate_key"))
|
||||
googleCloudTranslateKey.setConfigString(preferences.getString("google_cloud_translate_key", null));
|
||||
if (preferences.contains("cache_path"))
|
||||
cachePath.setConfigString(preferences.getString("cache_path", null));
|
||||
|
||||
if (preferences.contains("trans_to_lang"))
|
||||
translateToLang.setConfigString(preferences.getString("trans_to_lang", ""));
|
||||
if (preferences.contains("trans_input_to_lang"))
|
||||
translateInputLang.setConfigString(preferences.getString("trans_input_to_lang", "en"));
|
||||
|
||||
if (preferences.contains("opencc_to_lang"))
|
||||
ccToLang.setConfigString(preferences.getString("opencc_to_lang", null));
|
||||
if (preferences.contains("opencc_input_to_lang"))
|
||||
ccInputLang.setConfigString(preferences.getString("opencc_input_to_lang", null));
|
||||
|
||||
if (preferences.contains("tabsTitleType"))
|
||||
tabsTitleType.setConfigInt(preferences.getInt("tabsTitleType", NekoConfig.TITLE_TYPE_TEXT));
|
||||
if (preferences.contains("confirmAVMessage"))
|
||||
confirmAVMessage.setConfigBool(preferences.getBoolean("confirmAVMessage", false));
|
||||
if (preferences.contains("askBeforeCall"))
|
||||
askBeforeCall.setConfigBool(preferences.getBoolean("askBeforeCall", false));
|
||||
if (preferences.contains("disableNumberRounding"))
|
||||
disableNumberRounding.setConfigBool(preferences.getBoolean("disableNumberRounding", false));
|
||||
|
||||
if (preferences.contains("useSystemDNS"))
|
||||
useSystemDNS.setConfigBool(preferences.getBoolean("useSystemDNS", false));
|
||||
if (preferences.contains("customDoH"))
|
||||
customDoH.setConfigString(preferences.getString("customDoH", ""));
|
||||
if (preferences.contains("hide_proxy_by_default"))
|
||||
hideProxyByDefault.setConfigBool(preferences.getBoolean("hide_proxy_by_default", false));
|
||||
if (preferences.contains("use_proxy_item"))
|
||||
useProxyItem.setConfigBool(preferences.getBoolean("use_proxy_item", true));
|
||||
|
||||
if (preferences.contains("disableAppBarShadow"))
|
||||
disableAppBarShadow.setConfigBool(preferences.getBoolean("disableAppBarShadow", false));
|
||||
if (preferences.contains("mediaPreview"))
|
||||
mediaPreview.setConfigBool(preferences.getBoolean("mediaPreview", true));
|
||||
|
||||
if (preferences.contains("proxy_auto_switch"))
|
||||
proxyAutoSwitch.setConfigBool(preferences.getBoolean("proxy_auto_switch", false));
|
||||
|
||||
if (preferences.contains("openPGPApp"))
|
||||
openPGPApp.setConfigString(preferences.getString("openPGPApp", ""));
|
||||
if (preferences.contains("openPGPKeyId"))
|
||||
openPGPKeyId.setConfigLong(preferences.getLong("openPGPKeyId", 0L));
|
||||
|
||||
if (preferences.contains("disableVibration"))
|
||||
disableVibration.setConfigBool(preferences.getBoolean("disableVibration", false));
|
||||
if (preferences.contains("autoPauseVideo"))
|
||||
autoPauseVideo.setConfigBool(preferences.getBoolean("autoPauseVideo", false));
|
||||
if (preferences.contains("disableProximityEvents"))
|
||||
disableProximityEvents.setConfigBool(preferences.getBoolean("disableProximityEvents", false));
|
||||
|
||||
if (preferences.contains("ignoreContentRestrictions"))
|
||||
ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay));
|
||||
if (preferences.contains("useChatAttachMediaMenu"))
|
||||
useChatAttachMediaMenu.setConfigBool(preferences.getBoolean("useChatAttachMediaMenu", true));
|
||||
if (preferences.contains("disableLinkPreviewByDefault"))
|
||||
disableLinkPreviewByDefault.setConfigBool(preferences.getBoolean("disableLinkPreviewByDefault", false));
|
||||
if (preferences.contains("sendCommentAfterForward"))
|
||||
sendCommentAfterForward.setConfigBool(preferences.getBoolean("sendCommentAfterForward", true));
|
||||
if (preferences.contains("increaseVoiceMessageQuality"))
|
||||
increaseVoiceMessageQuality.setConfigBool(preferences.getBoolean("increaseVoiceMessageQuality", true));
|
||||
if (preferences.contains("acceptSecretChat"))
|
||||
acceptSecretChat.setConfigBool(preferences.getBoolean("acceptSecretChat", true));
|
||||
if (preferences.contains("disableTrending"))
|
||||
disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true));
|
||||
if (preferences.contains("dontSendGreetingSticker"))
|
||||
dontSendGreetingSticker.setConfigBool(preferences.getBoolean("dontSendGreetingSticker", false));
|
||||
if (preferences.contains("hideTimeForSticker"))
|
||||
hideTimeForSticker.setConfigBool(preferences.getBoolean("hideTimeForSticker", false));
|
||||
if (preferences.contains("takeGIFasVideo"))
|
||||
takeGIFasVideo.setConfigBool(preferences.getBoolean("takeGIFasVideo", false));
|
||||
if (preferences.contains("maxRecentStickerCount"))
|
||||
maxRecentStickerCount.setConfigInt(preferences.getInt("maxRecentStickerCount", 20));
|
||||
if (preferences.contains("disableSwipeToNext"))
|
||||
disableSwipeToNext.setConfigBool(preferences.getBoolean("disableSwipeToNext", true));
|
||||
if (preferences.contains("disableRemoteEmojiInteractions"))
|
||||
disableRemoteEmojiInteractions.setConfigBool(preferences.getBoolean("disableRemoteEmojiInteractions", true));
|
||||
if (preferences.contains("disableChoosingSticker"))
|
||||
disableChoosingSticker.setConfigBool(preferences.getBoolean("disableChoosingSticker", false));
|
||||
|
||||
if (preferences.contains("disableAutoDownloadingWin32Executable"))
|
||||
disableAutoDownloadingWin32Executable.setConfigBool(preferences.getBoolean("disableAutoDownloadingWin32Executable", true));
|
||||
if (preferences.contains("disableAutoDownloadingArchive"))
|
||||
disableAutoDownloadingArchive.setConfigBool(preferences.getBoolean("disableAutoDownloadingArchive", true));
|
||||
|
||||
if (preferences.contains("enableStickerPin"))
|
||||
enableStickerPin.setConfigBool(preferences.getBoolean("enableStickerPin", false));
|
||||
if (preferences.contains("useMediaStreamInVoip"))
|
||||
useMediaStreamInVoip.setConfigBool(preferences.getBoolean("useMediaStreamInVoip", false));
|
||||
if (preferences.contains("customAudioBitrate"))
|
||||
customAudioBitrate.setConfigInt(preferences.getInt("customAudioBitrate", 32));
|
||||
if (preferences.contains("disableGroupVoipAudioProcessing"))
|
||||
disableGroupVoipAudioProcessing.setConfigBool(preferences.getBoolean("disableGroupVoipAudioProcessing", false));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package tw.nekomimi.nkmr;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class NekomuraTGCell {
|
||||
protected CellGroup cellGroup;
|
||||
|
||||
public void bindCellGroup(CellGroup cellGroup) {
|
||||
this.cellGroup = cellGroup;
|
||||
}
|
||||
|
||||
public abstract int getType();
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
public abstract void onBindViewHolder(RecyclerView.ViewHolder holder);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGCustom extends NekomuraTGCell {
|
||||
public final int type;
|
||||
public final boolean enabled;
|
||||
|
||||
public NekomuraTGCustom(int type, boolean enabled) {
|
||||
this.type = type;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
// Not Used
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGDivider extends NekomuraTGCell {
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_DIVIDER;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGHeader extends NekomuraTGCell {
|
||||
private final String title;
|
||||
|
||||
public NekomuraTGHeader(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_HEADER;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
HeaderCell headerCell = (HeaderCell) holder.itemView;
|
||||
headerCell.setText(title);
|
||||
}
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.RadioColorCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
// TextSettingsCell, select from a list
|
||||
// Can be used without select list(custom)
|
||||
public class NekomuraTGSelectBox extends NekomuraTGCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String[] selectList; // split by \n
|
||||
private final String title;
|
||||
private final Runnable onClickCustom;
|
||||
private Context ctxCustom;
|
||||
|
||||
// default: customTitle=null customOnClick=null
|
||||
public NekomuraTGSelectBox(String customTitle, ConfigItem bind, Object selectList_s, Runnable customOnClick) {
|
||||
this.bindConfig = bind;
|
||||
if (selectList_s == null) {
|
||||
this.selectList = null;
|
||||
} else if (selectList_s instanceof String) {
|
||||
this.selectList = ((String) selectList_s).split("\n");
|
||||
} else if (selectList_s instanceof String[]) {
|
||||
this.selectList = (String[]) selectList_s;
|
||||
} else {
|
||||
this.selectList = null;
|
||||
}
|
||||
if (customTitle == null) {
|
||||
title = LocaleController.getString(bindConfig.getKey());
|
||||
} else {
|
||||
title = customTitle;
|
||||
}
|
||||
this.onClickCustom = customOnClick;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
|
||||
String valueText = "";
|
||||
if (selectList != null && bindConfig.Int() < selectList.length) {
|
||||
valueText = selectList[bindConfig.Int()];
|
||||
}
|
||||
cell.setTextAndValue(title, valueText, cellGroup.needSetDivider(this));
|
||||
}
|
||||
|
||||
public void onClick(Context ctx) {
|
||||
ctxCustom = ctx;
|
||||
onClick();
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
if (onClickCustom != null) {
|
||||
try {
|
||||
onClickCustom.run();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = ctxCustom != null ? ctxCustom : cellGroup.thisFragment.getParentActivity();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context); //TODO Replace with pop-up menu
|
||||
builder.setTitle(LocaleController.getString(bindConfig.getKey()));
|
||||
final LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
builder.setView(linearLayout);
|
||||
|
||||
for (int i = 0; i < selectList.length; i++) {
|
||||
RadioColorCell cell = new RadioColorCell(context);
|
||||
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
cell.setTag(i);
|
||||
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
|
||||
cell.setTextAndValue(selectList[i], bindConfig.Int() == i);
|
||||
linearLayout.addView(cell);
|
||||
cell.setOnClickListener(v -> {
|
||||
Integer which = (Integer) v.getTag();
|
||||
bindConfig.setConfigInt(which);
|
||||
|
||||
if (cellGroup.listAdapter != null)
|
||||
cellGroup.listAdapter.notifyItemChanged(cellGroup.rows.indexOf(this));
|
||||
builder.getDismissRunnable().run();
|
||||
if (cellGroup.thisFragment != null)
|
||||
cellGroup.thisFragment.parentLayout.rebuildAllFragmentViews(false, false);
|
||||
|
||||
cellGroup.runCallback(bindConfig.getKey(), which);
|
||||
});
|
||||
}
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
if (ctxCustom == null) {
|
||||
cellGroup.thisFragment.showDialog(builder.create());
|
||||
} else {
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.ui.Cells.TextCheckCell;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGTextCheck extends NekomuraTGCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String title;
|
||||
private final String subtitle;
|
||||
public boolean enabled = true;
|
||||
public TextCheckCell cell; //TODO getCell() in NekomuraTGCell
|
||||
|
||||
public NekomuraTGTextCheck(ConfigItem bind) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.subtitle = null;
|
||||
}
|
||||
|
||||
public NekomuraTGTextCheck(ConfigItem bind, String subtitle) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_TEXT_CHECK;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextCheckCell cell = (TextCheckCell) holder.itemView;
|
||||
this.cell = cell;
|
||||
if (subtitle == null) {
|
||||
cell.setTextAndCheck(title, bindConfig.Bool(), cellGroup.needSetDivider(this));
|
||||
} else {
|
||||
cell.setTextAndValueAndCheck(title, subtitle, bindConfig.Bool(), true, cellGroup.needSetDivider(this));
|
||||
}
|
||||
cell.setEnabled(enabled, null);
|
||||
}
|
||||
|
||||
public void onClick(TextCheckCell cell) {
|
||||
if (!enabled) return;
|
||||
|
||||
boolean newV = bindConfig.toggleConfigBool();
|
||||
cell.setChecked(newV);
|
||||
|
||||
cellGroup.runCallback(bindConfig.getKey(), newV);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.ui.Cells.TextDetailSettingsCell;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGTextDetail extends NekomuraTGCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String title;
|
||||
private final String hint;
|
||||
public final RecyclerListView.OnItemClickListener onItemClickListener;
|
||||
|
||||
public NekomuraTGTextDetail(ConfigItem bind, RecyclerListView.OnItemClickListener onItemClickListener, String hint) {
|
||||
this.bindConfig = bind;
|
||||
this.title = LocaleController.getString(bindConfig.getKey());
|
||||
this.hint = hint == null ? "" : hint;
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_TEXT_DETAIL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextDetailSettingsCell cell = (TextDetailSettingsCell) holder.itemView;
|
||||
cell.setTextAndValue(title, StrUtil.isNotBlank(bindConfig.String()) ? bindConfig.String() : hint, cellGroup.needSetDivider(this));
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.EditTextBoldCursor;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
|
||||
public class NekomuraTGTextInput extends NekomuraTGCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String hint;
|
||||
private final String title;
|
||||
private final Runnable onClickCustom;
|
||||
|
||||
// default: customTitle=null customOnClick=null
|
||||
public NekomuraTGTextInput(String customTitle, ConfigItem bind, String hint, Runnable customOnClick) {
|
||||
this.bindConfig = bind;
|
||||
if (hint == null) {
|
||||
this.hint = "";
|
||||
} else {
|
||||
this.hint = hint;
|
||||
}
|
||||
if (customTitle == null) {
|
||||
title = LocaleController.getString(bindConfig.getKey());
|
||||
} else {
|
||||
title = customTitle;
|
||||
}
|
||||
this.onClickCustom = customOnClick;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder) {
|
||||
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
|
||||
cell.setTextAndValue(title, bindConfig.String(), cellGroup.needSetDivider(this));
|
||||
}
|
||||
|
||||
public void onClick() {
|
||||
if (onClickCustom != null) {
|
||||
try {
|
||||
onClickCustom.run();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Context context = cellGroup.thisFragment.getParentActivity();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(LocaleController.getString(bindConfig.getKey()));
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
EditTextBoldCursor editText = new EditTextBoldCursor(context);
|
||||
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
editText.setHint(hint);
|
||||
editText.setText(bindConfig.String());
|
||||
linearLayout.addView(editText, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(10), 0));
|
||||
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (d, v) -> {
|
||||
String newV = editText.getText().toString();
|
||||
bindConfig.setConfigString(newV);
|
||||
|
||||
//refresh
|
||||
cellGroup.listAdapter.notifyItemChanged(cellGroup.rows.indexOf(this));
|
||||
builder.getDismissRunnable().run();
|
||||
cellGroup.thisFragment.parentLayout.rebuildAllFragmentViews(false, false);
|
||||
|
||||
cellGroup.runCallback(bindConfig.getKey(), newV);
|
||||
});
|
||||
builder.setView(linearLayout);
|
||||
cellGroup.thisFragment.showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user