mirror of https://github.com/NekoX-Dev/NekoX.git
Fix InternalUpdater & Refactor Cells
This commit is contained in:
parent
3c8781c7de
commit
ac47e574e0
|
@ -29,14 +29,15 @@ import java.io.File;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import tw.nekomimi.nekogram.utils.FileUtil;
|
||||
import tw.nekomimi.nkmr.Cells;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.MiniCDNDrive;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.NekomuraUtil;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGSelectBox;
|
||||
|
||||
//TODO use UpdateAppAlertDialog / BlockingUpdateView?
|
||||
|
||||
|
@ -56,6 +57,10 @@ public class InternalUpdater {
|
|||
String browser_download_url;
|
||||
}
|
||||
|
||||
private static class GithubApiContents {
|
||||
String content;
|
||||
}
|
||||
|
||||
// as a base64 encoded json
|
||||
private static class NekoXReleaseNote {
|
||||
NekoXAPK[] apks;
|
||||
|
@ -88,6 +93,16 @@ public class InternalUpdater {
|
|||
ReleaseMetadata[] releases = new Gson().fromJson(ret, ReleaseMetadata[].class);
|
||||
|
||||
ReleaseMetadata release = null;
|
||||
String releaseChannel = "stable";
|
||||
switch (NekoXConfig.autoUpdateReleaseChannel) {
|
||||
case 2:
|
||||
releaseChannel = "rc";
|
||||
break;
|
||||
case 3:
|
||||
releaseChannel = "preview";
|
||||
break;
|
||||
}
|
||||
|
||||
for (ReleaseMetadata rel : releases) {
|
||||
if (rel.name.equals("v" + BuildConfig.VERSION_NAME))
|
||||
break;
|
||||
|
@ -110,20 +125,26 @@ public class InternalUpdater {
|
|||
final ApkMetadata apk = matchBuild(release.assets);
|
||||
|
||||
// match apk urls
|
||||
byte[] gzipped = Base64.decode(NekomuraUtil.getSubString(release.body, "#NekoXStart#", "#NekoXEnd#"), Base64.NO_PADDING);
|
||||
final NekoXReleaseNote nekoXReleaseNote = new Gson().fromJson(new String(NekomuraUtil.uncompress(gzipped)), NekoXReleaseNote.class);
|
||||
String urlChannel = "";
|
||||
String urlCDNDrive = "";
|
||||
String sha1 = "";
|
||||
if (apk != null && nekoXReleaseNote != null) {
|
||||
for (NekoXAPK napk : nekoXReleaseNote.apks) {
|
||||
if (napk.name.equals(apk.name)) {
|
||||
sha1 = napk.sha1;
|
||||
for (String url : napk.urls) {
|
||||
if (url.startsWith("https://t.me/")) urlChannel = url;
|
||||
if (url.startsWith("bdex://")) urlCDNDrive = url;
|
||||
if (apk != null) {
|
||||
final String newBody = HttpUtil.get("https://api.github.com/repos/NekoX-Dev/updates/contents/" + releaseChannel + ".txt?ref=main");
|
||||
final GithubApiContents releaseNoteApi = new Gson().fromJson(newBody, GithubApiContents.class);
|
||||
final String releaseNoteString = new String(Base64.decode(releaseNoteApi.content, Base64.DEFAULT));
|
||||
final byte[] gzipped = Base64.decode(NekomuraUtil.getSubString(releaseNoteString, "#NekoXStart#", "#NekoXEnd#"), Base64.NO_PADDING);
|
||||
final NekoXReleaseNote nekoXReleaseNote = new Gson().fromJson(new String(NekomuraUtil.uncompress(gzipped)), NekoXReleaseNote.class);
|
||||
|
||||
if (nekoXReleaseNote != null && nekoXReleaseNote.apks != null) {
|
||||
for (NekoXAPK napk : nekoXReleaseNote.apks) {
|
||||
if (napk.name.equals(apk.name)) {
|
||||
sha1 = napk.sha1;
|
||||
for (String url : napk.urls) {
|
||||
if (url.startsWith("https://t.me/")) urlChannel = url;
|
||||
if (url.startsWith("bdex://")) urlCDNDrive = url;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +187,7 @@ public class InternalUpdater {
|
|||
}
|
||||
|
||||
public static void showSelectDownloadSource(Context ctx, String title, String browser_download_url, String urlChannel, String urlCDNDrive, String sha1) {
|
||||
Cells nkmrCells = new Cells(null, null);
|
||||
CellGroup nkmrCells = new CellGroup(null);
|
||||
|
||||
nkmrCells.callBackSettingsChanged = ((k, v) -> {
|
||||
int source = NekomuraConfig.update_download_soucre.Int();
|
||||
|
@ -221,7 +242,8 @@ public class InternalUpdater {
|
|||
String[] sources_ = new String[sources.size()];
|
||||
sources.toArray(sources_);
|
||||
|
||||
Cells.NekomuraTGSelectBox sb = nkmrCells.new NekomuraTGSelectBox(null, NekomuraConfig.update_download_soucre, sources_, null);
|
||||
NekomuraTGSelectBox sb = new NekomuraTGSelectBox(null, NekomuraConfig.update_download_soucre, sources_, null);
|
||||
nkmrCells.appendCell(sb); // new
|
||||
sb.onClick(ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ import tw.nekomimi.nekogram.NekoXConfig;
|
|||
import tw.nekomimi.nekogram.PopupBuilder;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.AbstractCell;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGCustom;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGDivider;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGHeader;
|
||||
|
@ -62,58 +62,59 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
private final boolean showCensoredFeatures = NekomuraConfig.showCensoredFeatures(getUserConfig().clientUserId);
|
||||
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,
|
||||
|
||||
private final AbstractCell header0 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("StickerSize")));
|
||||
private final AbstractCell stickerSizeRow = cellGroup.appendCell(new NekomuraTGCustom(998, true));
|
||||
private final AbstractCell divider0 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Chat")));
|
||||
private final AbstractCell unreadBadgeOnBackButton = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unreadBadgeOnBackButton));
|
||||
private final AbstractCell ignoreBlockedRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout")));
|
||||
private final AbstractCell ignoreMutedCountRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.ignoreMutedCount));
|
||||
private final AbstractCell disableChatActionRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableChatAction));
|
||||
private final AbstractCell disableChoosingStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableChoosingSticker));
|
||||
private final AbstractCell disablePhotoSideActionRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disablePhotoSideAction));
|
||||
private final AbstractCell hideKeyboardOnChatScrollRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideKeyboardOnChatScroll));
|
||||
private final AbstractCell disableVibrationRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableVibration));
|
||||
private final AbstractCell skipOpenLinkConfirmRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.skipOpenLinkConfirm));
|
||||
private final AbstractCell rearVideoMessagesRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.rearVideoMessages));
|
||||
private final AbstractCell confirmAVRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.confirmAVMessage));
|
||||
private final AbstractCell useChatAttachMediaMenuRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useChatAttachMediaMenu, LocaleController.getString("UseChatAttachEnterMenuNotice")));
|
||||
private final AbstractCell disableLinkPreviewByDefaultRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableLinkPreviewByDefault, LocaleController.getString("DisableLinkPreviewByDefaultNotice")));
|
||||
private final AbstractCell sendCommentAfterForwardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.sendCommentAfterForward));
|
||||
private final AbstractCell disableProximityEventsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableProximityEvents));
|
||||
private final AbstractCell disableTrendingRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableTrending));
|
||||
private final AbstractCell dontSendGreetingStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.dontSendGreetingSticker));
|
||||
private final AbstractCell hideTimeForStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideTimeForSticker));
|
||||
private final AbstractCell hideGroupStickerRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideGroupSticker));
|
||||
private final AbstractCell takeGIFasVideoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.takeGIFasVideo));
|
||||
private final AbstractCell maxRecentStickerCountRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell disableSwipeToNextRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableSwipeToNext));
|
||||
private final AbstractCell disableRemoteEmojiInteractionsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableRemoteEmojiInteractions));
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> {
|
||||
private final AbstractCell messageMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> {
|
||||
showMessageMenuAlert();
|
||||
}));
|
||||
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,
|
||||
private final AbstractCell divider1 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell header2 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("AutoDownload")));
|
||||
private final AbstractCell win32Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingWin32Executable));
|
||||
private final AbstractCell archiveRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAutoDownloadingArchive));
|
||||
private final AbstractCell divider2 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell header3 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Folder")));
|
||||
private final AbstractCell showTabsOnForwardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.showTabsOnForward));
|
||||
private final AbstractCell hideAllTabRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideAllTab, LocaleController.getString("HideAllTabAbout")));
|
||||
private final AbstractCell pressTitleToOpenAllChatsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.pressTitleToOpenAllChats));
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell divider3 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private ActionBarMenuItem menuItem;
|
||||
|
@ -178,7 +179,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
|
||||
// Fragment: Set OnClick Callbacks
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
|
@ -489,7 +490,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
|
@ -498,7 +499,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
|
@ -507,7 +508,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
|
|
|
@ -43,7 +43,7 @@ import kotlin.Unit;
|
|||
import tw.nekomimi.nekogram.PopupBuilder;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.AbstractCell;
|
||||
import tw.nekomimi.nkmr.cells.*;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
|
@ -58,19 +58,19 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
|||
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
|
||||
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 AbstractCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Experiment")));
|
||||
private final AbstractCell smoothKeyboardRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.smoothKeyboard));
|
||||
private final AbstractCell increaseVoiceMessageQualityRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.increaseVoiceMessageQuality));
|
||||
private final AbstractCell mediaPreviewRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.mediaPreview));
|
||||
private final AbstractCell proxyAutoSwitchRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.proxyAutoSwitch));
|
||||
private final AbstractCell 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 = 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 final AbstractCell unlimitedFavedStickersRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unlimitedFavedStickers, LocaleController.getString("UnlimitedFavoredStickersAbout")));
|
||||
private final AbstractCell unlimitedPinnedDialogsRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.unlimitedPinnedDialogs, LocaleController.getString("UnlimitedPinnedDialogsAbout")));
|
||||
private final AbstractCell enableStickerPinRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.enableStickerPin, LocaleController.getString("EnableStickerPinAbout")));
|
||||
private final AbstractCell useMediaStreamInVoipRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useMediaStreamInVoip));
|
||||
private final AbstractCell customAudioBitrateRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell 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 = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
|
@ -338,7 +338,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
|||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
|
|
|
@ -67,7 +67,7 @@ import tw.nekomimi.nekogram.utils.PGPUtil;
|
|||
import tw.nekomimi.nkmr.ConfigItem;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
import tw.nekomimi.nkmr.NekomuraTGCell;
|
||||
import tw.nekomimi.nkmr.cells.AbstractCell;
|
||||
import tw.nekomimi.nkmr.cells.*;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
|
@ -81,88 +81,88 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
|
||||
private final CellGroup cellGroup = new CellGroup(this);
|
||||
|
||||
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 AbstractCell profilePreviewRow = cellGroup.appendCell(new NkmrDrawerProfilePreviewCell());
|
||||
private final AbstractCell largeAvatarInDrawerRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null));
|
||||
private final AbstractCell avatarBackgroundBlurRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundBlur));
|
||||
private final AbstractCell avatarBackgroundDarkenRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.avatarBackgroundDarken));
|
||||
private final AbstractCell hidePhoneRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hidePhone));
|
||||
private final AbstractCell divider0 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
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) -> {
|
||||
private final AbstractCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Connection")));
|
||||
private final AbstractCell useIPv6Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useIPv6));
|
||||
private final AbstractCell disableProxyWhenVpnEnabledRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableProxyWhenVpnEnabled));
|
||||
private final AbstractCell useProxyItemRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useProxyItem));
|
||||
private final AbstractCell hideProxyByDefaultRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideProxyByDefault));
|
||||
private final AbstractCell useSystemDNSRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useSystemDNS));
|
||||
private final AbstractCell customDoHRow = cellGroup.appendCell(new NekomuraTGTextInput(null, NekomuraConfig.customDoH, "https://1.0.0.1/dns-query", null));
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell divider1 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
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) -> {
|
||||
private final AbstractCell header2 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Translate")));
|
||||
private final AbstractCell translationProviderRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell translateToLangRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell translateInputToLangRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell divider2 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
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) -> {
|
||||
private final AbstractCell header3 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("OpenKayChain")));
|
||||
private final AbstractCell pgpAppRow = cellGroup.appendCell(new NekomuraTGCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true));
|
||||
private final AbstractCell keyRow = cellGroup.appendCell(new NekomuraTGTextDetail(NekomuraConfig.openPGPKeyId, (view, position) -> {
|
||||
requestKey(new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID));
|
||||
}, "0"));
|
||||
private final NekomuraTGCell divider3 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell divider3 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
private final NekomuraTGCell header4 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("DialogsSettings")));
|
||||
private final NekomuraTGCell sortMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("SortMenu"), null, null, () -> {
|
||||
private final AbstractCell header4 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("DialogsSettings")));
|
||||
private final AbstractCell sortMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("SortMenu"), null, null, () -> {
|
||||
showSortMenuAlert();
|
||||
}));
|
||||
private final NekomuraTGCell acceptSecretChatRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.acceptSecretChat));
|
||||
private final NekomuraTGCell divider4 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell acceptSecretChatRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.acceptSecretChat));
|
||||
private final AbstractCell divider4 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
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[]{
|
||||
private final AbstractCell header5 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Appearance")));
|
||||
private final AbstractCell typefaceRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.typeface));
|
||||
private final AbstractCell useDefaultThemeRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useDefaultTheme));
|
||||
private final AbstractCell useSystemEmojiRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useSystemEmoji));
|
||||
private final AbstractCell transparentStatusBarRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.transparentStatusBar));
|
||||
private final AbstractCell appBarShadowRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableAppBarShadow));
|
||||
private final AbstractCell newYearRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.newYear));
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.tabletMode, new String[]{
|
||||
private final AbstractCell 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 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
private final AbstractCell divider5 = cellGroup.appendCell(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 AbstractCell header6 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("PrivacyTitle")));
|
||||
private final AbstractCell disableSystemAccountRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableSystemAccount));
|
||||
private final AbstractCell divider6 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
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 hideSponsoredMessageRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideSponsoredMessage));
|
||||
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[]{
|
||||
private final AbstractCell header7 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("General")));
|
||||
private final AbstractCell disableUndoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableUndo));
|
||||
private final AbstractCell showIdAndDcRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.showIdAndDc));
|
||||
private final AbstractCell inappCameraRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.inappCamera));
|
||||
private final AbstractCell hideProxySponsorChannelRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideProxySponsorChannel));
|
||||
private final AbstractCell hideSponsoredMessageRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideSponsoredMessage));
|
||||
private final AbstractCell askBeforeCallRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.askBeforeCall));
|
||||
private final AbstractCell autoPauseVideoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.autoPauseVideo, LocaleController.getString("AutoPauseVideoAbout")));
|
||||
private final AbstractCell disableNumberRoundingRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableNumberRounding, "4.8K -> 4777"));
|
||||
private final AbstractCell openArchiveOnPullRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.openArchiveOnPull));
|
||||
private final AbstractCell 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 = 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 final AbstractCell usePersianCalendarRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.usePersianCalendar, LocaleController.getString("UsePersiancalendarInfo")));
|
||||
private final AbstractCell displayPersianCalendarByLatinRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.displayPersianCalendarByLatin));
|
||||
private final AbstractCell divider7 = cellGroup.appendCell(new NekomuraTGDivider());
|
||||
|
||||
|
||||
private UndoView restartTooltip;
|
||||
|
@ -214,7 +214,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
|
||||
// Fragment: Set OnClick Callbacks
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a instanceof NekomuraTGTextCheck) {
|
||||
((NekomuraTGTextCheck) a).onClick((TextCheckCell) view);
|
||||
} else if (a instanceof NekomuraTGSelectBox) {
|
||||
|
@ -371,7 +371,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
return fragmentView;
|
||||
}
|
||||
|
||||
private class NkmrDrawerProfilePreviewCell extends NekomuraTGCell {
|
||||
private class NkmrDrawerProfilePreviewCell extends AbstractCell {
|
||||
public int getType() {
|
||||
return 999;
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
@Override
|
||||
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.isEnabled();
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
return a.getType();
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
|
|||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
NekomuraTGCell a = cellGroup.rows.get(position);
|
||||
AbstractCell a = cellGroup.rows.get(position);
|
||||
if (a != null) {
|
||||
if (a instanceof NekomuraTGCustom) {
|
||||
// Custom binds
|
||||
|
|
|
@ -1,31 +1,16 @@
|
|||
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.AbstractCell;
|
||||
import tw.nekomimi.nkmr.cells.NekomuraTGDivider;
|
||||
|
||||
public class CellGroup {
|
||||
|
@ -39,7 +24,7 @@ public class CellGroup {
|
|||
public BaseFragment thisFragment;
|
||||
public RecyclerListView listView;
|
||||
public RecyclerListView.SelectionAdapter listAdapter;
|
||||
public ArrayList<NekomuraTGCell> rows;
|
||||
public ArrayList<AbstractCell> rows;
|
||||
|
||||
public CallBackSettingsChanged callBackSettingsChanged;
|
||||
|
||||
|
@ -53,15 +38,15 @@ public class CellGroup {
|
|||
this.listAdapter = la;
|
||||
}
|
||||
|
||||
public NekomuraTGCell appendCell(NekomuraTGCell cell) {
|
||||
public AbstractCell appendCell(AbstractCell cell) {
|
||||
cell.bindCellGroup(this);
|
||||
this.rows.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
public NekomuraTGCell appendCell(NekomuraTGCell cell, boolean display) {
|
||||
public AbstractCell appendCell(AbstractCell cell, boolean display) {
|
||||
cell.bindCellGroup(this);
|
||||
if (display)
|
||||
if (display) // For censored features, don't show it forever.
|
||||
this.rows.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
@ -98,14 +83,8 @@ public class CellGroup {
|
|||
cell.setLayoutParams(params);
|
||||
}
|
||||
|
||||
public boolean needSetDivider(NekomuraTGCell cell) {
|
||||
public boolean needSetDivider(AbstractCell cell) {
|
||||
return !(rows.get(rows.indexOf(cell) + 1) instanceof NekomuraTGDivider);
|
||||
}
|
||||
|
||||
//TG Cells
|
||||
|
||||
|
||||
//TextDetailSettingsCell
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package tw.nekomimi.nkmr;
|
||||
package tw.nekomimi.nkmr.cells;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public abstract class NekomuraTGCell {
|
||||
import tw.nekomimi.nkmr.CellGroup;
|
||||
|
||||
public abstract class AbstractCell {
|
||||
// can not be null!
|
||||
protected CellGroup cellGroup;
|
||||
|
||||
// called by CellGroup.java
|
||||
public void bindCellGroup(CellGroup cellGroup) {
|
||||
this.cellGroup = cellGroup;
|
||||
}
|
|
@ -2,10 +2,7 @@ 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 class NekomuraTGCustom extends AbstractCell {
|
||||
public final int type;
|
||||
public final boolean enabled;
|
||||
|
||||
|
|
|
@ -3,9 +3,8 @@ 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 class NekomuraTGDivider extends AbstractCell {
|
||||
|
||||
public int getType() {
|
||||
return CellGroup.ITEM_TYPE_DIVIDER;
|
||||
|
|
|
@ -2,14 +2,11 @@ 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 {
|
||||
public class NekomuraTGHeader extends AbstractCell {
|
||||
private final String title;
|
||||
|
||||
public NekomuraTGHeader(String title) {
|
||||
|
|
|
@ -15,11 +15,10 @@ 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 {
|
||||
public class NekomuraTGSelectBox extends AbstractCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String[] selectList; // split by \n
|
||||
private final String title;
|
||||
|
|
|
@ -7,9 +7,8 @@ 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 {
|
||||
public class NekomuraTGTextCheck extends AbstractCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String title;
|
||||
private final String subtitle;
|
||||
|
|
|
@ -9,10 +9,8 @@ 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 {
|
||||
public class NekomuraTGTextDetail extends AbstractCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String title;
|
||||
private final String hint;
|
||||
|
|
|
@ -16,10 +16,8 @@ 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 {
|
||||
public class NekomuraTGTextInput extends AbstractCell {
|
||||
private final ConfigItem bindConfig;
|
||||
private final String hint;
|
||||
private final String title;
|
||||
|
|
Loading…
Reference in New Issue