1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

migrate user nekoconfig

This commit is contained in:
arm64v8a 2021-10-30 14:37:34 +08:00
parent c37dfa2831
commit 4ff6df9f9a
3 changed files with 132 additions and 136 deletions

View File

@ -74,139 +74,6 @@ public class NekoConfig {
}
static {
// useIPv6 = preferences.getBoolean("useIPv6", false);
// hidePhone = preferences.getBoolean("hidePhone", true);
// ignoreBlocked = preferences.getBoolean("ignoreBlocked", false);
//
// boolean forceTablet = preferences.getBoolean("forceTablet", false);
// if (forceTablet) {
// tabletMode = 1;
// preferences.edit()
// .remove("forceTablet")
// .putInt("tabletMode", 1)
// .apply();
// } else {
// tabletMode = preferences.getInt("tabletMode", 0);
// }
//
// typeface = preferences.getInt("typeface", 0);
// nameOrder = preferences.getInt("nameOrder", 1);
// mapPreviewProvider = preferences.getInt("mapPreviewProvider", 0);
// transparentStatusBar = preferences.getBoolean("transparentStatusBar", false);
// residentNotification = preferences.getBoolean("residentNotification", false);
// hideProxySponsorChannel = preferences.getBoolean("hideProxySponsorChannel", false);
// showAddToSavedMessages = preferences.getBoolean("showAddToSavedMessages", true);
// showReport = preferences.getBoolean("showReport", true);
// showViewHistory = preferences.getBoolean("showViewHistory", true);
// showAdminActions = preferences.getBoolean("showAdminActions", true);
// showChangePermissions = preferences.getBoolean("showChangePermissions", true);
// showDeleteDownloadedFile = preferences.getBoolean("showDeleteDownloadedFile", true);
// showMessageDetails = preferences.getBoolean("showMessageDetails", false);
// showTranslate = preferences.getBoolean("showTranslate", true);
// showRepeat = preferences.getBoolean("showRepeat", false);
// showMessageHide = preferences.getBoolean("showMessageHide", false);
//
// eventType = preferences.getInt("eventType", 0);
// actionBarDecoration = preferences.getInt("actionBarDecoration", 0);
// newYear = preferences.getBoolean("newYear", false);
// stickerSize = preferences.getFloat("stickerSize", 14.0f);
// unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false);
// unlimitedPinnedDialogs = preferences.getBoolean("unlimitedPinnedDialogs", false);
// translationProvider = preferences.getInt("translationProvider", 1);
// disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true);
// openArchiveOnPull = preferences.getBoolean("openArchiveOnPull", false);
// //showHiddenFeature = preferences.getBoolean("showHiddenFeature", false);
// hideKeyboardOnChatScroll = preferences.getBoolean("hideKeyboardOnChatScroll", false);
// avatarAsDrawerBackground = preferences.getBoolean("avatarAsDrawerBackground", true);
// avatarBackgroundBlur = preferences.getBoolean("avatarBackgroundBlur", false);
// avatarBackgroundDarken = preferences.getBoolean("avatarBackgroundDarken", false);
// useSystemEmoji = preferences.getBoolean("useSystemEmoji", false);
// showTabsOnForward = preferences.getBoolean("showTabsOnForward", false);
// rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
// hideAllTab = preferences.getBoolean("hideAllTab", false);
// pressTitleToOpenAllChats = preferences.getBoolean("pressTitleToOpenAllChats", false);
//
// disableChatAction = preferences.getBoolean("disable_chat_action", false);
// sortByUnread = preferences.getBoolean("sort_by_unread", false);
// sortByUnmuted = preferences.getBoolean("sort_by_unmuted", true);
// sortByUser = preferences.getBoolean("sort_by_user", true);
// sortByContacts = preferences.getBoolean("sort_by_contacts", true);
//
// disableUndo = preferences.getBoolean("disable_undo", false);
//
// filterUsers = preferences.getBoolean("filter_users", true);
// filterContacts = preferences.getBoolean("filter_contacts", true);
// filterGroups = preferences.getBoolean("filter_groups", true);
// filterChannels = preferences.getBoolean("filter_channels", true);
// filterBots = preferences.getBoolean("filter_bots", true);
// filterAdmins = preferences.getBoolean("filter_admins", true);
// filterUnmuted = preferences.getBoolean("filter_unmuted", true);
// filterUnread = preferences.getBoolean("filter_unread", true);
// filterUnmutedAndUnread = preferences.getBoolean("filter_unmuted_and_unread", true);
//
// disableSystemAccount = preferences.getBoolean("disable_system_account", false);
// disableProxyWhenVpnEnabled = preferences.getBoolean("disable_proxy_when_vpn_enabled", false);
// skipOpenLinkConfirm = preferences.getBoolean("skip_open_link_confirm", false);
//
// ignoreMutedCount = preferences.getBoolean("ignore_muted_count", true);
// useDefaultTheme = preferences.getBoolean("use_default_theme", false);
// showIdAndDc = preferences.getBoolean("show_id_and_dc", false);
//
// googleCloudTranslateKey = preferences.getString("google_cloud_translate_key", null);
// cachePath = preferences.getString("cache_path", null);
//
// translateToLang = preferences.getString("trans_to_lang", null);
// translateInputLang = preferences.getString("trans_input_to_lang", "en");
//
// ccToLang = preferences.getString("opencc_to_lang", null);
// ccInputLang = preferences.getString("opencc_input_to_lang", null);
//
// tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
// confirmAVMessage = preferences.getBoolean("confirmAVMessage", false);
// askBeforeCall = preferences.getBoolean("askBeforeCall", false);
// disableNumberRounding = preferences.getBoolean("disableNumberRounding", false);
//
// useSystemDNS = preferences.getBoolean("useSystemDNS", false);
// customDoH = preferences.getString("customDoH", "");
// hideProxyByDefault = preferences.getBoolean("hide_proxy_by_default", false);
// useProxyItem = preferences.getBoolean("use_proxy_item", true);
//
// disableAppBarShadow = preferences.getBoolean("disableAppBarShadow", false);
// mediaPreview = preferences.getBoolean("mediaPreview", true);
//
// proxyAutoSwitch = preferences.getBoolean("proxy_auto_switch", false);
//
// usePersianCalendar = preferences.getInt("persian_calendar", 0);
// displayPersianCalendarByLatin = preferences.getBoolean("displayPersianCalendarByLatin", false);
// openPGPApp = preferences.getString("openPGPApp", "");
// openPGPKeyId = preferences.getLong("openPGPKeyId", 0L);
//
// disableVibration = preferences.getBoolean("disableVibration", false);
// autoPauseVideo = preferences.getBoolean("autoPauseVideo", false);
// disableProximityEvents = preferences.getBoolean("disableProximityEvents", false);
//
// ignoreContentRestrictions = preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay);
// useChatAttachMediaMenu = preferences.getBoolean("useChatAttachMediaMenu", true);
// disableLinkPreviewByDefault = preferences.getBoolean("disableLinkPreviewByDefault", false);
// sendCommentAfterForward = preferences.getBoolean("sendCommentAfterForward", true);
// increaseVoiceMessageQuality = preferences.getBoolean("increaseVoiceMessageQuality", true);
// acceptSecretChat = preferences.getBoolean("acceptSecretChat", true);
// disableTrending = preferences.getBoolean("disableTrending", true);
// dontSendGreetingSticker = preferences.getBoolean("dontSendGreetingSticker", false);
// hideTimeForSticker = preferences.getBoolean("hideTimeForSticker", false);
// takeGIFasVideo = preferences.getBoolean("takeGIFasVideo", false);
// maxRecentStickerCount = preferences.getInt("maxRecentStickerCount", 20);
// disableSwipeToNext = preferences.getBoolean("disableSwipeToNext", true);
// disableRemoteEmojiInteractions = preferences.getBoolean("disableRemoteEmojiInteractions", true);
// disableChoosingSticker = preferences.getBoolean("disableChoosingSticker", false);
//
// disableAutoDownloadingWin32Executable = preferences.getBoolean("disableAutoDownloadingWin32Executable", true);
// disableAutoDownloadingArchive = preferences.getBoolean("disableAutoDownloadingArchive", true);
//
// enableStickerPin = preferences.getBoolean("enableStickerPin", false);
// useMediaStreamInVoip = preferences.getBoolean("useMediaStreamInVoip", false);
// customAudioBitrate = (short) preferences.getInt("customAudioBitrate", 32);
// disableGroupVoipAudioProcessing = preferences.getBoolean("disableGroupVoipAudioProcessing", false);
}

