From 4a12bad17c863ca9a026f55fa42b5c420f342103 Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Fri, 12 Nov 2021 12:38:06 +0800 Subject: [PATCH] add more restart tips --- .../java/org/telegram/messenger/SharedConfig.java | 7 +++++++ .../NekoExperimentalSettingsActivity.java | 15 +++++++++++---- .../settings/NekoGeneralSettingsActivity.java | 9 ++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index ef0170549..181b236dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -1842,6 +1842,13 @@ public class SharedConfig { editor.commit(); } + public static void setInappCamera(boolean inappCamera) { + SharedPreferences preferences = MessagesController.getGlobalMainSettings(); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("inappCamera", inappCamera); + editor.commit(); + } + public static void toggleRoundCamera16to9() { roundCamera16to9 = !roundCamera16to9; SharedPreferences preferences = MessagesController.getGlobalMainSettings(); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java index a54a25b57..ab419baf3 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java @@ -213,18 +213,21 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { tooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null); } } else if (key.equals(NekomuraConfig.mediaPreview.getKey())) { - if (NekomuraConfig.mediaPreview.Bool()) { + if ((boolean) newValue) { tooltip.setInfoText(AndroidUtilities.replaceTags(LocaleController.formatString("BetaWarning", R.string.BetaWarning))); tooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null); } } else if (key.equals(NekomuraConfig.enableStickerPin.getKey())) { - if (NekomuraConfig.mediaPreview.Bool()) { + if ((boolean) newValue) { tooltip.setInfoText(AndroidUtilities.replaceTags(LocaleController.formatString("EnableStickerPinTip", R.string.EnableStickerPinTip))); tooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null); } } else if (key.equals(NekomuraConfig.useCustomEmoji.getKey())) { // Check - if (!(boolean) newValue) return; + if (!(boolean) newValue) { + tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); + return; + } NekomuraConfig.useCustomEmoji.setConfigBool(false); // Open picker @@ -265,16 +268,20 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { dir.mkdir(); //process zip - ZipUtil.unzip(new FileInputStream(zipPath), dir); + File zipFile = new File(zipPath); + ZipUtil.unzip(new FileInputStream(zipFile), dir); + zipFile.delete(); if (!new File(ApplicationLoader.applicationContext.getFilesDir(), "custom_emoji/emoji/0_0.png").exists()) { throw new Exception(LocaleController.getString("useCustomEmojiInvalid")); } + NekomuraConfig.useCustomEmoji.setConfigBool(true); } catch (Exception e) { FileLog.e(e); NekomuraConfig.useCustomEmoji.setConfigBool(false); Toast.makeText(ApplicationLoader.applicationContext, "Failed: " + e.toString(), Toast.LENGTH_LONG).show(); } + tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(useCustomEmojiRow)); } } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index fce65c66f..5dce339d3 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -312,14 +312,13 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } } } else if (key.equals(NekomuraConfig.inappCamera.getKey())) { - if (SharedConfig.inappCamera != (boolean) newValue) - SharedConfig.toggleInappCamera(); + SharedConfig.setInappCamera((boolean) newValue); } else if (key.equals(NekomuraConfig.hidePhone.getKey())) { parentLayout.rebuildAllFragmentViews(false, false); getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow)); } else if (key.equals(NekomuraConfig.transparentStatusBar.getKey())) { - AndroidUtilities.runOnUIThread(() -> NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetNewTheme, false)); + restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } else if (key.equals(NekomuraConfig.hideProxySponsorChannel.getKey())) { for (int a : SharedConfig.activeAccounts) { if (UserConfig.getInstance(a).isClientActivated()) { @@ -337,7 +336,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } else if (key.equals(NekomuraConfig.displayPersianCalendarByLatin.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } else if (key.equals(NekomuraConfig.disableSystemAccount.getKey())) { - if (NekomuraConfig.disableSystemAccount.Bool()) { + if ((boolean) newValue) { getContactsController().deleteUnknownAppAccounts(); } else { for (int a : SharedConfig.activeAccounts) { @@ -712,7 +711,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } private void setCanNotChange() { - if(!showCensoredFeatures) + if (!showCensoredFeatures) cellGroup.rows.remove(hideSponsoredMessageRow); boolean enabled;