View File

@ -199,7 +199,6 @@ public class NekoSettingsActivity extends BaseFragment {
}
//TODO save NekomuraConfig
private String backupSettingsJson() throws JSONException {
JSONObject configJson = new JSONObject();
@ -274,7 +273,7 @@ public class NekoSettingsActivity extends BaseFragment {
spToJSON("mainconfig", configJson, mainconfig::contains);
spToJSON("themeconfig", configJson, null);
spToJSON("nekoconfig", configJson, null);
spToJSON("nkmrcfg", configJson, null);
return configJson.toString(4);
}

View File

@ -133,7 +133,11 @@ public class NekomuraConfig {
}
public void setConfigString(String v) {
value = v;
if (v == null) {
value = "";
} else {
value = v;
}
if (forceDefault) {
value = defaultValue;
}
@ -292,6 +296,132 @@ 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);
typeface.setConfigBool(preferences.getInt("typeface", 0) != 0);
nameOrder.setConfigInt(preferences.getInt("nameOrder", 1));
mapPreviewProvider.setConfigInt(preferences.getInt("mapPreviewProvider", 0));
transparentStatusBar.setConfigBool(preferences.getBoolean("transparentStatusBar", false));
residentNotification.setConfigBool(preferences.getBoolean("residentNotification", false));
hideProxySponsorChannel.setConfigBool(preferences.getBoolean("hideProxySponsorChannel", false));
showAddToSavedMessages.setConfigBool(preferences.getBoolean("showAddToSavedMessages", true));
showReport.setConfigBool(preferences.getBoolean("showReport", true));
showViewHistory.setConfigBool(preferences.getBoolean("showViewHistory", true));
showAdminActions.setConfigBool(preferences.getBoolean("showAdminActions", true));
showChangePermissions.setConfigBool(preferences.getBoolean("showChangePermissions", true));
showDeleteDownloadedFile.setConfigBool(preferences.getBoolean("showDeleteDownloadedFile", true));
showMessageDetails.setConfigBool(preferences.getBoolean("showMessageDetails", false));
showTranslate.setConfigBool(preferences.getBoolean("showTranslate", true));
showRepeat.setConfigBool(preferences.getBoolean("showRepeat", false));
showMessageHide.setConfigBool(preferences.getBoolean("showMessageHide", false));
eventType.setConfigInt(preferences.getInt("eventType", 0));
actionBarDecoration.setConfigInt(preferences.getInt("actionBarDecoration", 0));
newYear.setConfigBool(preferences.getBoolean("newYear", false));
stickerSize.setConfigFloat(preferences.getFloat("stickerSize", 14.0f));
unlimitedFavedStickers.setConfigBool(preferences.getBoolean("unlimitedFavedStickers", false));
unlimitedPinnedDialogs.setConfigBool(preferences.getBoolean("unlimitedPinnedDialogs", false));
translationProvider.setConfigInt(preferences.getInt("translationProvider", 1));
disablePhotoSideAction.setConfigBool(preferences.getBoolean("disablePhotoSideAction", true));
openArchiveOnPull.setConfigBool(preferences.getBoolean("openArchiveOnPull", false));
//showHiddenFeature.setConfigBool(preferences.getBoolean("showHiddenFeature", false));
hideKeyboardOnChatScroll.setConfigBool(preferences.getBoolean("hideKeyboardOnChatScroll", false));
avatarBackgroundBlur.setConfigBool(preferences.getBoolean("avatarBackgroundBlur", false));
avatarBackgroundDarken.setConfigBool(preferences.getBoolean("avatarBackgroundDarken", false));
useSystemEmoji.setConfigBool(preferences.getBoolean("useSystemEmoji", false));
showTabsOnForward.setConfigBool(preferences.getBoolean("showTabsOnForward", false));
rearVideoMessages.setConfigBool(preferences.getBoolean("rearVideoMessages", false));
hideAllTab.setConfigBool(preferences.getBoolean("hideAllTab", false));
pressTitleToOpenAllChats.setConfigBool(preferences.getBoolean("pressTitleToOpenAllChats", false));
disableChatAction.setConfigBool(preferences.getBoolean("disable_chat_action", false));
sortByUnread.setConfigBool(preferences.getBoolean("sort_by_unread", false));
sortByUnmuted.setConfigBool(preferences.getBoolean("sort_by_unmuted", true));
sortByUser.setConfigBool(preferences.getBoolean("sort_by_user", true));
sortByContacts.setConfigBool(preferences.getBoolean("sort_by_contacts", true));
disableUndo.setConfigBool(preferences.getBoolean("disable_undo", false));
filterUsers.setConfigBool(preferences.getBoolean("filter_users", true));
filterContacts.setConfigBool(preferences.getBoolean("filter_contacts", true));
filterGroups.setConfigBool(preferences.getBoolean("filter_groups", true));
filterChannels.setConfigBool(preferences.getBoolean("filter_channels", true));
filterBots.setConfigBool(preferences.getBoolean("filter_bots", true));
filterAdmins.setConfigBool(preferences.getBoolean("filter_admins", true));
filterUnmuted.setConfigBool(preferences.getBoolean("filter_unmuted", true));
filterUnread.setConfigBool(preferences.getBoolean("filter_unread", true));
filterUnmutedAndUnread.setConfigBool(preferences.getBoolean("filter_unmuted_and_unread", true));
disableSystemAccount.setConfigBool(preferences.getBoolean("disable_system_account", false));
disableProxyWhenVpnEnabled.setConfigBool(preferences.getBoolean("disable_proxy_when_vpn_enabled", false));
skipOpenLinkConfirm.setConfigBool(preferences.getBoolean("skip_open_link_confirm", false));
ignoreMutedCount.setConfigBool(preferences.getBoolean("ignore_muted_count", true));
useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false));
showIdAndDc.setConfigBool(preferences.getBoolean("show_id_and_dc", false));
googleCloudTranslateKey.setConfigString(preferences.getString("google_cloud_translate_key", null));
cachePath.setConfigString(preferences.getString("cache_path", null));
translateToLang.setConfigString(preferences.getString("trans_to_lang", null));
translateInputLang.setConfigString(preferences.getString("trans_input_to_lang", "en"));
ccToLang.setConfigString(preferences.getString("opencc_to_lang", null));
ccInputLang.setConfigString(preferences.getString("opencc_input_to_lang", null));
tabsTitleType.setConfigInt(preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT));
confirmAVMessage.setConfigBool(preferences.getBoolean("confirmAVMessage", false));
askBeforeCall.setConfigBool(preferences.getBoolean("askBeforeCall", false));
disableNumberRounding.setConfigBool(preferences.getBoolean("disableNumberRounding", false));
useSystemDNS.setConfigBool(preferences.getBoolean("useSystemDNS", false));
customDoH.setConfigString(preferences.getString("customDoH", ""));
hideProxyByDefault.setConfigBool(preferences.getBoolean("hide_proxy_by_default", false));
useProxyItem.setConfigBool(preferences.getBoolean("use_proxy_item", true));
disableAppBarShadow.setConfigBool(preferences.getBoolean("disableAppBarShadow", false));
mediaPreview.setConfigBool(preferences.getBoolean("mediaPreview", true));
proxyAutoSwitch.setConfigBool(preferences.getBoolean("proxy_auto_switch", false));
usePersianCalendar.setConfigBool(preferences.getInt("persian_calendar", 0) != 0);
displayPersianCalendarByLatin.setConfigBool(preferences.getBoolean("displayPersianCalendarByLatin", false));
openPGPApp.setConfigString(preferences.getString("openPGPApp", ""));
openPGPKeyId.setConfigLong(preferences.getLong("openPGPKeyId", 0L));
disableVibration.setConfigBool(preferences.getBoolean("disableVibration", false));
autoPauseVideo.setConfigBool(preferences.getBoolean("autoPauseVideo", false));
disableProximityEvents.setConfigBool(preferences.getBoolean("disableProximityEvents", false));
ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay));
useChatAttachMediaMenu.setConfigBool(preferences.getBoolean("useChatAttachMediaMenu", true));
disableLinkPreviewByDefault.setConfigBool(preferences.getBoolean("disableLinkPreviewByDefault", false));
sendCommentAfterForward.setConfigBool(preferences.getBoolean("sendCommentAfterForward", true));
increaseVoiceMessageQuality.setConfigBool(preferences.getBoolean("increaseVoiceMessageQuality", true));
acceptSecretChat.setConfigBool(preferences.getBoolean("acceptSecretChat", true));
disableTrending.setConfigBool(preferences.getBoolean("disableTrending", true));
dontSendGreetingSticker.setConfigBool(preferences.getBoolean("dontSendGreetingSticker", false));
hideTimeForSticker.setConfigBool(preferences.getBoolean("hideTimeForSticker", false));
takeGIFasVideo.setConfigBool(preferences.getBoolean("takeGIFasVideo", false));
maxRecentStickerCount.setConfigInt(preferences.getInt("maxRecentStickerCount", 20));
disableSwipeToNext.setConfigBool(preferences.getBoolean("disableSwipeToNext", true));
disableRemoteEmojiInteractions.setConfigBool(preferences.getBoolean("disableRemoteEmojiInteractions", true));
disableChoosingSticker.setConfigBool(preferences.getBoolean("disableChoosingSticker", false));
disableAutoDownloadingWin32Executable.setConfigBool(preferences.getBoolean("disableAutoDownloadingWin32Executable", true));
disableAutoDownloadingArchive.setConfigBool(preferences.getBoolean("disableAutoDownloadingArchive", true));
enableStickerPin.setConfigBool(preferences.getBoolean("enableStickerPin", false));
useMediaStreamInVoip.setConfigBool(preferences.getBoolean("useMediaStreamInVoip", false));
customAudioBitrate.setConfigInt(preferences.getInt("customAudioBitrate", 32));
disableGroupVoipAudioProcessing.setConfigBool(preferences.getBoolean("disableGroupVoipAudioProcessing", false));
}
}
public static ConfigItem addConfig(String k, int t, Object d) {