From 2a6708a4ccf9e01a2f28570c7c95c658b623c0c1 Mon Sep 17 00:00:00 2001 From: luvletter2333 Date: Mon, 17 Jan 2022 15:45:37 +0800 Subject: [PATCH] Refactor nekogram package structure --- .../recyclerview/widget/ItemTouchHelper.java | 4 +- .../recyclerview/widget/RecyclerView.java | 4 +- .../telegram/messenger/AndroidUtilities.java | 17 +- .../telegram/messenger/ApplicationLoader.java | 4 - .../messenger/ContactsController.java | 8 +- .../messenger/DownloadController.java | 6 +- .../java/org/telegram/messenger/Emoji.java | 17 +- .../telegram/messenger/LocaleController.java | 12 +- .../telegram/messenger/MediaController.java | 17 +- .../messenger/MediaDataController.java | 25 +- .../org/telegram/messenger/MessageObject.java | 8 +- .../messenger/MessagesController.java | 51 +- .../telegram/messenger/MessagesStorage.java | 8 +- .../messenger/NotificationsController.java | 16 +- .../messenger/NotificationsService.java | 6 - .../telegram/messenger/SecretChatHelper.java | 1 - .../org/telegram/messenger/SharedConfig.java | 2 +- .../messenger/voip/NativeInstance.java | 4 +- .../telegram/messenger/voip/VoIPService.java | 5 +- .../telegram/tgnet/ConnectionsManager.java | 5 +- .../main/java/org/telegram/tgnet/TLRPC.java | 2 - .../org/telegram/ui/ActionBar/ActionBar.java | 10 +- .../ui/ActionBar/ActionBarLayout.java | 15 +- .../telegram/ui/ActionBar/BaseFragment.java | 6 +- .../java/org/telegram/ui/ActionBar/Theme.java | 16 +- .../org/telegram/ui/ActionIntroActivity.java | 2 +- .../ui/Adapters/DrawerLayoutAdapter.java | 4 +- .../java/org/telegram/ui/ArticleViewer.java | 19 +- .../java/org/telegram/ui/AvatarPreviewer.java | 6 +- .../org/telegram/ui/CacheControlActivity.java | 8 +- .../java/org/telegram/ui/Cells/BaseCell.java | 4 +- .../telegram/ui/Cells/ChatMessageCell.java | 18 +- .../telegram/ui/Cells/ContextLinkCell.java | 5 +- .../org/telegram/ui/Cells/DialogCell.java | 12 +- .../telegram/ui/Cells/DrawerProfileCell.java | 33 +- .../ui/Cells/PhotoAttachPermissionCell.java | 4 +- .../org/telegram/ui/Cells/SharedLinkCell.java | 4 +- .../org/telegram/ui/Cells/StickerSetCell.java | 9 +- .../ui/Cells/TextSelectionHelper.java | 16 +- .../ui/Cells/ThemesHorizontalListCell.java | 6 +- .../telegram/ui/ChannelAdminLogActivity.java | 6 +- .../telegram/ui/ChannelCreateActivity.java | 2 +- .../org/telegram/ui/Charts/BaseChartView.java | 4 +- .../org/telegram/ui/Charts/PieChartView.java | 4 +- .../java/org/telegram/ui/ChatActivity.java | 105 ++-- .../telegram/ui/Components/AlertsCreator.java | 12 +- .../ui/Components/ChatActivityEnterView.java | 78 +-- .../ui/Components/ChatAttachAlert.java | 9 +- .../ChatAttachAlertLocationLayout.java | 2 +- .../ChatAttachAlertPhotoLayout.java | 18 +- .../ui/Components/ChatGreetingsView.java | 5 +- .../ui/Components/EditTextCaption.java | 4 +- .../org/telegram/ui/Components/EmojiView.java | 34 +- .../ui/Components/FilterTabsView.java | 18 +- .../ui/Components/FragmentContextView.java | 6 +- .../telegram/ui/Components/GroupCallPip.java | 8 +- .../telegram/ui/Components/ImageUpdater.java | 2 +- .../ui/Components/InstantCameraView.java | 6 +- .../ui/Components/Paint/Views/EntityView.java | 4 +- .../telegram/ui/Components/PasscodeView.java | 10 +- .../ui/Components/ProximitySheet.java | 4 +- .../ui/Components/RLottieDrawable.java | 6 +- .../ui/Components/RecyclerListView.java | 11 +- .../telegram/ui/Components/ShareAlert.java | 10 +- .../ui/Components/SharedMediaLayout.java | 5 +- .../org/telegram/ui/Components/UndoView.java | 5 +- .../ui/Components/WallpaperUpdater.java | 2 +- .../ui/Components/ZoomControlView.java | 6 +- .../ui/Components/voip/VoIPHelper.java | 4 +- .../org/telegram/ui/ContentPreviewViewer.java | 8 +- .../org/telegram/ui/DataSettingsActivity.java | 11 +- .../telegram/ui/DatabaseMigrationHint.java | 8 +- .../java/org/telegram/ui/DialogsActivity.java | 65 ++- .../telegram/ui/DocumentSelectActivity.java | 6 +- .../telegram/ui/EmojiAnimationsOverlay.java | 4 +- .../org/telegram/ui/FilteredSearchView.java | 2 +- .../org/telegram/ui/GroupCallActivity.java | 18 +- .../org/telegram/ui/GroupCreateActivity.java | 8 +- .../telegram/ui/LanguageSelectActivity.java | 32 +- .../java/org/telegram/ui/LaunchActivity.java | 7 +- .../java/org/telegram/ui/LoginActivity.java | 4 +- .../org/telegram/ui/ManageLinksActivity.java | 4 +- .../telegram/ui/PhotoAlbumPickerActivity.java | 6 +- .../org/telegram/ui/PhotoPickerActivity.java | 7 +- .../java/org/telegram/ui/PhotoViewer.java | 47 +- .../ui/PopupNotificationActivity.java | 4 +- .../java/org/telegram/ui/ProfileActivity.java | 10 +- .../org/telegram/ui/ProxyListActivity.java | 12 +- .../org/telegram/ui/SessionsActivity.java | 12 - .../org/telegram/ui/StickersActivity.java | 22 +- .../ui/TwoStepVerificationActivity.java | 3 +- .../ui/TwoStepVerificationSetupActivity.java | 5 +- .../tw/nekomimi/nekogram/InternalUpdater.java | 62 +- .../java/tw/nekomimi/nekogram/NekoConfig.java | 521 +++++++++++++---- .../tw/nekomimi/nekogram/NekoXConfig.java | 128 ++++- .../nekogram/SaveToDownloadReceiver.java | 2 +- .../{nkmr => nekogram/config}/CellGroup.java | 16 +- .../nekomimi/nekogram/config/ConfigItem.java | 170 ++++++ .../config/cell/AbstractConfigCell.java} | 6 +- .../config/cell/ConfigCellCustom.java} | 6 +- .../config/cell/ConfigCellDivider.java} | 6 +- .../config/cell/ConfigCellHeader.java} | 8 +- .../config/cell/ConfigCellSelectBox.java} | 13 +- .../config/cell/ConfigCellTextCheck.java} | 14 +- .../config/cell/ConfigCellTextDetail.java} | 10 +- .../config/cell/ConfigCellTextInput.java} | 10 +- .../nekomimi/nekogram/parts/MessageTrans.kt | 5 +- .../tw/nekomimi/nekogram/parts/ProxyLoads.kt | 8 +- .../nekomimi/nekogram/parts/ProxySwitcher.kt | 6 +- .../nekogram/{ => proxy}/ProxyManager.kt | 2 +- .../proxy/ShadowsocksRSettingsActivity.java | 2 +- .../proxy/ShadowsocksSettingsActivity.java | 4 +- .../nekogram/proxy/VmessSettingsActivity.java | 2 +- .../tw/nekomimi/nekogram/proxy/WsLoader.kt | 4 +- .../settings/NekoAccountSettingsActivity.java | 2 +- .../settings/NekoChatSettingsActivity.java | 212 +++---- .../NekoExperimentalSettingsActivity.java | 105 ++-- .../settings/NekoGeneralSettingsActivity.java | 241 ++++---- .../StickerSizePreviewMessagesCell.java | 6 +- .../shamsicalendar/PersianCalendar.java | 8 +- .../nekogram/transtale/TranslateDb.kt | 6 +- .../nekomimi/nekogram/transtale/Translator.kt | 11 +- .../transtale/source/GoogleAppTranslator.kt | 9 +- .../transtale/source/GoogleCloudTranslator.kt | 6 +- .../nekogram/{ => ui}/BottomBuilder.kt | 2 +- .../nekogram/{ => ui}/EditTextAutoFill.java | 2 +- .../nekogram/{ => ui}/InternalFilters.java | 2 +- .../{ => ui}/MessageDetailsActivity.java | 2 +- .../nekogram/{ => ui}/MessageHelper.java | 2 +- .../{ => ui}/PinnedStickerHelper.java | 2 +- .../nekogram/{ => ui}/PopupBuilder.kt | 2 +- .../tw/nekomimi/nekogram/utils/AlertUtil.kt | 8 +- .../tw/nekomimi/nekogram/utils/DnsFactory.kt | 13 +- .../tw/nekomimi/nekogram/utils/EnvUtil.kt | 8 +- .../tw/nekomimi/nekogram/utils/FileUtil.kt | 11 + .../tw/nekomimi/nekogram/utils/PGPUtil.kt | 4 +- .../tw/nekomimi/nekogram/utils/ProxyUtil.kt | 2 +- .../tw/nekomimi/nekogram/utils/StrUtil.kt | 20 + .../nekomimi/nekogram/utils/TelegramUtil.java | 47 ++ .../tw/nekomimi/nekogram/utils/VibrateUtil.kt | 4 +- .../java/tw/nekomimi/nkmr/ConfigItem.java | 133 ----- .../java/tw/nekomimi/nkmr/NekomuraConfig.java | 530 ------------------ .../java/tw/nekomimi/nkmr/NekomuraUtil.java | 179 ------ 143 files changed, 1625 insertions(+), 2073 deletions(-) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr => nekogram/config}/CellGroup.java (82%) create mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/ConfigItem.java rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/AbstractCell.java => nekogram/config/cell/AbstractConfigCell.java} (74%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGCustom.java => nekogram/config/cell/ConfigCellCustom.java} (71%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGDivider.java => nekogram/config/cell/ConfigCellDivider.java} (64%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGHeader.java => nekogram/config/cell/ConfigCellHeader.java} (71%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGSelectBox.java => nekogram/config/cell/ConfigCellSelectBox.java} (94%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGTextCheck.java => nekogram/config/cell/ConfigCellTextCheck.java} (81%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGTextDetail.java => nekogram/config/cell/ConfigCellTextDetail.java} (81%) rename TMessagesProj/src/main/java/tw/nekomimi/{nkmr/cells/NekomuraTGTextInput.java => nekogram/config/cell/ConfigCellTextInput.java} (92%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => proxy}/ProxyManager.kt (95%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/BottomBuilder.kt (99%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/EditTextAutoFill.java (94%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/InternalFilters.java (99%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/MessageDetailsActivity.java (99%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/MessageHelper.java (99%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/PinnedStickerHelper.java (99%) rename TMessagesProj/src/main/java/tw/nekomimi/nekogram/{ => ui}/PopupBuilder.kt (97%) create mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/TelegramUtil.java delete mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java delete mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java delete mode 100644 TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraUtil.java diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java index 7bd826e0f..e9470d0ef 100644 --- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java +++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java @@ -44,7 +44,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder; import java.util.ArrayList; import java.util.List; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; /** * This is a utility class to add swipe to dismiss and drag & drop support to RecyclerView. @@ -681,7 +681,7 @@ public class ItemTouchHelper extends RecyclerView.ItemDecoration mSelected = selected; if (actionState == ACTION_STATE_DRAG) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { mSelected.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java index aa70665ce..f50578b39 100644 --- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java +++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java @@ -95,7 +95,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.VibrateUtil; /** @@ -7002,7 +7002,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, try { TraceCompat.beginSection(TRACE_CREATE_VIEW_TAG); final VH holder = onCreateViewHolder(parent, viewType); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(holder.itemView); } if (holder.itemView.getParent() != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 9ce39000b..4602468e4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -39,7 +39,6 @@ import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.media.MediaScannerConnection; import android.net.Uri; import android.os.Build; import android.os.Environment; @@ -154,8 +153,8 @@ import java.util.regex.Pattern; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.EnvUtil; @@ -1362,7 +1361,7 @@ public class AndroidUtilities { public static Typeface getTypeface(String assetPath) { synchronized (typefaceCache) { - if (NekomuraConfig.typeface.Bool() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (NekoConfig.typeface.Bool() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (assetPath.contains("medium") && assetPath.contains("italic")) { return Typeface.create("sans-serif-medium", Typeface.ITALIC); } @@ -1714,7 +1713,7 @@ public class AndroidUtilities { provider = 1; } } else { - if (NekomuraConfig.mapPreviewProvider.Int() == 1) { + if (NekoConfig.mapPreviewProvider.Int() == 1) { provider = 1; } } @@ -1800,7 +1799,7 @@ public class AndroidUtilities { } public static boolean isTablet() { - if (isTablet == null) switch (NekomuraConfig.tabletMode.Int()) { + if (isTablet == null) switch (NekoConfig.tabletMode.Int()) { case 0: isTablet = ApplicationLoader.applicationContext != null && ApplicationLoader.applicationContext.getResources().getBoolean(R.bool.isTablet); break; @@ -4289,14 +4288,14 @@ public class AndroidUtilities { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { final View decorView = window.getDecorView(); int flags = decorView.getSystemUiVisibility(); - if (!SharedConfig.noStatusBar && NekomuraConfig.transparentStatusBar.Bool()) { + if (!SharedConfig.noStatusBar && NekoConfig.transparentStatusBar.Bool()) { window.setStatusBarColor(Color.TRANSPARENT); } if (enable) { if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) == 0) { flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; decorView.setSystemUiVisibility(flags); - if (!SharedConfig.noStatusBar && !NekomuraConfig.transparentStatusBar.Bool()) { + if (!SharedConfig.noStatusBar && !NekoConfig.transparentStatusBar.Bool()) { window.setStatusBarColor(0x0f000000); } } @@ -4304,7 +4303,7 @@ public class AndroidUtilities { if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0) { flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; decorView.setSystemUiVisibility(flags); - if (!SharedConfig.noStatusBar && !NekomuraConfig.transparentStatusBar.Bool()) { + if (!SharedConfig.noStatusBar && !NekoConfig.transparentStatusBar.Bool()) { window.setStatusBarColor(0x33000000); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index fb837bf43..459eff6c3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -29,7 +29,6 @@ import android.os.SystemClock; import android.telephony.TelephonyManager; import android.util.Log; -import androidx.core.app.NotificationManagerCompat; import androidx.multidex.MultiDex; import org.telegram.messenger.voip.VideoCapturerDevice; @@ -42,14 +41,11 @@ import java.io.File; import java.lang.reflect.Method; import java.util.HashSet; import java.util.LinkedList; -import java.util.Set; import tw.nekomimi.nekogram.ExternalGcm; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.parts.SignturesKt; import tw.nekomimi.nekogram.utils.FileUtil; -import tw.nekomimi.nekogram.utils.UIUtil; import static android.os.Build.VERSION.SDK_INT; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java index 43ebb4bdc..71a1470cc 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java @@ -37,7 +37,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import androidx.collection.LongSparseArray; public class ContactsController extends BaseController { @@ -324,7 +324,7 @@ public class ContactsController extends BaseController { AccountManager am = AccountManager.get(ApplicationLoader.applicationContext); if (getUserConfig().isClientActivated()) { readContacts(); - if (systemAccount == null && !NekomuraConfig.disableSystemAccount.Bool()) { + if (systemAccount == null && !NekoConfig.disableSystemAccount.Bool()) { try { TLRPC.User user = getUserConfig().getCurrentUser(); systemAccount = new Account(formatName(user.first_name, user.last_name), BuildConfig.APPLICATION_ID); @@ -343,7 +343,7 @@ public class ContactsController extends BaseController { Account[] accounts = am.getAccountsByType(BuildConfig.APPLICATION_ID); for (int a = 0; a < accounts.length; a++) { Account acc = accounts[a]; - if (NekomuraConfig.disableSystemAccount.Bool()) { + if (NekoConfig.disableSystemAccount.Bool()) { try { am.removeAccount(accounts[a], null, null); } catch (Exception ignore) { @@ -2641,7 +2641,7 @@ public class ContactsController extends BaseController { lastName = lastName.trim(); } StringBuilder result = new StringBuilder((firstName != null ? firstName.length() : 0) + (lastName != null ? lastName.length() : 0) + 1); - if (NekomuraConfig.nameOrder.Int() == 1) { + if (NekoConfig.nameOrder.Int() == 1) { if (firstName != null && firstName.length() > 0) { if (maxLength > 0 && firstName.length() > maxLength + 2) { return firstName.substring(0, maxLength); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DownloadController.java b/TMessagesProj/src/main/java/org/telegram/messenger/DownloadController.java index 5a11ce0d9..64d380667 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/DownloadController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/DownloadController.java @@ -26,7 +26,7 @@ import java.util.HashMap; import androidx.collection.LongSparseArray; import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class DownloadController extends BaseController implements NotificationCenter.NotificationCenterDelegate { @@ -575,9 +575,9 @@ public class DownloadController extends BaseController implements NotificationCe if (messageObject.getDocument() != null) { String documentName = messageObject.getDocument().file_name; if (StrUtil.isNotBlank(documentName)) { - if ((NekomuraConfig.disableAutoDownloadingWin32Executable.Bool() && + if ((NekoConfig.disableAutoDownloadingWin32Executable.Bool() && documentName.toLowerCase().matches(".*\\.(cmd|bat|com|exe|lnk|msi|ps1|reg|vb|vbe|vbs|vbscript)") - ) || (NekomuraConfig.disableAutoDownloadingArchive.Bool() && + ) || (NekoConfig.disableAutoDownloadingArchive.Bool() && documentName.toLowerCase().matches(".*\\.(apk|zip|7z|tar|gz|zst|iso|xz|lha|lzh)") ) ) return false; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java b/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java index 2129c0c3c..fe51dcc1f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Emoji.java @@ -24,7 +24,6 @@ import android.text.TextPaint; import android.text.TextUtils; import android.text.style.DynamicDrawableSpan; import android.text.style.ImageSpan; -import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; @@ -36,12 +35,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Locale; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; import tw.nekomimi.nekogram.EmojiProvider; +import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; public class Emoji { @@ -134,7 +131,7 @@ public class Emoji { try { InputStream is; String entry = "emoji/" + String.format(Locale.US, "%d_%d.png", page, page2); - if (NekomuraConfig.useCustomEmoji.Bool()) { + if (NekoConfig.useCustomEmoji.Bool()) { entry = "custom_emoji/" + entry; is = new FileInputStream(new File(ApplicationLoader.applicationContext.getFilesDir(), entry)); } else { @@ -289,7 +286,7 @@ public class Emoji { b = getBounds(); } - if (!NekomuraConfig.useSystemEmoji.Bool() && EmojiProvider.containsEmoji) { + if (!NekoConfig.useSystemEmoji.Bool() && EmojiProvider.containsEmoji) { if (!isLoaded()) { loadEmoji(info.page, info.page2); canvas.drawRect(getBounds(), placeholderPaint); @@ -301,14 +298,14 @@ public class Emoji { String emoji = fixEmoji(EmojiData.data[info.page][info.emojiIndex]); - if (!NekomuraConfig.useSystemEmoji.Bool() && EmojiProvider.isFont) { + if (!NekoConfig.useSystemEmoji.Bool() && EmojiProvider.isFont) { try { textPaint.setTypeface(EmojiProvider.getFont()); } catch (RuntimeException ignored) { } - } else if (NekomuraConfig.useSystemEmoji.Bool()) { + } else if (NekoConfig.useSystemEmoji.Bool()) { try { - textPaint.setTypeface(NekoConfig.getSystemEmojiTypeface()); + textPaint.setTypeface(NekoXConfig.getSystemEmojiTypeface()); } catch (RuntimeException ignored) { } } @@ -333,7 +330,7 @@ public class Emoji { } public boolean isLoaded() { - if (!EmojiProvider.containsEmoji || NekomuraConfig.useSystemEmoji.Bool()) { + if (!EmojiProvider.containsEmoji || NekoConfig.useSystemEmoji.Bool()) { return true; } return emojiBmp[info.page][info.page2] != null; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java index 5127d561d..d954d08d4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java @@ -24,9 +24,6 @@ import android.text.format.DateFormat; import android.util.Xml; import android.view.Gravity; -import com.google.gson.Gson; -import com.google.gson.JsonObject; - import org.telegram.messenger.support.ArrayUtils; import org.telegram.messenger.time.FastDateFormat; import org.telegram.tgnet.ConnectionsManager; @@ -47,10 +44,9 @@ import java.util.Currency; import java.util.Date; import java.util.HashMap; import java.util.Locale; -import java.util.Map; import java.util.TimeZone; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.parts.LocFiltersKt; import tw.nekomimi.nekogram.shamsicalendar.PersianCalendar; import tw.nekomimi.nekogram.utils.FileUtil; @@ -107,7 +103,7 @@ public class LocaleController { private HashMap translitChars; private HashMap ruTranslitChars; - public static boolean usePersianCalendar = NekomuraConfig.usePersianCalendar.Bool(); // need restart + public static boolean usePersianCalendar = NekoConfig.usePersianCalendar.Bool(); // need restart private class TimeZoneChangedReceiver extends BroadcastReceiver { @Override @@ -1814,7 +1810,7 @@ public class LocaleController { formatterWeekLong = createFormatter(locale, getStringInternal("formatterWeekLong", R.string.formatterWeekLong), "EEEE"); formatterScheduleDay = createFormatter(locale, getStringInternal("formatDateSchedule", R.string.formatDateSchedule), "MMM d"); formatterScheduleYear = createFormatter(locale, getStringInternal("formatDateScheduleYear", R.string.formatDateScheduleYear), "MMM d yyyy"); - formatterDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, (is24HourFormat ? getStringInternal("formatterDay24H", R.string.formatterDay24H) : getStringInternal("formatterDay12H", R.string.formatterDay12H)).replace(":mm", NekomuraConfig.showSeconds.Bool() ? ":mm:ss" : ":mm"), (is24HourFormat ? "HH:mm" : "h:mm a").replace(":mm", NekomuraConfig.showSeconds.Bool() ? ":mm:ss" : ":mm")); + formatterDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, (is24HourFormat ? getStringInternal("formatterDay24H", R.string.formatterDay24H) : getStringInternal("formatterDay12H", R.string.formatterDay12H)).replace(":mm", NekoConfig.showSeconds.Bool() ? ":mm:ss" : ":mm"), (is24HourFormat ? "HH:mm" : "h:mm a").replace(":mm", NekoConfig.showSeconds.Bool() ? ":mm:ss" : ":mm")); formatterStats = createFormatter(locale, is24HourFormat ? getStringInternal("formatterStats24H", R.string.formatterStats24H) : getStringInternal("formatterStats12H", R.string.formatterStats12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a"); formatterBannedUntil = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntil24H", R.string.formatterBannedUntil24H) : getStringInternal("formatterBannedUntil12H", R.string.formatterBannedUntil12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a"); formatterBannedUntilThisYear = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntilThisYear24H", R.string.formatterBannedUntilThisYear24H) : getStringInternal("formatterBannedUntilThisYear12H", R.string.formatterBannedUntilThisYear12H), is24HourFormat ? "MMM dd, HH:mm" : "MMM dd, h:mm a"); @@ -1962,7 +1958,7 @@ public class LocaleController { } public static String formatShortNumber(int number, int[] rounded) { - if (NekomuraConfig.disableNumberRounding.Bool()) { + if (NekoConfig.disableNumberRounding.Bool()) { if (rounded != null) { rounded[0] = number; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 1c447b9c9..a486c3a9e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -61,7 +61,6 @@ import android.widget.FrameLayout; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; -import com.google.android.exoplayer2.util.Log; import org.telegram.messenger.audioinfo.AudioInfo; import org.telegram.messenger.video.MediaCodecVideoConvertor; @@ -83,7 +82,6 @@ import org.telegram.ui.PhotoViewer; import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; @@ -102,7 +100,6 @@ import java.util.concurrent.CountDownLatch; import tw.nekomimi.nekogram.SaveToDownloadReceiver; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.NekoXConfig; public class MediaController implements AudioManager.OnAudioFocusChangeListener, NotificationCenter.NotificationCenterDelegate, SensorEventListener { @@ -574,7 +571,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, private ArrayList recordBuffers = new ArrayList<>(); private ByteBuffer fileBuffer; public int recordBufferSize = 1280; - public int sampleRate = NekomuraConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000; + public int sampleRate = NekoConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000; private int sendAfterDone; private boolean sendAfterDoneNotify; private int sendAfterDoneScheduleDate; @@ -858,7 +855,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, public void recreateProximityWakeLock() { - if (NekomuraConfig.disableProximityEvents.Bool()) { + if (NekoConfig.disableProximityEvents.Bool()) { proximityWakeLock = null; return; } @@ -879,7 +876,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, recordQueue.postRunnable(() -> { try { - sampleRate = NekomuraConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000; + sampleRate = NekoConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000; int minBuferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); if (minBuferSize <= 0) { minBuferSize = 1280; @@ -1434,7 +1431,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } private boolean isNearToSensor(float value) { - return !NekomuraConfig.disableProximityEvents.Bool() && value < 5.0f && value != proximitySensor.getMaximumRange(); + return !NekoConfig.disableProximityEvents.Bool() && value < 5.0f && value != proximitySensor.getMaximumRange(); } public boolean isRecordingOrListeningByProximity() { @@ -3459,7 +3456,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, requestAudioFocus(true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { try { feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } catch (Exception ignore) { @@ -3489,7 +3486,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, recordingAudioFile = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), FileLoader.getAttachFileName(recordingAudio)); try { - if (startRecord(recordingAudioFile.getAbsolutePath(), NekomuraConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000) == 0) { + if (startRecord(recordingAudioFile.getAbsolutePath(), NekoConfig.increaseVoiceMessageQuality.Bool() ? 48000 : 16000) == 0) { AndroidUtilities.runOnUIThread(() -> { recordStartRunnable = null; NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.recordStartError, guid); @@ -3647,7 +3644,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (send == 0) { stopRecordingInternal(0, false, 0); } - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { try { feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } catch (Exception ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index d08057eea..d7c33cd5c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -40,9 +40,6 @@ import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; import androidx.collection.LongSparseArray; -import androidx.core.content.pm.ShortcutInfoCompat; -import androidx.core.content.pm.ShortcutManagerCompat; -import androidx.core.graphics.drawable.IconCompat; import org.telegram.SQLite.SQLiteCursor; import org.telegram.SQLite.SQLiteDatabase; @@ -79,10 +76,8 @@ import java.util.concurrent.CountDownLatch; import java.util.regex.Matcher; import java.util.regex.Pattern; -import androidx.collection.LongSparseArray; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nekogram.NekoXConfig; -import tw.nekomimi.nekogram.PinnedStickerHelper; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.ui.PinnedStickerHelper; @SuppressWarnings("unchecked") public class MediaDataController extends BaseController { @@ -433,7 +428,7 @@ public class MediaDataController extends BaseController { public ArrayList getRecentStickers(int type, int padding) { ArrayList arrayList = recentStickers[type]; - return new ArrayList<>(arrayList.subList(0, Math.min(arrayList.size(), NekomuraConfig.maxRecentStickerCount.Int() + padding))); + return new ArrayList<>(arrayList.subList(0, Math.min(arrayList.size(), NekoConfig.maxRecentStickerCount.Int() + padding))); } public ArrayList getRecentStickersNoCopy(int type) { @@ -495,7 +490,7 @@ public class MediaDataController extends BaseController { AndroidUtilities.runOnUIThread(() -> getMediaDataController().loadRecents(MediaDataController.TYPE_FAVE, false, false, true)); } }); - maxCount = NekomuraConfig.unlimitedFavedStickers.Bool() ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount; + maxCount = NekoConfig.unlimitedFavedStickers.Bool() ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount; } else { if (type == TYPE_IMAGE && remove) { NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.showBulletin, Bulletin.TYPE_STICKER, document, StickerSetBulletinLayout.TYPE_REMOVED_FROM_RECENT); @@ -890,7 +885,7 @@ public class MediaDataController extends BaseController { } public void loadRecents(int type, boolean gif, boolean cache, boolean force) { - if (NekomuraConfig.unlimitedFavedStickers.Bool() && type == TYPE_FAVE && !cache) { + if (NekoConfig.unlimitedFavedStickers.Bool() && type == TYPE_FAVE && !cache) { return; } if (gif) { @@ -1062,7 +1057,7 @@ public class MediaDataController extends BaseController { if (type == TYPE_GREETINGS) { maxCount = 200; } else if (type == TYPE_FAVE) { - maxCount = NekomuraConfig.unlimitedFavedStickers.Bool() ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount; + maxCount = NekoConfig.unlimitedFavedStickers.Bool() ? Integer.MAX_VALUE : getMessagesController().maxFaveStickersCount; } else { maxCount = getMessagesController().maxRecentStickersCount; } @@ -1222,7 +1217,7 @@ public class MediaDataController extends BaseController { } public void loadFeaturedStickers(boolean cache, boolean force) { - if (loadingFeaturedStickers || NekomuraConfig.disableTrending.Bool()) { + if (loadingFeaturedStickers || NekoConfig.disableTrending.Bool()) { return; } loadingFeaturedStickers = true; @@ -1552,7 +1547,7 @@ public class MediaDataController extends BaseController { } else { LongSparseArray newStickerSets = new LongSparseArray<>(); // NekoX: Pin Sticker - if (NekomuraConfig.enableStickerPin.Bool() && type == MediaDataController.TYPE_IMAGE) { + if (NekoConfig.enableStickerPin.Bool() && type == MediaDataController.TYPE_IMAGE) { PinnedStickerHelper ins = PinnedStickerHelper.getInstance(UserConfig.selectedAccount); if (ins.reorderPinnedStickersForSS(res.sets, true)) AndroidUtilities.runOnUIThread(() -> { @@ -2071,7 +2066,7 @@ public class MediaDataController extends BaseController { int type = stickerSet.masks ? TYPE_MASK : TYPE_IMAGE; - if (NekomuraConfig.enableStickerPin.Bool() && type == MediaDataController.TYPE_IMAGE && (toggle == 0 || toggle == 1)) { + if (NekoConfig.enableStickerPin.Bool() && type == MediaDataController.TYPE_IMAGE && (toggle == 0 || toggle == 1)) { PinnedStickerHelper.getInstance(currentAccount).removePinnedStickerLocal(stickerSet.id); } @@ -2108,7 +2103,7 @@ public class MediaDataController extends BaseController { toggleStickerSetInternal(context, toggle, baseFragment, showSettings, stickerSetObject, stickerSet, type, false); } else { StickerSetBulletinLayout bulletinLayout = new StickerSetBulletinLayout(context, stickerSetObject, toggle); - int finalCurrentIndex = NekomuraConfig.enableStickerPin.Bool() && type == TYPE_IMAGE && PinnedStickerHelper.getInstance(UserConfig.selectedAccount).isPinned(stickerSet.id) + int finalCurrentIndex = NekoConfig.enableStickerPin.Bool() && type == TYPE_IMAGE && PinnedStickerHelper.getInstance(UserConfig.selectedAccount).isPinned(stickerSet.id) ? PinnedStickerHelper.getInstance(UserConfig.selectedAccount).pinnedList.size() : currentIndex; // NekoX: Pin Sticker, Fix undo for Archiving and Deleting diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 0e3e851d3..566e8c055 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -59,18 +59,14 @@ import java.util.Collections; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; -import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; -import androidx.collection.LongSparseArray; -import androidx.core.math.MathUtils; - public class MessageObject { public static final int MESSAGE_SEND_STATE_SENT = 0; @@ -3047,7 +3043,7 @@ public class MessageObject { } else { isRestrictedMessage = false; String restrictionReason = MessagesController.getRestrictionReason(messageOwner.restriction_reason); - if (!TextUtils.isEmpty(restrictionReason) && !NekomuraConfig.ignoreContentRestrictions.Bool()) { + if (!TextUtils.isEmpty(restrictionReason) && !NekoConfig.ignoreContentRestrictions.Bool()) { messageText = restrictionReason; isRestrictedMessage = true; } else if (!isMediaEmpty()) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 96a93d79b..333a14d9f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -69,9 +69,8 @@ import java.util.stream.Collectors; import cn.hutool.core.thread.ThreadUtil; import tw.nekomimi.nekogram.ExternalGcm; -import tw.nekomimi.nekogram.InternalFilters; +import tw.nekomimi.nekogram.ui.InternalFilters; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.UIUtil; @@ -659,25 +658,25 @@ public class MessagesController extends BaseController implements NotificationCe boolean is1user = !DialogObject.isChannel(dialog1) && dialog1.id > 0; boolean is2user = !DialogObject.isChannel(dialog2) && dialog2.id > 0; - if (NekomuraConfig.sortByUnread.Bool()) { + if (NekoConfig.sortByUnread.Bool()) { if (dialog1.unread_count == 0 && dialog2.unread_count > 0) { return 1; } else if (dialog1.unread_count > 0 && dialog2.unread_count == 0) { return -1; } else if (dialog1.unread_count > 0 && dialog2.unread_count > 0) { - if (NekomuraConfig.sortByUnmuted.Bool()) { + if (NekoConfig.sortByUnmuted.Bool()) { if (isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) { return 1; } else if (!isDialogMuted(dialog1.id) && isDialogMuted(dialog2.id)) { return -1; } else if (!isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) { - if (NekomuraConfig.sortByUser.Bool()) { + if (NekoConfig.sortByUser.Bool()) { if (!is1user && is2user) { return 1; } else if (is1user && !is2user) { return -1; } else if (is1user && is2user) { - if (NekomuraConfig.sortByContacts.Bool()) { + if (NekoConfig.sortByContacts.Bool()) { boolean is1contact = is1user && getContactsController().isContact((int) dialog1.id); boolean is2contact = is2user && getContactsController().isContact((int) dialog2.id); if (!is1contact && is2contact) { @@ -699,19 +698,19 @@ public class MessagesController extends BaseController implements NotificationCe return 0; } } - } else if (NekomuraConfig.sortByUnmuted.Bool()) { + } else if (NekoConfig.sortByUnmuted.Bool()) { if (dialog1.unread_count == 0 && dialog2.unread_count > 0 && isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) { return 1; } else if (dialog1.unread_count > 0 && dialog2.unread_count == 0 && !isDialogMuted(dialog1.id) && isDialogMuted(dialog2.id)) { return -1; } else if (dialog1.unread_count > 0 && dialog2.unread_count > 0 && !isDialogMuted(dialog1.id) && !isDialogMuted(dialog2.id)) { - if (NekomuraConfig.sortByUser.Bool()) { + if (NekoConfig.sortByUser.Bool()) { if (!is1user && is2user) { return 1; } else if (is1user && !is2user) { return -1; } else if (is1user && is2user) { - if (NekomuraConfig.sortByContacts.Bool()) { + if (NekoConfig.sortByContacts.Bool()) { boolean is1contact = is1user && getContactsController().isContact((int) dialog1.id); boolean is2contact = is2user && getContactsController().isContact((int) dialog2.id); if (!is1contact && is2contact) { @@ -4336,7 +4335,7 @@ public class MessagesController extends BaseController implements NotificationCe } loadingBlockedPeers = false; getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad); - if (!reset && !blockedEndReached && NekomuraConfig.ignoreBlocked.Bool()) { + if (!reset && !blockedEndReached && NekoConfig.ignoreBlocked.Bool()) { getBlockedPeers(false); } } @@ -5893,7 +5892,7 @@ public class MessagesController extends BaseController implements NotificationCe TLRPC.TL_help_promoData res = (TLRPC.TL_help_promoData) response; SharedConfig.ProxyInfo proxy = SharedConfig.currentProxy; - if (res.proxy && (NekomuraConfig.hideProxySponsorChannel.Bool() || (proxy != null && proxy.subId == 1L))) { + if (res.proxy && (NekoConfig.hideProxySponsorChannel.Bool() || (proxy != null && proxy.subId == 1L))) { nextPromoInfoCheckTime = getConnectionsManager().getCurrentTime() + 60 * 60; noDialog = true; } else { @@ -6165,7 +6164,7 @@ public class MessagesController extends BaseController implements NotificationCe newStrings.put(key, newPrintingStrings); newTypes.put(key, newPrintingStringsTypes); - if (NekomuraConfig.ignoreBlocked.Bool()) { + if (NekoConfig.ignoreBlocked.Bool()) { arr = arr.stream().filter(it -> getMessagesController().blockePeers.indexOfKey(it.userId) == -1).collect(Collectors.toCollection(ArrayList::new)); } @@ -6345,7 +6344,7 @@ public class MessagesController extends BaseController implements NotificationCe } public boolean sendTyping(long dialogId, int threadMsgId, int action, String emojicon, int classGuid) { - if (NekomuraConfig.disableChatAction.Bool()) return false; + if (NekoConfig.disableChatAction.Bool()) return false; if (action < 0 || action >= sendingTypings.length || dialogId == 0) { return false; } @@ -6415,7 +6414,7 @@ public class MessagesController extends BaseController implements NotificationCe } else if (action == 9) { req.action = new TLRPC.TL_sendMessageUploadAudioAction(); } else if (action == 10) { - if (NekomuraConfig.disableChoosingSticker.Bool()) + if (NekoConfig.disableChoosingSticker.Bool()) req.action = new TLRPC.TL_sendMessageTypingAction(); else req.action = new TLRPC.TL_sendMessageChooseStickerAction(); @@ -7897,7 +7896,7 @@ public class MessagesController extends BaseController implements NotificationCe TLRPC.Message lastMessage = null; for (int a = 0; a < dialogsRes.messages.size(); a++) { TLRPC.Message message = dialogsRes.messages.get(a); - if (NekomuraConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(message.peer_id.user_id) >= 0) { + if (NekoConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(message.peer_id.user_id) >= 0) { continue; } if (lastMessage == null || message.date < lastMessage.date) { @@ -11069,7 +11068,7 @@ public class MessagesController extends BaseController implements NotificationCe newTaskId = taskId; } - if (!NekomuraConfig.unlimitedPinnedDialogs.Bool()) getConnectionsManager().sendRequest(req, (response, error) -> { + if (!NekoConfig.unlimitedPinnedDialogs.Bool()) getConnectionsManager().sendRequest(req, (response, error) -> { if (newTaskId != 0) { getMessagesStorage().removePendingTask(newTaskId); } @@ -11081,7 +11080,7 @@ public class MessagesController extends BaseController implements NotificationCe } public void loadPinnedDialogs(final int folderId, long newDialogId, ArrayList order) { - if (NekomuraConfig.unlimitedPinnedDialogs.Bool()) { + if (NekoConfig.unlimitedPinnedDialogs.Bool()) { return; } if (loadingPinnedDialogs.indexOfKey(folderId) >= 0 || getUserConfig().isPinnedDialogsLoaded(folderId)) { @@ -14298,7 +14297,7 @@ public class MessagesController extends BaseController implements NotificationCe message.entities = sponsoredMessage.entities; message.flags |= 128; } - if (NekomuraConfig.hideSponsoredMessage.Bool()) + if (NekoConfig.hideSponsoredMessage.Bool()) message.hide = true; message.peer_id = getPeer(dialogId); message.from_id = sponsoredMessage.from_id; @@ -14619,7 +14618,7 @@ public class MessagesController extends BaseController implements NotificationCe dialog.top_message = lastMessage.getId(); dialog.last_message_date = lastMessage.messageOwner.date; changed = true; - if(NekomuraConfig.ignoreBlocked.Bool() && blockePeers.indexOfKey(lastMessage.getSenderId())>=0){ + if(NekoConfig.ignoreBlocked.Bool() && blockePeers.indexOfKey(lastMessage.getSenderId())>=0){ MessageObject preMsg = dialogMessage.get(dialogId); if(blockePeers.indexOfKey(preMsg.getSenderId())<0) dialogMessageFromUnblocked.put(dialogId, preMsg); @@ -14760,10 +14759,10 @@ public class MessagesController extends BaseController implements NotificationCe } catch (Exception e) { - NekomuraConfig.sortByUnread.setConfigBool(false); - NekomuraConfig.sortByUnmuted.setConfigBool(false); - NekomuraConfig.sortByUser.setConfigBool(false); - NekomuraConfig.sortByContacts.setConfigBool(false); + NekoConfig.sortByUnread.setConfigBool(false); + NekoConfig.sortByUnmuted.setConfigBool(false); + NekoConfig.sortByUser.setConfigBool(false); + NekoConfig.sortByContacts.setConfigBool(false); try { @@ -14899,7 +14898,7 @@ public class MessagesController extends BaseController implements NotificationCe } for (int a = 0, N = reasons.size(); a < N; a++) { TLRPC.TL_restrictionReason reason = reasons.get(a); - if ("all".equals(reason.platform) || !AndroidUtilities.isStandaloneApp() && !AndroidUtilities.isBetaApp() && "android".equals(reason.platform) && !NekomuraConfig.ignoreContentRestrictions.Bool()) { + if ("all".equals(reason.platform) || !AndroidUtilities.isStandaloneApp() && !AndroidUtilities.isBetaApp() && "android".equals(reason.platform) && !NekoConfig.ignoreContentRestrictions.Bool()) { return reason.text; } } @@ -14939,7 +14938,7 @@ public class MessagesController extends BaseController implements NotificationCe } if (reason != null) { showCantOpenAlert(fragment, reason); - if (!NekomuraConfig.ignoreContentRestrictions.Bool()) return false; + if (!NekoConfig.ignoreContentRestrictions.Bool()) return false; } if (messageId != 0 && originalMessage != null && chat != null && chat.access_hash == 0) { long did = originalMessage.getDialogId(); @@ -15004,7 +15003,7 @@ public class MessagesController extends BaseController implements NotificationCe } if (reason != null) { showCantOpenAlert(fragment, reason); - if (!NekomuraConfig.ignoreContentRestrictions.Bool()) return; + if (!NekoConfig.ignoreContentRestrictions.Bool()) return; } Bundle args = new Bundle(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index e6c5693a6..f850c9c5a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -21,7 +21,6 @@ import android.util.SparseIntArray; import androidx.annotation.UiThread; -import androidx.annotation.UiThread; import androidx.collection.LongSparseArray; import org.telegram.PhoneFormat.PhoneFormat; @@ -52,8 +51,7 @@ import java.util.concurrent.atomic.AtomicLong; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; -import androidx.collection.LongSparseArray; +import tw.nekomimi.nekogram.NekoConfig; public class MessagesStorage extends BaseController { @@ -2565,7 +2563,7 @@ public class MessagesStorage extends BaseController { continue; } flags = filter.flags; - if (NekomuraConfig.ignoreMutedCount.Bool() && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { + if (NekoConfig.ignoreMutedCount.Bool() && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { flags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED; } } else { @@ -4735,7 +4733,7 @@ public class MessagesStorage extends BaseController { } unreadCount = filter.pendingUnreadCount; flags = filter.flags; - if (NekomuraConfig.ignoreMutedCount.Bool() && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { + if (NekoConfig.ignoreMutedCount.Bool() && (flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0) { flags |= MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED; } } else { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index 9b6deda8a..ec54c1f63 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -21,7 +21,6 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; @@ -45,7 +44,6 @@ import android.os.SystemClock; import android.provider.Settings; import android.text.TextUtils; import android.util.SparseArray; -import android.util.SparseIntArray; import androidx.collection.LongSparseArray; @@ -58,14 +56,10 @@ import androidx.core.content.LocusIdCompat; import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; -import android.text.TextUtils; -import android.util.SparseArray; -import org.json.JSONArray; import org.telegram.messenger.support.LongSparseIntArray; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; -import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.BubbleActivity; import org.telegram.ui.LaunchActivity; import org.telegram.ui.PopupNotificationActivity; @@ -78,8 +72,8 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; +import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; public class NotificationsController extends BaseController { @@ -784,7 +778,7 @@ public class NotificationsController extends BaseController { messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined))) { continue; } - if (NekomuraConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { + if (NekoConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { continue; } @@ -3746,7 +3740,7 @@ public class NotificationsController extends BaseController { .setGroupSummary(true) .setShowWhen(true) .setWhen(((long) lastMessageObject.messageOwner.date) * 1000) - .setColor(NekoConfig.getNotificationColor()); + .setColor(NekoXConfig.getNotificationColor()); long[] vibrationPattern = null; Uri sound = null; @@ -4238,7 +4232,7 @@ public class NotificationsController extends BaseController { int rowsMid = 0; for (int a = messageObjects.size() - 1; a >= 0; a--) { MessageObject messageObject = messageObjects.get(a); - if (NekomuraConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { + if (NekoConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messageObject.getSenderId()) >= 0) { continue; } String message = getShortStringForMessage(messageObject, senderName, preview); @@ -4454,7 +4448,7 @@ public class NotificationsController extends BaseController { .setContentText(text.toString()) .setAutoCancel(true) .setNumber(messageObjects.size()) - .setColor(NekoConfig.getNotificationColor()) + .setColor(NekoXConfig.getNotificationColor()) .setGroupSummary(false) .setWhen(date) .setShowWhen(true) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java index 15cd4b49f..b31be3383 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java @@ -11,21 +11,15 @@ package org.telegram.messenger; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; -import android.app.PendingIntent; import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.net.Uri; import android.os.Build; import android.os.IBinder; -import android.provider.Settings; import androidx.core.app.NotificationCompat; -import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; - public class NotificationsService extends Service { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java index 520c70090..e934c9d6f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java @@ -32,7 +32,6 @@ import java.util.Collections; import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.utils.AlertUtil; public class SecretChatHelper extends BaseController { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 4dbb79ef2..fe14df273 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -54,7 +54,7 @@ import java.util.stream.Collectors; import cn.hutool.core.util.StrUtil; import okhttp3.HttpUrl; -import tw.nekomimi.nekogram.ProxyManager; +import tw.nekomimi.nekogram.proxy.ProxyManager; import tw.nekomimi.nekogram.proxy.ShadowsocksLoader; import tw.nekomimi.nekogram.proxy.ShadowsocksRLoader; import tw.nekomimi.nekogram.proxy.VmessLoader; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/NativeInstance.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/NativeInstance.java index 68513c38c..63406ec35 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/NativeInstance.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/NativeInstance.java @@ -11,7 +11,7 @@ import org.webrtc.VideoSink; import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class NativeInstance { @@ -74,7 +74,7 @@ public class NativeInstance { instance.requestBroadcastPartCallback = requestBroadcastPartCallback; instance.cancelRequestBroadcastPartCallback = cancelRequestBroadcastPartCallback; instance.isGroup = true; - instance.nativePtr = makeGroupNativeInstance(instance, logPath, SharedConfig.disableVoiceAudioEffects, videoCapturer, screencast, noiseSupression, (short) NekomuraConfig.customAudioBitrate.Int()); + instance.nativePtr = makeGroupNativeInstance(instance, logPath, SharedConfig.disableVoiceAudioEffects, videoCapturer, screencast, noiseSupression, (short) NekoConfig.customAudioBitrate.Int()); return instance; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java index 8e0f32756..602b70d06 100755 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java @@ -37,7 +37,6 @@ import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Icon; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; @@ -133,7 +132,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; @SuppressLint("NewApi") public class VoIPService extends Service implements SensorEventListener, AudioManager.OnAudioFocusChangeListener, VoIPController.ConnectionStateListener, NotificationCenter.NotificationCenterDelegate { @@ -3435,7 +3434,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa } private void loadResources() { - if (NekomuraConfig.useMediaStreamInVoip.Bool()) { + if (NekoConfig.useMediaStreamInVoip.Bool()) { currentStreamType = AudioManager.STREAM_MUSIC; if (Build.VERSION.SDK_INT >= 21) WebRtcAudioTrack.setAudioTrackUsageAttribute(AudioAttributes.USAGE_MEDIA); diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java index adaea21c3..e2cdbb85c 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java @@ -9,7 +9,6 @@ import android.text.TextUtils; import android.util.Base64; import android.util.SparseArray; -import com.google.android.exoplayer2.util.Log; import com.v2ray.ang.util.Utils; import org.telegram.messenger.AccountInstance; @@ -50,7 +49,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.parts.ProxySwitcher; import tw.nekomimi.nekogram.utils.DnsFactory; @@ -881,7 +880,7 @@ public class ConnectionsManager extends BaseController { if (!hasIpv4) { ipStrategy = USE_IPV6_ONLY; } - if (NekomuraConfig.useIPv6.Bool()) { + if (NekoConfig.useIPv6.Bool()) { ipStrategy = USE_IPV4_IPV6_RANDOM; } return ipStrategy; diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index 73e3fe008..c018eab40 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -22,9 +22,7 @@ import java.util.ArrayList; import java.util.HashMap; import cn.hutool.core.util.ArrayUtil; -import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; -import tw.nekomimi.nkmr.NekomuraConfig; @SuppressWarnings("unchecked") public class TLRPC { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index fa505cee1..9bed98ba8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -41,7 +41,6 @@ import android.view.ViewPropertyAnimator; import android.widget.FrameLayout; import android.widget.ImageView; -import org.checkerframework.checker.units.qual.A; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; @@ -55,8 +54,7 @@ import org.telegram.ui.Components.SnowflakesEffect; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ActionBar extends FrameLayout { @@ -264,11 +262,11 @@ public class ActionBar extends FrameLayout { } } } - if (NekomuraConfig.actionBarDecoration.Int() == 2) { + if (NekoConfig.actionBarDecoration.Int() == 2) { if (fireworksEffect == null) { fireworksEffect = new FireworksEffect(); } - } else if (NekomuraConfig.actionBarDecoration.Int() == 1 || Theme.canStartHolidayAnimation()) { + } else if (NekoConfig.actionBarDecoration.Int() == 1 || Theme.canStartHolidayAnimation()) { if (snowflakesEffect == null) { snowflakesEffect = new SnowflakesEffect(0); } @@ -1580,7 +1578,7 @@ public class ActionBar extends FrameLayout { } public void unreadBadgeSetCount(int count) { - if (backButtonImageView != null && NekomuraConfig.unreadBadgeOnBackButton.Bool()) { + if (backButtonImageView != null && NekoConfig.unreadBadgeOnBackButton.Bool()) { backButtonImageView.setUnread(count); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index 4893b78fd..e42695d5e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -40,7 +40,6 @@ import android.widget.FrameLayout; import androidx.annotation.Keep; -import androidx.annotation.Keep; import androidx.core.graphics.ColorUtils; import androidx.core.math.MathUtils; @@ -57,7 +56,7 @@ import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; import java.util.HashMap; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.VibrateUtil; public class ActionBarLayout extends FrameLayout { @@ -338,7 +337,7 @@ public class ActionBarLayout extends FrameLayout { if (layerShadowDrawable == null) { layerShadowDrawable = getResources().getDrawable(R.drawable.layer_shadow); - headerShadowDrawable = NekomuraConfig.disableAppBarShadow.Bool() ? null : getResources().getDrawable(R.drawable.header_shadow).mutate(); + headerShadowDrawable = NekoConfig.disableAppBarShadow.Bool() ? null : getResources().getDrawable(R.drawable.header_shadow).mutate(); scrimPaint = new Paint(); } } @@ -665,7 +664,7 @@ public class ActionBarLayout extends FrameLayout { View fragmentView = lastFragment.fragmentView; if (fragmentView == null) { fragmentView = lastFragment.createView(parentActivity); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(fragmentView); } } @@ -1081,7 +1080,7 @@ public class ActionBarLayout extends FrameLayout { View fragmentView = fragment.fragmentView; if (fragmentView == null) { fragmentView = fragment.createView(parentActivity); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(fragmentView); } } else { @@ -1432,7 +1431,7 @@ public class ActionBarLayout extends FrameLayout { } }); animatorSet.start(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } @@ -1479,7 +1478,7 @@ public class ActionBarLayout extends FrameLayout { View fragmentView = previousFragment.fragmentView; if (fragmentView == null) { fragmentView = previousFragment.createView(parentActivity); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(fragmentView); } } @@ -1667,7 +1666,7 @@ public class ActionBarLayout extends FrameLayout { View fragmentView = previousFragment.fragmentView; if (fragmentView == null) { fragmentView = previousFragment.createView(parentActivity); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(fragmentView); } } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index 1016b6c92..3e3726091 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -50,9 +50,9 @@ import org.telegram.ui.Components.LayoutHelper; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.VibrateUtil; -import tw.nekomimi.nekogram.MessageHelper; +import tw.nekomimi.nekogram.ui.MessageHelper; public abstract class BaseFragment { @@ -191,7 +191,7 @@ public abstract class BaseFragment { public void setParentFragment(BaseFragment fragment) { setParentLayout(fragment.parentLayout); fragmentView = createView(parentLayout.getContext()); - if (NekomuraConfig.disableVibration.Bool()) { + if (NekoConfig.disableVibration.Bool()) { VibrateUtil.disableHapticFeedback(fragmentView); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index ea2d87f1a..3dca0935c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -67,10 +67,6 @@ import androidx.core.graphics.ColorUtils; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.annotation.UiThread; -import androidx.core.graphics.ColorUtils; - -import com.google.android.exoplayer2.util.Log; import org.json.JSONArray; import org.json.JSONObject; @@ -135,11 +131,7 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.CountDownLatch; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.UiThread; -import androidx.core.graphics.ColorUtils; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class Theme { @@ -4877,7 +4869,7 @@ public class Theme { themeInfo.previewOutColor = 0xffd0e6ff; themeInfo.sortIndex = 1; themeInfo.firstAccentIsDefault = true; - if (NekomuraConfig.useDefaultTheme.Bool()) + if (NekoConfig.useDefaultTheme.Bool()) themeInfo.currentAccentId = DEFALT_THEME_ACCENT_ID; themeInfo.setAccentColorOptions( new int[] { 0xFF5890C5, 0xFF239853, 0xFFCE5E82, 0xFF7F63C3, 0xFF2491AD, 0xFF299C2F, 0xFF8854B4, 0xFF328ACF, 0xFF43ACC7, 0xFF52AC44, 0xFFCD5F93, 0xFFD28036, 0xFF8366CC, 0xFFCE4E57, 0xFFD3AE40, 0xFF7B88AB }, @@ -4903,7 +4895,7 @@ public class Theme { themeInfo.previewInColor = Color.parseColor("#c0ffffff"); themeInfo.previewOutColor = Color.parseColor("#3f51b5"); themeInfo.sortIndex = 0; - if (!NekomuraConfig.useDefaultTheme.Bool()) + if (!NekoConfig.useDefaultTheme.Bool()) themeInfo.currentAccentId = DEFALT_THEME_ACCENT_ID; themes.add(themeInfo); themesDict.put("NekoX", themeInfo); @@ -5581,7 +5573,7 @@ public class Theme { canStartHolidayAnimation = false; } if (dialogs_holidayDrawable == null) { - if (getEventType() == 0 || NekomuraConfig.newYear.Bool()) { + if (getEventType() == 0 || NekoConfig.newYear.Bool()) { dialogs_holidayDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.newyear); dialogs_holidayDrawableOffsetX = -AndroidUtilities.dp(3); dialogs_holidayDrawableOffsetY = -AndroidUtilities.dp(1); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java index ad34e892d..2213fddee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java @@ -59,7 +59,7 @@ import org.telegram.ui.Components.voip.CellFlickerDrawable; import java.util.ArrayList; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; @TargetApi(23) public class ActionIntroActivity extends BaseFragment implements LocationController.LocationFetchCallback { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java index 9dc04e5e5..bb36a2f95 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java @@ -41,7 +41,7 @@ import java.util.Collections; import cn.hutool.core.util.StrUtil; import kotlin.jvm.functions.Function0; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter implements NotificationCenter.NotificationCenterDelegate { @@ -273,7 +273,7 @@ public class DrawerLayoutAdapter extends RecyclerListView.SelectionAdapter imple items.add(new Item(11, LocaleController.getString("SavedMessages", R.string.SavedMessages), savedIcon)); items.add(new Item(8, LocaleController.getString("Settings", R.string.Settings), settingsIcon)); items.add(new Item(10, LocaleController.getString("Calls", R.string.Calls), callsIcon)); - if (NekomuraConfig.useProxyItem.Bool() && (!NekomuraConfig.hideProxyByDefault.Bool() || SharedConfig.proxyEnabled)) { + if (NekoConfig.useProxyItem.Bool() && (!NekoConfig.hideProxyByDefault.Bool() || SharedConfig.proxyEnabled)) { items.add(new CheckItem(13, LocaleController.getString("Proxy", R.string.Proxy), R.drawable.baseline_security_24, () -> SharedConfig.proxyEnabled, () -> { SharedConfig.setProxyEnable(!SharedConfig.proxyEnabled); return true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java index c7af1092f..5d58a7d7d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java @@ -177,18 +177,13 @@ import java.util.Locale; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.parts.ArticleTransKt; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; -import static org.telegram.messenger.MessageObject.POSITION_FLAG_BOTTOM; -import static org.telegram.messenger.MessageObject.POSITION_FLAG_LEFT; -import static org.telegram.messenger.MessageObject.POSITION_FLAG_RIGHT; -import static org.telegram.messenger.MessageObject.POSITION_FLAG_TOP; - public class ArticleViewer implements NotificationCenter.NotificationCenterDelegate { public Activity parentActivity; @@ -1097,7 +1092,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg if (checkingForLongPress && windowView != null) { checkingForLongPress = false; if (pressedLink != null) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } showCopyPopup(pressedLink.getUrl()); @@ -1112,11 +1107,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg } else { textSelectionHelper.trySelect(pressedLinkOwnerView); } - if (textSelectionHelper.isSelectionMode() && !NekomuraConfig.disableVibration.Bool()) { + if (textSelectionHelper.isSelectionMode() && !NekoConfig.disableVibration.Bool()) { windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } else if (pressedLinkOwnerLayout != null && pressedLinkOwnerView != null) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } int[] location = new int[2]; @@ -10330,9 +10325,9 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg String currentUrl = AndroidUtilities.formapMapUrl(false, currentBlock.geo.lat, currentBlock.geo._long, (int) (photoWidth / AndroidUtilities.density), (int) (height / AndroidUtilities.density), true, 15); WebFile currentWebFile = WebFile.createWithGeoPoint(currentBlock.geo, (int) (photoWidth / AndroidUtilities.density), (int) (height / AndroidUtilities.density), 15, Math.min(2, (int) Math.ceil(AndroidUtilities.density))); - if (NekomuraConfig.mapPreviewProvider.Int() == 0) { + if (NekoConfig.mapPreviewProvider.Int() == 0) { currentMapProvider = 2; - } else if (NekomuraConfig.mapPreviewProvider.Int() == 1) { + } else if (NekoConfig.mapPreviewProvider.Int() == 1) { currentMapProvider = 1; } else { currentMapProvider = -1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java b/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java index 306df9b17..b979d6559 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/AvatarPreviewer.java @@ -44,8 +44,8 @@ import org.telegram.ui.Components.MediaActionDrawable; import org.telegram.ui.Components.RadialProgress2; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; public class AvatarPreviewer { @@ -436,7 +436,7 @@ public class AvatarPreviewer { } else { moveProgress = Math.max(-1, Math.min(0f, (event.getY() - downY) / AndroidUtilities.dp(56))); if (moveProgress == -1) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } moveAnimator = ValueAnimator.ofFloat(moveProgress, 0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java index 90d4633db..d3867d03b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java @@ -15,9 +15,7 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Environment; import android.os.StatFs; -import android.provider.Settings; import android.os.SystemClock; -import android.text.TextUtils; import android.transition.ChangeBounds; import android.transition.Fade; import android.transition.TransitionManager; @@ -28,7 +26,6 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; -import androidx.annotation.RequiresApi; import androidx.core.widget.NestedScrollView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -41,9 +38,6 @@ import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.messenger.AccountInstance; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.BuildConfig; -import org.telegram.messenger.BuildVars; import org.telegram.messenger.DialogObject; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; @@ -85,7 +79,7 @@ import java.util.ArrayList; import cn.hutool.core.thread.ThreadUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.utils.EnvUtil; import tw.nekomimi.nekogram.utils.FileUtil; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java index e34bfe3e9..386b69343 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java @@ -15,7 +15,7 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.ViewGroup; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public abstract class BaseCell extends ViewGroup { @@ -35,7 +35,7 @@ public abstract class BaseCell extends ViewGroup { public void run() { if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) { checkingForLongPress = false; - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } if (onLongPress()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 2e9683478..99263c0ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -68,8 +68,6 @@ import android.widget.Toast; import androidx.core.graphics.ColorUtils; -import com.google.android.exoplayer2.util.Log; - import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ChatObject; @@ -153,7 +151,7 @@ import java.util.Locale; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate, ImageReceiver.ImageReceiverDelegate, DownloadController.FileDownloadProgressListener, TextSelectionHelper.SelectableView, NotificationCenter.NotificationCenterDelegate { @@ -953,7 +951,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate private boolean needHideMessage() { return currentMessageObject.messageOwner.hide || MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(currentMessageObject.getFromChatId()) >= 0 && - NekomuraConfig.ignoreBlocked.Bool() && !(getParent() != null && getParent().getClass().getName().contains("ChannelAdminLogActivity")); + NekoConfig.ignoreBlocked.Bool() && !(getParent() != null && getParent().getClass().getName().contains("ChannelAdminLogActivity")); } public ChatMessageCell(Context context) { @@ -5058,7 +5056,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } int maxVote = 0; - if (!animatePollAnswer && pollVoteInProgress && vibrateOnPollVote && !NekomuraConfig.disableVibration.Bool()) { + if (!animatePollAnswer && pollVoteInProgress && vibrateOnPollVote && !NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } animatePollAnswerAlpha = animatePollAnswer = attachedToWindow && (pollVoteInProgress || pollUnvoteInProgress); @@ -5489,9 +5487,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate currentMapProvider = -1; } } else { - if (NekomuraConfig.mapPreviewProvider.Int() == 0) { + if (NekoConfig.mapPreviewProvider.Int() == 0) { currentMapProvider = 2; - } else if (NekomuraConfig.mapPreviewProvider.Int() == 1) { + } else if (NekoConfig.mapPreviewProvider.Int() == 1) { currentMapProvider = 1; } else { currentMapProvider = -1; @@ -5540,10 +5538,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate float maxHeight; int maxWidth; if (AndroidUtilities.isTablet()) { - maxHeight = AndroidUtilities.getMinTabletSide() * (0.4f + (NekomuraConfig.stickerSize.Float() - 14.0f) / 40); + maxHeight = AndroidUtilities.getMinTabletSide() * (0.4f + (NekoConfig.stickerSize.Float() - 14.0f) / 40); maxWidth = (int) maxHeight; } else { - maxHeight = Math.min(getParentWidth(), AndroidUtilities.displaySize.y) * (0.5f + (NekomuraConfig.stickerSize.Float() - 14.0f) / 30); + maxHeight = Math.min(getParentWidth(), AndroidUtilities.displaySize.y) * (0.5f + (NekoConfig.stickerSize.Float() - 14.0f) / 30); maxWidth = (int) maxHeight; } String filter; @@ -11012,7 +11010,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if ((!autoPlayingMedia || !MediaController.getInstance().isPlayingMessageAndReadyToDraw(currentMessageObject) || isRoundVideo) && !transitionParams.animateBackgroundBoundsInner) { drawOverlays(canvas); } - if ((drawTime || !mediaBackground) && !forceNotDrawTime && !transitionParams.animateBackgroundBoundsInner && !(enterTransitionInPorgress && !currentMessageObject.isVoice()) && (!currentMessageObject.isAnyKindOfSticker() || !NekomuraConfig.hideTimeForSticker.Bool())) { + if ((drawTime || !mediaBackground) && !forceNotDrawTime && !transitionParams.animateBackgroundBoundsInner && !(enterTransitionInPorgress && !currentMessageObject.isVoice()) && (!currentMessageObject.isAnyKindOfSticker() || !NekoConfig.hideTimeForSticker.Bool())) { drawTime(canvas, 1f, false); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java index a8b1171f0..e9fac8723 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ContextLinkCell.java @@ -39,7 +39,6 @@ import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaController; import org.telegram.messenger.MessageObject; -import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.SvgHelper; import org.telegram.messenger.UserConfig; @@ -59,7 +58,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ContextLinkCell extends FrameLayout implements DownloadController.FileDownloadProgressListener { @@ -267,7 +266,7 @@ public class ContextLinkCell extends FrameLayout implements DownloadController.F if (inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue || inlineResult.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) { double lat = inlineResult.send_message.geo.lat; double lon = inlineResult.send_message.geo._long; - if (NekomuraConfig.mapPreviewProvider.Int() == 0) { + if (NekoConfig.mapPreviewProvider.Int() == 0) { webFile = WebFile.createWithGeoPoint(inlineResult.send_message.geo, 72, 72, 15, Math.min(2, (int) Math.ceil(AndroidUtilities.density))); } else { urlLocation = AndroidUtilities.formapMapUrl(false, lat, lon, 72, 72, true, 15); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index abd8148bb..1406b8a8d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -39,8 +39,6 @@ import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; import org.telegram.messenger.DialogObject; import org.telegram.messenger.ChatThemeController; -import org.telegram.messenger.ContactsController; -import org.telegram.messenger.DialogObject; import org.telegram.messenger.DownloadController; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLoader; @@ -81,8 +79,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Stack; -import tw.nekomimi.nekogram.MessageHelper; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.MessageHelper; +import tw.nekomimi.nekogram.NekoConfig; public class DialogCell extends BaseCell { @@ -1025,7 +1023,7 @@ public class DialogCell extends BaseCell { currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex]; } else { boolean needEmoji = true; - if (NekomuraConfig.mediaPreview.Bool() && TextUtils.isEmpty(restrictionReason) && currentDialogFolderId == 0 && encryptedChat == null && !message.needDrawBluredPreview() && (message.isPhoto() || message.isNewGif() || message.isVideo())) { + if (NekoConfig.mediaPreview.Bool() && TextUtils.isEmpty(restrictionReason) && currentDialogFolderId == 0 && encryptedChat == null && !message.needDrawBluredPreview() && (message.isPhoto() || message.isNewGif() || message.isVideo())) { String type = message.isWebpage() ? message.messageOwner.media.webpage.type : null; if (!("app".equals(type) || "profile".equals(type) || "article".equals(type) || type != null && type.startsWith("telegram_"))) { TLRPC.PhotoSize smallThumb = FileLoader.getClosestPhotoSizeWithSize(message.photoThumbs, 40); @@ -2030,7 +2028,7 @@ public class DialogCell extends BaseCell { if (mask == 0) { clearingDialog = MessagesController.getInstance(currentAccount).isClearingDialog(dialog.id); message = MessagesController.getInstance(currentAccount).dialogMessage.get(dialog.id); - if (message != null && NekomuraConfig.ignoreBlocked.Bool() && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getSenderId()) >= 0) { + if (message != null && NekoConfig.ignoreBlocked.Bool() && MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(message.getSenderId()) >= 0) { if (MessagesController.getInstance(currentAccount).dialogMessageFromUnblocked.get(dialog.id) != null) message = MessagesController.getInstance(currentAccount).dialogMessageFromUnblocked.get(dialog.id); else { @@ -2316,7 +2314,7 @@ public class DialogCell extends BaseCell { if (isSliding && !swipeCanceled) { boolean prevValue = drawRevealBackground; drawRevealBackground = Math.abs(translationX) >= getMeasuredWidth() * 0.45f; - if (prevValue != drawRevealBackground && archiveHidden == SharedConfig.archiveHidden && !NekomuraConfig.disableVibration.Bool()) { + if (prevValue != drawRevealBackground && archiveHidden == SharedConfig.archiveHidden && !NekoConfig.disableVibration.Bool()) { try { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } catch (Exception ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java index c387a1ed9..be6c68fa1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -59,8 +59,7 @@ import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RLottieImageView; import org.telegram.ui.Components.SnowflakesEffect; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class DrawerProfileCell extends FrameLayout { @@ -96,7 +95,7 @@ public class DrawerProfileCell extends FrameLayout { imageReceiver.setCrossfadeWithOldImage(true); imageReceiver.setForceCrossfade(true); imageReceiver.setDelegate((imageReceiver, set, thumb, memCache) -> { - if (NekomuraConfig.avatarBackgroundDarken.Bool() || NekomuraConfig.avatarBackgroundBlur.Bool()) { + if (NekoConfig.avatarBackgroundDarken.Bool() || NekoConfig.avatarBackgroundBlur.Bool()) { if (thumb || allowInvalidate) { return; } @@ -107,19 +106,19 @@ public class DrawerProfileCell extends FrameLayout { imageReceiver.setCrossfadeWithOldImage(false); imageReceiver.setImageBitmap(new BitmapDrawable(null, lastBitmap), false); } - int width = NekomuraConfig.avatarBackgroundBlur.Bool() ? 150 : bmp.bitmap.getWidth(); - int height = NekomuraConfig.avatarBackgroundBlur.Bool() ? 150 : bmp.bitmap.getHeight(); + int width = NekoConfig.avatarBackgroundBlur.Bool() ? 150 : bmp.bitmap.getWidth(); + int height = NekoConfig.avatarBackgroundBlur.Bool() ? 150 : bmp.bitmap.getHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawBitmap(bmp.bitmap, null, new Rect(0, 0, width, height), new Paint(Paint.FILTER_BITMAP_FLAG)); - if (NekomuraConfig.avatarBackgroundBlur.Bool()) { + if (NekoConfig.avatarBackgroundBlur.Bool()) { try { Utilities.stackBlurBitmap(bitmap, 3); } catch (Exception e) { FileLog.e(e); } } - if (NekomuraConfig.avatarBackgroundDarken.Bool()) { + if (NekoConfig.avatarBackgroundDarken.Bool()) { final Palette palette = Palette.from(bmp.bitmap).generate(); Paint paint = new Paint(); paint.setColor((palette.getDarkMutedColor(0xFF547499) & 0x00FFFFFF) | 0x44000000); @@ -252,10 +251,10 @@ public class DrawerProfileCell extends FrameLayout { }); addView(darkThemeView, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.BOTTOM, 0, 10, 6, 90)); - if (Theme.getEventType() == 0 || NekomuraConfig.actionBarDecoration.Int() == 1) { + if (Theme.getEventType() == 0 || NekoConfig.actionBarDecoration.Int() == 1) { snowflakesEffect = new SnowflakesEffect(0); snowflakesEffect.setColorKey(Theme.key_chats_menuName); - } else if (NekomuraConfig.actionBarDecoration.Int() == 2) { + } else if (NekoConfig.actionBarDecoration.Int() == 2) { fireworksEffect = new FireworksEffect(); } } @@ -276,9 +275,9 @@ public class DrawerProfileCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int heightBase = NekomuraConfig.largeAvatarInDrawer.Int() == 2 ? MeasureSpec.getSize(widthMeasureSpec) : AndroidUtilities.dp(148); + int heightBase = NekoConfig.largeAvatarInDrawer.Int() == 2 ? MeasureSpec.getSize(widthMeasureSpec) : AndroidUtilities.dp(148); if (Build.VERSION.SDK_INT >= 21) { - heightBase -= NekomuraConfig.largeAvatarInDrawer.Int() == 2 ? AndroidUtilities.statusBarHeight : 0; + heightBase -= NekoConfig.largeAvatarInDrawer.Int() == 2 ? AndroidUtilities.statusBarHeight : 0; super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightBase + AndroidUtilities.statusBarHeight, MeasureSpec.EXACTLY)); } else { try { @@ -291,7 +290,7 @@ public class DrawerProfileCell extends FrameLayout { } private boolean useAdb() { - return NekomuraConfig.largeAvatarInDrawer.Int() > 0 && ImageLocation.isUserHasPhoto(user); + return NekoConfig.largeAvatarInDrawer.Int() > 0 && ImageLocation.isUserHasPhoto(user); } @Override @@ -398,7 +397,7 @@ public class DrawerProfileCell extends FrameLayout { accountsShown = accounts; setArrowState(false); nameTextView.setText(UserObject.getUserName(user)); - if (!NekomuraConfig.hidePhone.Bool()) { + if (!NekoConfig.hidePhone.Bool()) { phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone)); } else if (!TextUtils.isEmpty(user.username)) { phoneTextView.setText("@" + user.username); @@ -408,21 +407,21 @@ public class DrawerProfileCell extends FrameLayout { AvatarDrawable avatarDrawable = new AvatarDrawable(user); avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue)); avatarImageView.setForUserOrChat(user, avatarDrawable); - if (NekomuraConfig.largeAvatarInDrawer.Int() > 0) { + if (NekoConfig.largeAvatarInDrawer.Int() > 0) { ImageLocation imageLocation = ImageLocation.getForUser(user, ImageLocation.TYPE_BIG); - allowInvalidate = !useAdb() || !(NekomuraConfig.avatarBackgroundDarken.Bool() || NekomuraConfig.avatarBackgroundBlur.Bool()); + allowInvalidate = !useAdb() || !(NekoConfig.avatarBackgroundDarken.Bool() || NekoConfig.avatarBackgroundBlur.Bool()); imageReceiver.setImage(imageLocation, "512_512", null, null, new ColorDrawable(0x00000000), 0, null, user, 1); avatarImageView.setVisibility(INVISIBLE); } else { avatarImageView.setVisibility(VISIBLE); } - if (NekomuraConfig.largeAvatarInDrawer.Int() == 2) { + if (NekoConfig.largeAvatarInDrawer.Int() == 2) { // add shadow nameTextView.setShadowLayer(6.0f, 2.0f, 2.0f, Color.BLACK); phoneTextView.getTextView().setShadowLayer(6.0f, 2.0f, 2.0f, Color.BLACK); // correct the position of night button - LayoutParams lp = NekomuraConfig.largeAvatarInDrawer.Int() == 2 ? + LayoutParams lp = NekoConfig.largeAvatarInDrawer.Int() == 2 ? LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 0, AndroidUtilities.statusBarHeight / getResources().getDisplayMetrics().density, 6, 0) : LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.BOTTOM, 0, 10, 6, 90); darkThemeView.setLayoutParams(lp); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPermissionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPermissionCell.java index 507260bcc..443dba8c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPermissionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPermissionCell.java @@ -23,7 +23,7 @@ import org.telegram.messenger.R; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; -import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.NekoXConfig; public class PhotoAttachPermissionCell extends FrameLayout { @@ -72,7 +72,7 @@ public class PhotoAttachPermissionCell extends FrameLayout { imageView.setImageResource(R.drawable.permissions_gallery1); imageView2.setImageResource(R.drawable.permissions_gallery2); textView.setText(LocaleController.getString("GalleryPermissionText", R.string.GalleryPermissionText)); - if (NekoConfig.forceSystemPicker) { + if (NekoXConfig.forceSystemPicker) { imageView.setImageResource(R.drawable.baseline_open_in_browser_24); imageView2.setVisibility(GONE); textView.setText(LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java index 91cd04919..c1e4b0adb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedLinkCell.java @@ -56,7 +56,7 @@ import java.util.Locale; import java.util.Stack; import java.util.concurrent.atomic.AtomicReference; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class SharedLinkCell extends FrameLayout { private final static int SPOILER_TYPE_LINK = 0, @@ -90,7 +90,7 @@ public class SharedLinkCell extends FrameLayout { public void run() { if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) { checkingForLongPress = false; - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } if (pressedLink >= 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java index 69bb08e9a..c8b273fc1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerSetCell.java @@ -43,9 +43,8 @@ import org.telegram.ui.Components.RadialProgressView; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nekogram.NekoXConfig; -import tw.nekomimi.nekogram.PinnedStickerHelper; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.ui.PinnedStickerHelper; public class StickerSetCell extends FrameLayout { @@ -192,7 +191,7 @@ public class StickerSetCell extends FrameLayout { } // NekoX: Pinned Sticker Mark - if (NekomuraConfig.enableStickerPin.Bool() && PinnedStickerHelper.getInstance(UserConfig.selectedAccount).isPinned(set.set.id)) { + if (NekoConfig.enableStickerPin.Bool() && PinnedStickerHelper.getInstance(UserConfig.selectedAccount).isPinned(set.set.id)) { pinnedImageView.setVisibility(VISIBLE); } else { pinnedImageView.setVisibility(INVISIBLE); @@ -237,7 +236,7 @@ public class StickerSetCell extends FrameLayout { // NekoX: Pinned Sticker Mark -> Change Visibility public void setPinnedMarkVisibility(boolean visible) { - if (!NekomuraConfig.enableStickerPin.Bool()) { + if (!NekoConfig.enableStickerPin.Bool()) { pinnedImageView.setVisibility(INVISIBLE); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java index a9b02a8dd..50b34e12f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSelectionHelper.java @@ -53,7 +53,7 @@ import org.telegram.ui.Components.RecyclerListView; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.utils.AlertUtil; @@ -236,7 +236,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); @@ -833,7 +833,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); @@ -884,7 +884,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); @@ -922,7 +922,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); @@ -934,7 +934,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); @@ -966,7 +966,7 @@ public abstract class TextSelectionHelper= Build.VERSION_CODES.O_MR1 && !NekomuraConfig.disableVibration.Bool()) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && !NekoConfig.disableVibration.Bool()) { textSelectionOverlay.performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE); } TextSelectionHelper.this.invalidate(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ThemesHorizontalListCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ThemesHorizontalListCell.java index 562d23138..5c3a31e48 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ThemesHorizontalListCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ThemesHorizontalListCell.java @@ -6,7 +6,6 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.BitmapShader; import android.graphics.Canvas; import android.graphics.Color; @@ -41,7 +40,6 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; -import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; @@ -64,7 +62,7 @@ import androidx.annotation.Keep; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ThemesHorizontalListCell extends RecyclerListView implements NotificationCenter.NotificationCenterDelegate { @@ -198,7 +196,7 @@ public class ThemesHorizontalListCell extends RecyclerListView implements Notifi if (action == MotionEvent.ACTION_DOWN) { pressed = true; } else { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } showOptionsForTheme(themeInfo); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java index e616c8ef3..a85974f93 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java @@ -119,8 +119,8 @@ import java.util.ArrayList; import java.util.HashMap; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; @@ -1965,7 +1965,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio } public void showOpenUrlAlert(final String url, boolean ask) { - if (Browser.isInternalUrl(url, null) || !ask || NekomuraConfig.skipOpenLinkConfirm.Bool()) { + if (Browser.isInternalUrl(url, null) || !ask || NekoConfig.skipOpenLinkConfirm.Bool()) { Browser.openUrl(getParentActivity(), url, true); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java index 323e6112e..9c6c46333 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelCreateActivity.java @@ -72,7 +72,7 @@ import org.telegram.ui.Components.SizeNotifierFrameLayout; import java.util.ArrayList; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.utils.VibrateUtil; public class ChannelCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ImageUpdater.ImageUpdaterDelegate { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java index a5842da62..649720b54 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java @@ -40,7 +40,7 @@ import org.telegram.ui.Components.CubicBezierInterpolator; import java.util.ArrayList; import java.util.Arrays; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public abstract class BaseChartView extends View implements ChartPickerDelegate.Listener { @@ -1488,7 +1488,7 @@ public abstract class BaseChartView legendSignatureView.setVisibility(VISIBLE); selectionA = 1f; moveLegend(chartFullWidth * (pickerDelegate.pickerStart) - HORIZONTAL_PADDING); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java index 24713d3f3..600f4a6c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java @@ -20,7 +20,7 @@ import org.telegram.ui.Charts.view_data.LineViewData; import org.telegram.ui.Charts.view_data.PieLegendView; import org.telegram.ui.Charts.view_data.TransitionParams; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class PieChartView extends StackLinearChartView { @@ -387,7 +387,7 @@ public class PieChartView extends StackLinearChartView { pieLegendView.setTranslationX(xl); pieLegendView.setTranslationY(yl); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { boolean v = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { v = performHapticFeedback(HapticFeedbackConstants.TEXT_HANDLE_MOVE, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index d646333d9..2ec646ff5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -65,7 +65,6 @@ import android.text.TextUtils; import android.text.style.CharacterStyle; import android.text.style.ForegroundColorSpan; import android.text.style.URLSpan; -import android.util.Log; import android.util.Property; import android.util.SparseArray; import android.util.SparseIntArray; @@ -284,10 +283,10 @@ import java.util.regex.Pattern; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nekogram.MessageDetailsActivity; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.ui.MessageDetailsActivity; import tw.nekomimi.nekogram.utils.EnvUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.parts.MessageTransKt; import tw.nekomimi.nekogram.parts.PollTransUpdatesKt; @@ -296,7 +295,7 @@ import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.PGPUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; -import tw.nekomimi.nkmr.NekomuraUtil; +import tw.nekomimi.nekogram.utils.TelegramUtil; @SuppressWarnings("unchecked") public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, LocationActivity.LocationActivityDelegate, ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate { @@ -2957,15 +2956,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } actionModeOtherItem.addSubItem(nkbtn_translate, R.drawable.ic_translate, LocaleController.getString("Translate", R.string.Translate)); - if (NekomuraConfig.showShareMessages.Bool()) + if (NekoConfig.showShareMessages.Bool()) actionModeOtherItem.addSubItem(nkbtn_sharemessage, R.drawable.baseline_share_24, LocaleController.getString("ShareMessages", R.string.ShareMessages)); actionModeOtherItem.addSubItem(nkbtn_unpin, R.drawable.deproko_baseline_pin_undo_24, LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); if (!noforward) actionModeOtherItem.addSubItem(nkbtn_savemessage, R.drawable.baseline_bookmark_24, LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages)); - if (NekomuraConfig.showRepeat.Bool() && !noforward) + if (NekoConfig.showRepeat.Bool() && !noforward) actionModeOtherItem.addSubItem(nkbtn_repeat, R.drawable.msg_repeat, LocaleController.getString("Repeat", R.string.Repeat)); - if (NekomuraConfig.showMessageHide.Bool()) { + if (NekoConfig.showMessageHide.Bool()) { actionModeOtherItem.addSubItem(nkbtn_hide, R.drawable.baseline_remove_circle_24, LocaleController.getString("Hide", R.string.Hide)); } @@ -4315,7 +4314,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (startedTrackingSlidingView) { if (Math.abs(dx) >= AndroidUtilities.dp(50)) { if (!wasTrackingVibrate) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { try { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } catch (Exception ignore) { @@ -4357,7 +4356,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (e.getAction() == MotionEvent.ACTION_DOWN) { scrollByTouch = true; } - if (!NekomuraConfig.disableSwipeToNext.Bool() && pullingDownOffset != 0 && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_CANCEL)) { + if (!NekoConfig.disableSwipeToNext.Bool() && pullingDownOffset != 0 && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_CANCEL)) { float progress = Math.min(1f, pullingDownOffset / AndroidUtilities.dp(110)); if (e.getAction() == MotionEvent.ACTION_UP && progress == 1 && pullingDownDrawable != null && !pullingDownDrawable.emptyStub) { if (pullingDownDrawable.animationIsRunning()) { @@ -4496,7 +4495,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not drawReplyButton(c); } - if (!NekomuraConfig.disableSwipeToNext.Bool() && pullingDownOffset != 0) { + if (!NekoConfig.disableSwipeToNext.Bool() && pullingDownOffset != 0) { c.save(); float transitionOffset = 0; if (pullingDownAnimateProgress != 0) { @@ -4529,7 +4528,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not drawLaterRoundProgressCell = null; canvas.save(); - if (!NekomuraConfig.disableSwipeToNext.Bool() && fromPullingDownTransition && !toPullingDownTransition) { + if (!NekoConfig.disableSwipeToNext.Bool() && fromPullingDownTransition && !toPullingDownTransition) { canvas.clipRect(0, chatListViewPaddingTop - chatListViewPaddingVisibleOffset - AndroidUtilities.dp(4), getMeasuredWidth(), getMeasuredHeight()); } @@ -5495,7 +5494,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) { - if (!NekomuraConfig.disableSwipeToNext.Bool() && dy < 0 && pullingDownOffset != 0) { + if (!NekoConfig.disableSwipeToNext.Bool() && dy < 0 && pullingDownOffset != 0) { pullingDownOffset += dy; if (pullingDownOffset < 0) { dy = (int) pullingDownOffset; @@ -5528,7 +5527,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (!foundTopView) { scrolled = super.scrollVerticallyBy(dy, recycler, state); } - if (!NekomuraConfig.disableSwipeToNext.Bool() && dy > 0 && scrolled == 0 && ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatListView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING && !chatListView.isFastScrollAnimationRunning() && !chatListView.isMultiselect()) { + if (!NekoConfig.disableSwipeToNext.Bool() && dy > 0 && scrolled == 0 && ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatListView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING && !chatListView.isFastScrollAnimationRunning() && !chatListView.isMultiselect()) { if (pullingDownOffset == 0 && pullingDownDrawable != null) { pullingDownDrawable.updateDialog(); } @@ -5647,7 +5646,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not wasManualScroll = true; scrollingChatListView = true; } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { - if (NekomuraConfig.hideKeyboardOnChatScroll.Bool()) { + if (NekoConfig.hideKeyboardOnChatScroll.Bool()) { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); } pollHintCell = null; @@ -6333,8 +6332,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not textSelectionHelper.cancelTextSelectionRunnable(); if (createUnreadMessageAfterId != 0) { scrollToMessageId(createUnreadMessageAfterId, 0, false, returnToLoadIndex, true, 0); - } else if (returnToMessageId > 0 || (NekomuraConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty())) { - if (NekomuraConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty()) + } else if (returnToMessageId > 0 || (NekoConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty())) { + if (NekoConfig.rememberAllBackMessages.Bool() && !returnToMessageIdsStack.empty()) returnToMessageId = returnToMessageIdsStack.pop(); scrollToMessageId(returnToMessageId, 0, true, returnToLoadIndex, true, 0); } else { @@ -6345,7 +6344,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } }); - if (NekomuraConfig.rememberAllBackMessages.Bool()) { + if (NekoConfig.rememberAllBackMessages.Bool()) { pagedownButton.setOnLongClickListener(view -> { returnToMessageId = 0; returnToMessageIdsStack.clear(); @@ -10131,7 +10130,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (getParentActivity() == null || fragmentView == null || hide && voiceHintTextView == null || chatMode != 0 || chatActivityEnterView == null || chatActivityEnterView.getAudioVideoButtonContainer() == null || chatActivityEnterView.getAudioVideoButtonContainer().getVisibility() != View.VISIBLE) { return; } - if (NekomuraConfig.useChatAttachMediaMenu.Bool()) return; + if (NekoConfig.useChatAttachMediaMenu.Bool()) return; if (voiceHintTextView == null) { SizeNotifierFrameLayout frameLayout = (SizeNotifierFrameLayout) fragmentView; int index = frameLayout.indexOfChild(chatActivityEnterView); @@ -11023,7 +11022,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return dialog != chatAttachAlert && super.dismissDialogOnPause(dialog); } - private boolean disableLinkPreview = NekomuraConfig.disableLinkPreviewByDefault.Bool(); + private boolean disableLinkPreview = NekoConfig.disableLinkPreviewByDefault.Bool(); private void searchLinks(final CharSequence charSequence, final boolean force) { if (currentEncryptedChat != null && getMessagesController().secretWebpagePreview == 0 || editingMessageObject != null && !editingMessageObject.isWebpage()) { @@ -11254,7 +11253,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } public void beforeMessageSend(boolean notify, int scheduleDate, boolean beforeSend) { - if (beforeSend != NekomuraConfig.sendCommentAfterForward.Bool()) return; + if (beforeSend != NekoConfig.sendCommentAfterForward.Bool()) return; if (forwardingMessages != null) { ArrayList messagesToForward = new ArrayList<>(); forwardingMessages.getSelectedMessages(messagesToForward); @@ -12670,7 +12669,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } returnToMessageId = fromMessageId; - if (NekomuraConfig.rememberAllBackMessages.Bool() && fromMessageId > 0) + if (NekoConfig.rememberAllBackMessages.Bool() && fromMessageId > 0) returnToMessageIdsStack.push(returnToMessageId); returnToLoadIndex = loadIndex; needSelectFromMessageId = select; @@ -16064,12 +16063,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (voters.chosen) { if (voters.correct) { fireworksOverlay.start(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { pollView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } else { ((ChatMessageCell) pollView).shakeView(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { pollView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } showPollSolution(cell.getMessageObject(), results); @@ -19740,7 +19739,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (shareKeyItem != null) { - if ((currentChat != null && ChatObject.canSendMessages(currentChat) || user != null && !user.self) && StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) { + if ((currentChat != null && ChatObject.canSendMessages(currentChat) || user != null && !user.self) && StrUtil.isNotBlank(NekoConfig.openPGPApp.String())) { shareKeyItem.setVisibility(View.VISIBLE); } else { shareKeyItem.setVisibility(View.GONE); @@ -20820,7 +20819,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not // options.add(29); // icons.add(R.drawable.msg_translate); // } - if (NekomuraConfig.showReport.Bool() && selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) { + if (NekoConfig.showReport.Bool() && selectedObject.contentType == 0 && !selectedObject.isMediaEmptyWebpage() && selectedObject.getId() > 0 && !selectedObject.isOut() && (currentChat != null || currentUser != null && currentUser.bot)) { items.add(LocaleController.getString("ReportChat", R.string.ReportChat)); options.add(OPTION_REPORT_CHAT); icons.add(R.drawable.baseline_report_24); @@ -21101,7 +21100,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } if (chatMode != MODE_SCHEDULED) { - if (!UserObject.isUserSelf(currentUser) && NekomuraConfig.showAddToSavedMessages.Bool()) { + if (!UserObject.isUserSelf(currentUser) && NekoConfig.showAddToSavedMessages.Bool()) { if (!noforward) { items.add(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages)); options.add(nkbtn_savemessage); @@ -21110,7 +21109,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } boolean allowRepeat = currentUser != null || (currentChat != null && ChatObject.canSendMessages(currentChat)); - if (allowRepeat && NekomuraConfig.showRepeat.Bool() && !noforward) { + if (allowRepeat && NekoConfig.showRepeat.Bool() && !noforward) { items.add(LocaleController.getString("Repeat", R.string.Repeat)); options.add(nkbtn_repeat); icons.add(R.drawable.msg_repeat); @@ -21120,13 +21119,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not boolean allowViewHistory = currentUser == null && (currentChat != null && !currentChat.broadcast && message.isFromUser()); - if (NekomuraConfig.showDeleteDownloadedFile.Bool() && NekomuraUtil.messageObjectIsFile(type, selectedObject)) { + if (NekoConfig.showDeleteDownloadedFile.Bool() && TelegramUtil.messageObjectIsFile(type, selectedObject)) { items.add(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile)); options.add(nkbtn_deldlcache); icons.add(R.drawable.baseline_delete_sweep_24); } - if (allowViewHistory && NekomuraConfig.showViewHistory.Bool()) { + if (allowViewHistory && NekoConfig.showViewHistory.Bool()) { items.add(LocaleController.getString("ViewUserHistory", R.string.ViewHistory)); options.add(nkbtn_view_history); icons.add(R.drawable.baseline_schedule_24); @@ -21140,7 +21139,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } - if (NekomuraConfig.showTranslate.Bool()) { + if (NekoConfig.showTranslate.Bool()) { if (messageObject != null || docsWithMessages) { boolean td; if (messageObject != null) { @@ -21153,14 +21152,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not icons.add(R.drawable.ic_translate); } } - if (NekomuraConfig.showShareMessages.Bool()) { + if (NekoConfig.showShareMessages.Bool()) { if (messageObject != null || docsWithMessages) { items.add(LocaleController.getString("ShareMessages", R.string.ShareMessages)); options.add(nkbtn_sharemessage); icons.add(R.drawable.baseline_share_24); } } - if (messageObject != null && StrUtil.isNotBlank(messageObject.messageOwner.message) && StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) { + if (messageObject != null && StrUtil.isNotBlank(messageObject.messageOwner.message) && StrUtil.isNotBlank(NekoConfig.openPGPApp.String())) { if (PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(selectedObject.messageOwner.message).matches()) { items.add(LocaleController.getString("PGPVerify", R.string.PGPVerify)); options.add(nkbtn_PGPVerify); @@ -21180,12 +21179,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } - if (NekomuraConfig.showMessageDetails.Bool()) { + if (NekoConfig.showMessageDetails.Bool()) { items.add(LocaleController.getString("MessageDetails", R.string.MessageDetails)); options.add(nkbtn_detail); icons.add(R.drawable.menu_info); } - if (NekomuraConfig.showMessageHide.Bool()) { + if (NekoConfig.showMessageHide.Bool()) { items.add(LocaleController.getString("Hide", R.string.Hide)); options.add(nkbtn_hide); icons.add(R.drawable.baseline_remove_circle_24); @@ -21234,7 +21233,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not options.add(23); icons.add(R.drawable.baseline_report_24); - } else if (NekomuraConfig.showReport.Bool()) { + } else if (NekoConfig.showReport.Bool()) { items.add(LocaleController.getString("ReportChat", R.string.ReportChat)); options.add(23); @@ -21344,7 +21343,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } - if (NekomuraConfig.showTranslate.Bool()) { + if (NekoConfig.showTranslate.Bool()) { if (messageObject != null || docsWithMessages) { boolean td; if (messageObject != null) { @@ -21357,7 +21356,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not icons.add(R.drawable.ic_translate); } } - if (messageObject != null && StrUtil.isNotBlank(messageObject.messageOwner.message) && StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) { + if (messageObject != null && StrUtil.isNotBlank(messageObject.messageOwner.message) && StrUtil.isNotBlank(NekoConfig.openPGPApp.String())) { //TODO wtf if (PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(selectedObject.messageOwner.message).matches()) { items.add(LocaleController.getString("PGPVerify", R.string.PGPVerify)); @@ -21377,7 +21376,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not icons.add(R.drawable.baseline_vpn_key_24); } } - if (NekomuraConfig.showMessageHide.Bool()) { + if (NekoConfig.showMessageHide.Bool()) { items.add(LocaleController.getString("Hide", R.string.Hide)); options.add(204); icons.add(R.drawable.baseline_remove_circle_24); @@ -21414,13 +21413,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not editingAdmin = participant instanceof TLRPC.TL_chatParticipantAdmin; } - if (canEditAdmin && NekomuraConfig.showAdminActions.Bool()) { + if (canEditAdmin && NekoConfig.showAdminActions.Bool()) { items.add(editingAdmin ? LocaleController.getString("EditAdminRights", R.string.EditAdminRights) : LocaleController.getString("SetAsAdmin", R.string.SetAsAdmin)); icons.add(R.drawable.baseline_stars_24); options.add(nkbtn_editAdmin); selectedParticipant = participant; } - if (canRestrict && NekomuraConfig.showChangePermissions.Bool()) { + if (canRestrict && NekoConfig.showChangePermissions.Bool()) { items.add(LocaleController.getString("ChangePermissions", R.string.ChangePermissions)); icons.add(R.drawable.baseline_block_24); options.add(nkbtn_editPermission); @@ -23200,11 +23199,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not hideFieldPanel(false); for (int a = 0; a < dids.size(); a++) { long did = dids.get(a); - if (message != null && !NekomuraConfig.sendCommentAfterForward.Bool()) { + if (message != null && !NekoConfig.sendCommentAfterForward.Bool()) { getSendMessagesHelper().sendMessage(message.toString(), did, null, null, null, true, null, null, null, true, 0, null); } forwardMessages(fmessages, noForwardQuote, true, 0, did); - if (message != null && NekomuraConfig.sendCommentAfterForward.Bool()) { + if (message != null && NekoConfig.sendCommentAfterForward.Bool()) { getSendMessagesHelper().sendMessage(message.toString(), did, null, null, null, true, null, null, null, true, 0, null); } } @@ -24122,7 +24121,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not Browser.openUrl(getParentActivity(), url, inlineReturn == 0, false); } else if (type == 2) { // NekoX: Fix skipOpenLinkConfirm broken in 7.6.0, since processExternalUrl is imported in 7.6.0 - if (NekomuraConfig.skipOpenLinkConfirm.Bool()) + if (NekoConfig.skipOpenLinkConfirm.Bool()) Browser.openUrl(getParentActivity(), url, inlineReturn == 0); else AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, true); @@ -25483,7 +25482,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } fireworksOverlay.start(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } @@ -25617,7 +25616,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject message = messages.get(position - messagesStartRow); View view = holder.itemView; - boolean fromUserBlocked = getMessagesController().blockePeers.indexOfKey(message.getFromChatId()) >= 0 && NekomuraConfig.ignoreBlocked.Bool(); + boolean fromUserBlocked = getMessagesController().blockePeers.indexOfKey(message.getFromChatId()) >= 0 && NekoConfig.ignoreBlocked.Bool(); if (view instanceof ChatMessageCell) { final ChatMessageCell messageCell = (ChatMessageCell) view; @@ -28192,7 +28191,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not Integer end = ids.get(ids.size() - 1); for (int i = 0; i < messages.size(); i++) { int msgId = messages.get(i).getId(); - if (NekomuraConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messages.get(i).getSenderId()) >= 0) + if (NekoConfig.ignoreBlocked.Bool() && getMessagesController().blockePeers.indexOfKey(messages.get(i).getSenderId()) >= 0) continue; if (msgId > begin && msgId < end && selectedMessagesIds[0].indexOfKey(msgId) < 0) { MessageObject message = messages.get(i); @@ -28328,7 +28327,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } case nkbtn_deldlcache: { final MessageObject so = selectedObject; - final boolean isDownloading = NekomuraUtil.messageObjectIsDownloading(getMessageType(so)); + final boolean isDownloading = TelegramUtil.messageObjectIsDownloading(getMessageType(so)); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("DeleteDownloadedFile")); @@ -28368,7 +28367,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (isDownloading) { // Download unfinished catalog is not the same String cacheFilePath = AndroidUtilities.getCacheDir().getAbsolutePath(); - cacheFilePath += "/" + NekomuraUtil.getFileNameNoEx(file.getName()); + cacheFilePath += "/" + TelegramUtil.getFileNameWithoutEx(file.getName()); List suffix = Arrays.asList(".pt", ".temp"); for (int ii = 0; ii < suffix.size(); ii++) { file = new File(cacheFilePath + suffix.get(ii)); @@ -28500,7 +28499,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not Intent open = new Intent(Intent.ACTION_SEND); open.setType("application/pgp-message"); open.putExtra(Intent.EXTRA_TEXT, messageObject.messageOwner.message); - open.setClassName(NekomuraConfig.openPGPApp.String(), NekomuraConfig.openPGPApp.String() + ".ui.DecryptActivity"); + open.setClassName(NekoConfig.openPGPApp.String(), NekoConfig.openPGPApp.String() + ".ui.DecryptActivity"); try { @@ -28530,8 +28529,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not case nkbtn_PGPImportPrivate: case nkbtn_PGPImport: { - Intent open = new Intent(NekomuraConfig.openPGPApp.String() + ".action.IMPORT_KEY"); - open.putExtra(NekomuraConfig.openPGPApp.String() + ".EXTRA_KEY_BYTES", StrUtil.utf8Bytes(selectedObject.messageOwner.message)); + Intent open = new Intent(NekoConfig.openPGPApp.String() + ".action.IMPORT_KEY"); + open.putExtra(NekoConfig.openPGPApp.String() + ".EXTRA_KEY_BYTES", StrUtil.utf8Bytes(selectedObject.messageOwner.message)); try { @@ -28586,7 +28585,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (selectedMessagesIds[0].get(selectedMessagesIds[0].keyAt(k)) != null) messages.add(selectedMessagesIds[0].get(selectedMessagesIds[0].keyAt(k))); } - if (!NekomuraConfig.repeatConfirm.Bool()) { + if (!NekoConfig.repeatConfirm.Bool()) { doRepeatMessage(isLongClick, messages); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 16e324638..f4d27b546 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -118,8 +118,8 @@ import java.util.Locale; import java.util.concurrent.CountDownLatch; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.VibrateUtil; @@ -992,7 +992,7 @@ public class AlertsCreator { return; } long inlineReturn = (fragment instanceof ChatActivity) ? ((ChatActivity) fragment).getInlineReturn() : 0; - if (Browser.isInternalUrl(url, null) || !ask || NekomuraConfig.skipOpenLinkConfirm.Bool()) { + if (Browser.isInternalUrl(url, null) || !ask || NekoConfig.skipOpenLinkConfirm.Bool()) { Browser.openUrl(fragment.getParentActivity(), url, inlineReturn == 0, tryTelegraph); } else { String urlFinal; @@ -2418,7 +2418,7 @@ public class AlertsCreator { }); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } catch (Exception ignore) { @@ -2606,7 +2606,7 @@ public class AlertsCreator { }); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } catch (Exception ignore) { @@ -2810,7 +2810,7 @@ public class AlertsCreator { dayPicker.setFormatter(value -> "" + value); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } catch (Exception ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index ade34cc95..95f067591 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -162,8 +162,8 @@ import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; import kotlin.Unit; import kotlin.text.StringsKt; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.cc.CCConverter; import tw.nekomimi.nekogram.cc.CCTarget; import tw.nekomimi.nekogram.transtale.TranslateDb; @@ -172,7 +172,7 @@ import tw.nekomimi.nekogram.transtale.TranslatorKt; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.PGPUtil; import tw.nekomimi.nekogram.utils.UIUtil; -import tw.nekomimi.nkmr.NekomuraConfig; + import java.util.concurrent.atomic.AtomicReference; public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate { @@ -517,7 +517,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe private MessageObject replyingMessageObject; private MessageObject botMessageObject; private TLRPC.WebPage messageWebPage; - private boolean messageWebPageSearch = !NekomuraConfig.disableLinkPreviewByDefault.Bool(); + private boolean messageWebPageSearch = !NekoConfig.disableLinkPreviewByDefault.Bool(); private ChatActivityEnterViewDelegate delegate; private TrendingStickersAlert trendingStickersAlert; @@ -3198,7 +3198,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe audioVideoButtonContainer = new FrameLayout(context); audioVideoButtonContainer.setSoundEffectsEnabled(false); sendButtonContainer.addView(audioVideoButtonContainer, LayoutHelper.createFrame(48, 48)); - if (NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (NekoConfig.useChatAttachMediaMenu.Bool()) { audioVideoButtonContainer.setOnClickListener(v -> { if (recordCircle.isSendButtonVisible()) { if (!hasRecordVideo || calledRecordRunnable) { @@ -3301,7 +3301,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe AndroidUtilities.cancelRunOnUIThread(recordAudioVideoRunnable); delegate.onSwitchRecordMode(videoSendButton.getTag() == null); setRecordVideoButtonVisible(videoSendButton.getTag() == null, true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); @@ -3309,21 +3309,21 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe startedDraggingX = -1; if (hasRecordVideo && videoSendButton.getTag() != null) { CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable); - delegate.needStartRecordVideo(NekomuraConfig.confirmAVMessage.Bool() ? 3 : 1, true, 0); + delegate.needStartRecordVideo(NekoConfig.confirmAVMessage.Bool() ? 3 : 1, true, 0); } else { - if (!NekomuraConfig.confirmAVMessage.Bool()) { + if (!NekoConfig.confirmAVMessage.Bool()) { if (recordingAudioVideo && isInScheduleMode()) { AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0), resourcesProvider); } } delegate.needStartRecordAudio(0); - if (!NekomuraConfig.confirmAVMessage.Bool()) { + if (!NekoConfig.confirmAVMessage.Bool()) { MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0); } else { MediaController.getInstance().stopRecording(2, true, 0); } } - if (!NekomuraConfig.confirmAVMessage.Bool()) { + if (!NekoConfig.confirmAVMessage.Bool()) { recordingAudioVideo = false; messageTransitionIsRunning = false; AndroidUtilities.runOnUIThread(moveToSendStateRunnable = () -> { @@ -3388,13 +3388,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe audioSendButton = new ImageView(context); audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); audioSendButton.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.SRC_IN)); - audioSendButton.setImageResource(!NekomuraConfig.useChatAttachMediaMenu.Bool() ? R.drawable.baseline_mic_24 : R.drawable.ic_ab_other); + audioSendButton.setImageResource(!NekoConfig.useChatAttachMediaMenu.Bool() ? R.drawable.baseline_mic_24 : R.drawable.ic_ab_other); audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0); - audioSendButton.setContentDescription(!NekomuraConfig.useChatAttachMediaMenu.Bool() ? + audioSendButton.setContentDescription(!NekoConfig.useChatAttachMediaMenu.Bool() ? LocaleController.getString("AccDescrVoiceMessage", R.string.AccDescrVoiceMessage) : LocaleController.getString("AccDescrChatAttachEnterMenu", R.string.AccDescrChatAttachEnterMenu)); - if (Build.VERSION.SDK_INT >= 21 && NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (Build.VERSION.SDK_INT >= 21 && NekoConfig.useChatAttachMediaMenu.Bool()) { audioSendButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector))); } @@ -3691,7 +3691,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe private void startLockTransition(boolean animate) { AnimatorSet animatorSet = new AnimatorSet(); - if (!NekomuraConfig.disableVibration.Bool() && animate) { + if (!NekoConfig.disableVibration.Bool() && animate) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } @@ -3820,7 +3820,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe recordAudioVideoRunnable.run(); delegate.onSwitchRecordMode(videoSendButton.getTag() == null); setRecordVideoButtonVisible(videoSendButton.getTag() == null, true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } recordCircle.sendButtonVisible = true; @@ -3852,7 +3852,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe recordAudioVideoRunnable.run(); delegate.onSwitchRecordMode(videoSendButton.getTag() == null); setRecordVideoButtonVisible(videoSendButton.getTag() == null, true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } recordCircle.sendButtonVisible = true; @@ -3867,7 +3867,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe } else { - if (StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) { + if (StrUtil.isNotBlank(NekoConfig.openPGPApp.String())) { cell.setTextAndIcon(LocaleController.getString("Sign", R.string.Sign), R.drawable.baseline_vpn_key_24); cell.setOnClickListener(v -> { @@ -3907,7 +3907,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe if (menuPopupWindow != null && menuPopupWindow.isShowing()) { menuPopupWindow.dismiss(); } - translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); }); ActionBarMenuSubItem finalCell = cell; cell.setOnLongClickListener(v -> { @@ -3928,7 +3928,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe cell.setTextAndIcon(LocaleController.getString("Translate", R.string.OpenCC), R.drawable.ic_translate); ActionBarMenuSubItem finalCell1 = cell; cell.setOnClickListener(v -> { - String ccTarget = TranslateDb.getChatCCTarget(chatId, NekomuraConfig.ccInputLang.String()); + String ccTarget = TranslateDb.getChatCCTarget(chatId, NekoConfig.ccInputLang.String()); if (ccTarget == null || StringsKt.isBlank(ccTarget)) { Translator.showCCTargetSelect(finalCell1, (target) -> { if (menuPopupWindow != null && menuPopupWindow.isShowing()) { @@ -4153,7 +4153,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), y); sendPopupWindow.dimBehind(); sendButton.invalidate(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } @@ -4164,8 +4164,8 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe Intent intent = new Intent(); - if (NekomuraConfig.openPGPKeyId.Long() != 0L && save) - intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NekomuraConfig.openPGPKeyId.Long()); + if (NekoConfig.openPGPKeyId.Long() != 0L && save) + intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NekoConfig.openPGPKeyId.Long()); signComment(intent, save); @@ -4181,7 +4181,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L); - if (save) NekomuraConfig.openPGPKeyId.setConfigLong(keyId); + if (save) NekoConfig.openPGPKeyId.setConfigLong(keyId); signComment(result, save); @@ -4223,7 +4223,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); if (error == null) return; if (error.getMessage() != null && error.getMessage().contains("not found") && save) { - NekomuraConfig.openPGPKeyId.setConfigLong(0L); + NekoConfig.openPGPKeyId.setConfigLong(0L); signComment(new Intent(), true); } else { AlertUtil.showToast(error.toString()); @@ -4381,7 +4381,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe if (videoSendButton == null) { return; } - if (NekomuraConfig.useChatAttachMediaMenu.Bool()) visible = animated = false; + if (NekoConfig.useChatAttachMediaMenu.Bool()) visible = animated = false; videoSendButton.setTag(visible ? 1 : null); @@ -5200,7 +5200,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe videoToSendMessageObject = null; videoTimelineView.destroy(); - if (videoSendButton != null && isInVideoMode() && !NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (videoSendButton != null && isInVideoMode() && !NekoConfig.useChatAttachMediaMenu.Bool()) { videoSendButton.setVisibility(View.VISIBLE); } else if (audioSendButton != null) { audioSendButton.setVisibility(View.VISIBLE); @@ -5288,7 +5288,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe AnimatorSet attachIconAnimator = null; AnimatorSet botIconAnimator = null; - if (attachButton != null && NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (attachButton != null && NekoConfig.useChatAttachMediaMenu.Bool()) { checkAttachButton(false, 150); if (!attachButton.isShown()) { attachButton.setAlpha(0f); @@ -5631,7 +5631,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe } if (attachLayout != null) { - if (!NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (!NekoConfig.useChatAttachMediaMenu.Bool()) { runningAnimation2 = new AnimatorSet(); ArrayList animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 0.0f)); @@ -5686,7 +5686,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe runningAnimation = new AnimatorSet(); ArrayList animators = new ArrayList<>(); - if (NekomuraConfig.useChatAttachMediaMenu.Bool() && botButton.getVisibility() == VISIBLE) { + if (NekoConfig.useChatAttachMediaMenu.Bool() && botButton.getVisibility() == VISIBLE) { animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_X, 0.1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 0.1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.ALPHA, 0.0f)); @@ -5766,7 +5766,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe expandStickersButton.setVisibility(GONE); } if (attachLayout != null) { - if (!NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (!NekoConfig.useChatAttachMediaMenu.Bool()) { attachLayout.setVisibility(GONE); if (delegate != null && getVisibility() == VISIBLE) { delegate.onAttachButtonHidden(); @@ -5818,7 +5818,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe if (attachLayout != null) { - if (!NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (!NekoConfig.useChatAttachMediaMenu.Bool()) { runningAnimation2 = new AnimatorSet(); ArrayList animators = new ArrayList<>(); animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 0.0f)); @@ -5872,7 +5872,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe runningAnimation = new AnimatorSet(); ArrayList animators = new ArrayList<>(); - if (NekomuraConfig.useChatAttachMediaMenu.Bool() && botButton.getVisibility() == VISIBLE) { + if (NekoConfig.useChatAttachMediaMenu.Bool() && botButton.getVisibility() == VISIBLE) { animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_X, 0.1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 0.1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.ALPHA, 0.0f)); @@ -5921,7 +5921,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe @Override public void onAnimationEnd(Animator animation) { if (animation.equals(runningAnimation)) { - if (NekomuraConfig.useChatAttachMediaMenu.Bool() && botButton != null) { + if (NekoConfig.useChatAttachMediaMenu.Bool() && botButton != null) { botButton.setVisibility(View.GONE); updateFieldRight(1); } @@ -5985,7 +5985,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe expandStickersButton.setVisibility(GONE); } if (attachLayout != null) { - if (!NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (!NekoConfig.useChatAttachMediaMenu.Bool()) { attachLayout.setVisibility(GONE); if (delegate != null && getVisibility() == VISIBLE) { delegate.onAttachButtonHidden(); @@ -6205,7 +6205,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe scheduledButton.setTranslationX(0); } } - if (NekomuraConfig.useChatAttachMediaMenu.Bool() && checkBotButton()) { + if (NekoConfig.useChatAttachMediaMenu.Bool() && checkBotButton()) { animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_X, 1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 1f)); animators.add(ObjectAnimator.ofFloat(botButton, View.ALPHA, 1f)); @@ -6218,7 +6218,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe if (animation.equals(runningAnimation2)) { runningAnimation2 = null; } - if (NekomuraConfig.useChatAttachMediaMenu.Bool() && checkBotButton()) { + if (NekoConfig.useChatAttachMediaMenu.Bool() && checkBotButton()) { updateBotButton(true); updateFieldRight(1); } @@ -6399,7 +6399,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe } recordCircle.voiceEnterTransitionInProgress = false; - boolean isVid = isInVideoMode() && !NekomuraConfig.useChatAttachMediaMenu.Bool(); + boolean isVid = isInVideoMode() && !NekoConfig.useChatAttachMediaMenu.Bool(); if (recordingAudioVideo) { if (recordInterfaceState == 1) { @@ -6844,7 +6844,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe audioVideoButtonContainer.setScaleY(0); if (attachButton != null) { - if (NekomuraConfig.useChatAttachMediaMenu.Bool()) { + if (NekoConfig.useChatAttachMediaMenu.Bool()) { checkAttachButton(false, 150); } else if (attachButton.getVisibility() == View.VISIBLE) { attachButton.setScaleX(0); @@ -7609,7 +7609,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe if (parentFragment == null) { return; } - if (NekomuraConfig.hideSendAsChannel.Bool()) + if (NekoConfig.hideSendAsChannel.Bool()) return; TLRPC.ChatFull full = parentFragment.getMessagesController().getChatFull(-dialog_id); TLRPC.Peer defPeer = full != null ? full.default_send_as : null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java index cc23dddd4..a1dbf2399 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java @@ -28,14 +28,12 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.Build; -import android.os.Bundle; import android.os.Vibrator; import android.text.Editable; import android.text.TextPaint; import android.text.TextUtils; import android.text.TextWatcher; import android.text.style.ImageSpan; -import android.text.util.Linkify; import android.util.Property; import android.util.TypedValue; import android.view.Gravity; @@ -46,7 +44,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.view.WindowManager; -import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.DecelerateInterpolator; import android.view.animation.OvershootInterpolator; @@ -100,7 +97,7 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import kotlin.Unit; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.transtale.TranslatorKt; @@ -1668,7 +1665,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N sendPopupWindow.dismiss(); } if (num == 0) { - translateComment(parentFragment.getParentActivity(), TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(parentFragment.getParentActivity(), TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); } else if (num == 1) { AlertsCreator.createScheduleDatePickerDialog(getContext(), chatActivity.getDialogId(), (notify, scheduleDate) -> { if (currentAttachLayout == photoLayout) { @@ -1721,7 +1718,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N view.getLocationInWindow(location); sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2)); sendPopupWindow.dimBehind(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertLocationLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertLocationLayout.java index 8969237b0..1c455fb75 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertLocationLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertLocationLayout.java @@ -104,7 +104,7 @@ import java.util.HashMap; import java.util.List; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; public class ChatAttachAlertLocationLayout extends ChatAttachAlert.AttachAlertLayout implements NotificationCenter.NotificationCenterDelegate { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java index c0f16d5a4..9cb8fbfb6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java @@ -94,16 +94,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import androidx.annotation.Keep; import androidx.core.graphics.ColorUtils; -import androidx.exifinterface.media.ExifInterface; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.LinearSmoothScroller; -import androidx.recyclerview.widget.RecyclerView; +import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayout implements NotificationCenter.NotificationCenterDelegate { @@ -621,7 +615,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou return; } else if (noGalleryPermissions && position != 0) { try { - if (NekoConfig.forceSystemPicker) { + if (NekoXConfig.forceSystemPicker) { menu.onItemClick(open_in); // Use system photo picker } else { parentAlert.baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); @@ -664,7 +658,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou PhotoViewer.getInstance().setCaption(parentAlert.getCommentTextView().getText()); } else { if (SharedConfig.inappCamera) { - if (NekomuraConfig.disableInstantCamera.Bool()) { + if (NekoConfig.disableInstantCamera.Bool()) { showCamera(); } openCamera(true); @@ -1625,7 +1619,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou deviceHasGoodCamera = CameraController.getInstance().isCameraInitied(); } } - if (deviceHasGoodCamera && NekomuraConfig.disableInstantCamera.Bool()) { + if (deviceHasGoodCamera && NekoConfig.disableInstantCamera.Bool()) { // Clear cached bitmap File file = new File(ApplicationLoader.getFilesDirFixed(), "cthumb.jpg"); if (file.exists()) file.delete(); @@ -1633,7 +1627,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou if ((old != deviceHasGoodCamera || old2 != noCameraPermissions) && adapter != null) { adapter.notifyDataSetChanged(); } - if (parentAlert.isShowing() && deviceHasGoodCamera && parentAlert.baseFragment != null && parentAlert.getBackDrawable().getAlpha() != 0 && !cameraOpened && !NekomuraConfig.disableInstantCamera.Bool()) { + if (parentAlert.isShowing() && deviceHasGoodCamera && parentAlert.baseFragment != null && parentAlert.getBackDrawable().getAlpha() != 0 && !cameraOpened && !NekoConfig.disableInstantCamera.Bool()) { showCamera(); } } @@ -1922,7 +1916,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou } private void saveLastCameraBitmap() { - if (!canSaveCameraPreview || NekomuraConfig.disableInstantCamera.Bool()) { + if (!canSaveCameraPreview || NekoConfig.disableInstantCamera.Bool()) { return; } try { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatGreetingsView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatGreetingsView.java index 412d15b46..8396fcc6c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatGreetingsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatGreetingsView.java @@ -14,7 +14,6 @@ import org.telegram.messenger.ImageLocation; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessageObject; -import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.SvgHelper; import org.telegram.tgnet.TLRPC; @@ -22,7 +21,7 @@ import org.telegram.ui.ActionBar.Theme; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ChatGreetingsView extends LinearLayout { @@ -87,7 +86,7 @@ public class ChatGreetingsView extends LinearLayout { stickerToSendView.setImage(ImageLocation.getForDocument(sticker), createFilter(sticker), ImageLocation.getForDocument(thumb, sticker), null, 0, sticker); } stickerToSendView.setOnClickListener(v -> { - if (NekomuraConfig.dontSendGreetingSticker.Bool()) + if (NekoConfig.dontSendGreetingSticker.Bool()) return; if (listener != null) { listener.onGreetings(sticker); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java index eb8334121..a6d795bfe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java @@ -48,7 +48,7 @@ import org.telegram.ui.ActionBar.Theme; import java.util.List; import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.transtale.TranslatorKt; @@ -196,7 +196,7 @@ public class EditTextCaption extends EditTextBoldCursor { } else { - Translator.translate(TranslateDb.getChatLanguage(delegate.getCurrentChat(), TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String())), text, new Translator.Companion.TranslateCallBack() { + Translator.translate(TranslateDb.getChatLanguage(delegate.getCurrentChat(), TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String())), text, new Translator.Companion.TranslateCallBack() { AlertDialog status = AlertUtil.showProgress(getContext()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index d3fce57aa..b6e0b22bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -15,10 +15,8 @@ import android.animation.ObjectAnimator; import android.animation.StateListAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; -import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; -import android.database.DataSetObserver; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Outline; @@ -71,20 +69,6 @@ import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.TextView; -import androidx.annotation.IntDef; -import androidx.annotation.MainThread; -import androidx.annotation.NonNull; -import androidx.core.view.ViewCompat; -import androidx.recyclerview.widget.GridLayoutManager; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.LinearSmoothScroller; -import androidx.recyclerview.widget.RecyclerView; -import androidx.recyclerview.widget.SimpleItemAnimator; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; - -import com.google.android.exoplayer2.util.Log; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.BuildVars; import org.telegram.messenger.ChatObject; @@ -97,7 +81,6 @@ import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; @@ -113,7 +96,6 @@ import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.Theme; -import org.telegram.ui.Adapters.DialogsSearchAdapter; import org.telegram.ui.Cells.ContextLinkCell; import org.telegram.ui.Cells.EmptyCell; import org.telegram.ui.Cells.FeaturedStickerSetInfoCell; @@ -131,8 +113,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nekogram.PinnedStickerHelper; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.ui.PinnedStickerHelper; public class EmojiView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { @@ -1996,7 +1978,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) { backspacePressed = false; if (!backspaceOnce) { - if (delegate != null && delegate.onBackspace() && !NekomuraConfig.disableVibration.Bool()) { + if (delegate != null && delegate.onBackspace() && !NekoConfig.disableVibration.Bool()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } @@ -3202,7 +3184,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific if (!backspacePressed) { return; } - if (delegate != null && delegate.onBackspace() && !NekomuraConfig.disableVibration.Bool()) { + if (delegate != null && delegate.onBackspace() && !NekoConfig.disableVibration.Bool()) { backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } backspaceOnce = true; @@ -3271,7 +3253,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific if (trendingAdapter != null) { trendingAdapter.notifyDataSetChanged(); } - if (!NekomuraConfig.disableTrending.Bool() && !featured.isEmpty() && (!BuildVars.DEBUG_PRIVATE_VERSION || featuredStickerSets.isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id)) { + if (!NekoConfig.disableTrending.Bool() && !featured.isEmpty() && (!BuildVars.DEBUG_PRIVATE_VERSION || featuredStickerSets.isEmpty() || preferences.getLong("featured_hidden", 0) == featured.get(0).set.id)) { final int id = mediaDataController.getUnreadStickerSets().isEmpty() ? 2 : 3; final StickerTabView trendingStickersTabView = stickersTab.addStickerIconTab(id, stickerIcons[id]); trendingStickersTabView.textView.setText(LocaleController.getString("FeaturedStickersShort", R.string.FeaturedStickersShort)); @@ -3328,7 +3310,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific } stickerSets.add(pack); } - if (info != null && (!NekomuraConfig.hideGroupSticker.Bool())) { + if (info != null && (!NekoConfig.hideGroupSticker.Bool())) { long hiddenStickerSetId = MessagesController.getEmojiSettings(currentAccount).getLong("group_hide_stickers_" + info.id, -1); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(info.id); if (chat == null || info.stickerset == null || !ChatObject.hasAdminRights(chat)) { @@ -3428,7 +3410,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific gifTabs.addIconTab(0, gifIcons[0]).setContentDescription(LocaleController.getString("RecentStickers", R.string.RecentStickers)); } - if (!NekomuraConfig.disableTrending.Bool()) { + if (!NekoConfig.disableTrending.Bool()) { gifTrendingTabNum = gifTabsCount++; gifTabs.addIconTab(1, gifIcons[1]).setContentDescription(LocaleController.getString("FeaturedGifs", R.string.FeaturedGifs)); } @@ -3838,7 +3820,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific } } } - recentStickers = new ArrayList<>(recentStickers.subList(0, Math.min(recentStickers.size(), NekomuraConfig.maxRecentStickerCount.Int()))); + recentStickers = new ArrayList<>(recentStickers.subList(0, Math.min(recentStickers.size(), NekoConfig.maxRecentStickerCount.Int()))); if (previousCount != recentStickers.size() || previousCount2 != favouriteStickers.size()) { updateStickerTabs(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java index 055f42d89..b40dc6b0c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FilterTabsView.java @@ -56,8 +56,8 @@ import org.telegram.ui.ActionBar.Theme; import java.util.ArrayList; +import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; public class FilterTabsView extends FrameLayout { @@ -984,7 +984,7 @@ public class FilterTabsView extends FrameLayout { delegate.onPageSelected(id, scrollingForward); } scrollToChild(position); - if (NekomuraConfig.hideAllTab.Bool() && showAllChatsTab && id != Integer.MAX_VALUE) + if (NekoConfig.hideAllTab.Bool() && showAllChatsTab && id != Integer.MAX_VALUE) toggleAllTabs(false); } @@ -1295,7 +1295,7 @@ public class FilterTabsView extends FrameLayout { manualScrollingToId = -1; currentPosition = position; selectedTabId = id; - if (NekomuraConfig.hideAllTab.Bool() && showAllChatsTab) + if (NekoConfig.hideAllTab.Bool() && showAllChatsTab) toggleAllTabs(false); } } @@ -1517,7 +1517,7 @@ public class FilterTabsView extends FrameLayout { @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { - if (!isEditing || ((showAllChatsTab && viewHolder.getAdapterPosition() == 0) && !NekomuraConfig.pressTitleToOpenAllChats.Bool())) { + if (!isEditing || ((showAllChatsTab && viewHolder.getAdapterPosition() == 0) && !NekoConfig.pressTitleToOpenAllChats.Bool())) { return makeMovementFlags(0, 0); } return makeMovementFlags(ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT, 0); @@ -1559,7 +1559,7 @@ public class FilterTabsView extends FrameLayout { return listView; } - public boolean showAllChatsTab = !NekomuraConfig.hideAllTab.Bool(); + public boolean showAllChatsTab = !NekoConfig.hideAllTab.Bool(); public void toggleAllTabs(boolean show) { if (show == showAllChatsTab) @@ -1571,14 +1571,14 @@ public class FilterTabsView extends FrameLayout { ArrayList filters = AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().dialogFilters; for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter dialogFilter = filters.get(a); - switch (NekomuraConfig.tabsTitleType.Int()) { - case NekoConfig.TITLE_TYPE_TEXT: + switch (NekoConfig.tabsTitleType.Int()) { + case NekoXConfig.TITLE_TYPE_TEXT: addTab(a, filters.get(a).localId, dialogFilter.name); break; - case NekoConfig.TITLE_TYPE_ICON: + case NekoXConfig.TITLE_TYPE_ICON: addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon : "📂"); break; - case NekoConfig.TITLE_TYPE_MIX: + case NekoXConfig.TITLE_TYPE_MIX: addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon + " " + dialogFilter.name : "📂 " + dialogFilter.name); break; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java index 8a2848081..f41ce73c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentContextView.java @@ -81,7 +81,7 @@ import org.telegram.ui.LocationActivity; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class FragmentContextView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, VoIPService.StateListener { @@ -449,7 +449,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent isMuted = false; AndroidUtilities.runOnUIThread(toggleMicRunnable, 90); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } }; @@ -543,7 +543,7 @@ public class FragmentContextView extends FrameLayout implements NotificationCent } muteButton.playAnimation(); Theme.getFragmentContextViewWavesDrawable().updateState(true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java index fe1f4746e..0b497782c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCallPip.java @@ -37,7 +37,7 @@ import org.telegram.messenger.voip.VoIPService; import org.telegram.tgnet.TLRPC; import org.telegram.ui.GroupCallActivity; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; @@ -131,7 +131,7 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega return; } AndroidUtilities.runOnUIThread(micRunnable, 90); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } pressed = true; @@ -257,7 +257,7 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega if (pressed) { if (VoIPService.getSharedInstance() != null) { VoIPService.getSharedInstance().setMicMute(true, false, false); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } @@ -891,7 +891,7 @@ public class GroupCallPip implements NotificationCenter.NotificationCenterDelega iconView.playAnimation(); } if (prepare) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { button.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ImageUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ImageUpdater.java index bec18a1a3..ac86a33e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ImageUpdater.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ImageUpdater.java @@ -61,7 +61,7 @@ import java.util.ArrayList; import java.util.HashMap; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; public class ImageUpdater implements NotificationCenter.NotificationCenterDelegate, PhotoCropActivity.PhotoEditActivityDelegate { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java index 61cdb6918..1a2ec3200 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java @@ -109,7 +109,7 @@ import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.opengles.GL; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; @TargetApi(18) public class InstantCameraView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { @@ -540,7 +540,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter textureOverlayView.setImageResource(R.drawable.icplaceholder); } cameraReady = false; - isFrontface = !NekomuraConfig.rearVideoMessages.Bool(); + isFrontface = !NekoConfig.rearVideoMessages.Bool(); selectedCamera = null; recordedTime = 0; progress = 0; @@ -2196,7 +2196,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter if (cancelled) { return; } - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { try { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } catch (Exception ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/EntityView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/EntityView.java index 6e5e0f3b2..bfbb0a9ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/EntityView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/EntityView.java @@ -15,7 +15,7 @@ import org.telegram.ui.Components.Rect; import java.util.UUID; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class EntityView extends FrameLayout { @@ -59,7 +59,7 @@ public class EntityView extends FrameLayout { recognizedLongPress = true; if (delegate != null) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } delegate.onEntityLongClicked(EntityView.this); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java index 02667c74a..fd6d41566 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java @@ -27,7 +27,6 @@ import android.hardware.biometrics.BiometricManager; import android.hardware.biometrics.BiometricPrompt; import android.os.Build; import android.os.SystemClock; -import android.os.Vibrator; import androidx.annotation.IdRes; import androidx.core.content.ContextCompat; @@ -55,9 +54,6 @@ import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.annotation.IdRes; -import androidx.core.os.CancellationSignal; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; @@ -73,7 +69,7 @@ import java.util.ArrayList; import java.util.Locale; import java.util.concurrent.Executor; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.VibrateUtil; public class PasscodeView extends FrameLayout { @@ -130,7 +126,7 @@ public class PasscodeView extends FrameLayout { return; } try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } catch (Exception e) { @@ -253,7 +249,7 @@ public class PasscodeView extends FrameLayout { return false; } try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java index 1f8f4ede5..00b063618 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProximitySheet.java @@ -37,7 +37,7 @@ import org.telegram.ui.ActionBar.Theme; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ProximitySheet extends FrameLayout { @@ -202,7 +202,7 @@ public class ProximitySheet extends FrameLayout { kmPicker.setTextOffset(AndroidUtilities.dp(20)); final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> { try { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } catch (Exception ignore) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java index c98332ca0..ef9c0fc36 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java @@ -22,8 +22,6 @@ import android.text.TextUtils; import android.view.HapticFeedbackConstants; import android.view.View; -import com.google.android.exoplayer2.util.Log; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.DispatchQueuePool; @@ -42,7 +40,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class RLottieDrawable extends BitmapDrawable implements Animatable { @@ -1010,7 +1008,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable { } else if (nextRenderingBitmap != null && (renderingBitmap == null || timeDiff >= timeCheck) && isCurrentParentViewMaster()) { if (vibrationPattern != null && currentParentView != null) { Integer force = vibrationPattern.get(currentFrame - 1); - if (force != null && !NekomuraConfig.disableVibration.Bool()) { + if (force != null && !NekoConfig.disableVibration.Bool()) { currentParentView.performHapticFeedback(force == 1 ? HapticFeedbackConstants.LONG_PRESS : HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java index 13e0243e7..f363bb3f5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java @@ -59,12 +59,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashSet; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.ColorUtils; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class RecyclerListView extends RecyclerView { @@ -1005,14 +1000,14 @@ public class RecyclerListView extends RecyclerView { View child = currentChildView; if (onItemLongClickListener != null) { if (onItemLongClickListener.onItemClick(currentChildView, currentChildPosition)) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } child.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); } } else { if (onItemLongClickListenerExtended.onItemClick(currentChildView, currentChildPosition, event.getX() - currentChildView.getX(), event.getY() - currentChildView.getY())) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { child.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } child.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java index 18c5cfe05..298d0d1fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java @@ -100,7 +100,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ShareAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate { @@ -1269,13 +1269,13 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi if (sendingMessageObjects != null) { for (int a = 0; a < selectedDialogs.size(); a++) { long key = selectedDialogs.keyAt(a); - if (NekomuraConfig.sendCommentAfterForward.Bool()) { + if (NekoConfig.sendCommentAfterForward.Bool()) { SendMessagesHelper.getInstance(currentAccount).sendMessage(sendingMessageObjects, key, false, false, true, 0); } if (frameLayout2.getTag() != null && commentTextView.length() > 0) { SendMessagesHelper.getInstance(currentAccount).sendMessage(commentTextView.getText().toString(), key, null, null, null, true, null, null, null, true, 0, null); } - if (!NekomuraConfig.sendCommentAfterForward.Bool()) { + if (!NekoConfig.sendCommentAfterForward.Bool()) { SendMessagesHelper.getInstance(currentAccount).sendMessage(sendingMessageObjects, key, false, false, true, 0); } } @@ -1290,13 +1290,13 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi if (sendingText[num] != null) { for (int a = 0; a < selectedDialogs.size(); a++) { long key = selectedDialogs.keyAt(a); - if (NekomuraConfig.sendCommentAfterForward.Bool()) { + if (NekoConfig.sendCommentAfterForward.Bool()) { SendMessagesHelper.getInstance(currentAccount).sendMessage(sendingText[num], key, null, null, null, true, null, null, null, true, 0, null); } if (frameLayout2.getTag() != null && commentTextView.length() > 0) { SendMessagesHelper.getInstance(currentAccount).sendMessage(commentTextView.getText().toString(), key, null, null, null, true, null, null, null, true, 0, null); } - if (!NekomuraConfig.sendCommentAfterForward.Bool()) { + if (!NekoConfig.sendCommentAfterForward.Bool()) { SendMessagesHelper.getInstance(currentAccount).sendMessage(sendingText[num], key, null, null, null, true, null, null, null, true, 0, null); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java index a09e7f522..565db50aa 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java @@ -55,8 +55,6 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.exoplayer2.util.Log; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ChatObject; @@ -72,7 +70,6 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; -import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; import org.telegram.messenger.browser.Browser; @@ -118,7 +115,7 @@ import java.util.HashMap; import java.util.HashSet; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java index 201d2f175..867bf081a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java @@ -51,13 +51,12 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserObject; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.LaunchActivity; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import java.util.ArrayList; @@ -449,7 +448,7 @@ public class UndoView extends FrameLayout { timeLeft = 5000; currentInfoObject = infoObject; - if (NekomuraConfig.disableUndo.Bool() && !isTooltipAction()) { + if (NekoConfig.disableUndo.Bool() && !isTooltipAction()) { if (actionRunnable != null) actionRunnable.run(); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/WallpaperUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/WallpaperUpdater.java index 5cea0a244..611085f17 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/WallpaperUpdater.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/WallpaperUpdater.java @@ -37,7 +37,7 @@ import java.io.FileOutputStream; import java.util.ArrayList; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; public class WallpaperUpdater { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ZoomControlView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ZoomControlView.java index 056462b60..fb71af207 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ZoomControlView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ZoomControlView.java @@ -15,7 +15,7 @@ import android.view.View; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.R; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ZoomControlView extends View { @@ -126,7 +126,7 @@ public class ZoomControlView extends View { handled = true; } else if (x >= minusCx - AndroidUtilities.dp(16) && x <= minusCx + AndroidUtilities.dp(16) && y >= minusCy - AndroidUtilities.dp(16) && y <= minusCy + AndroidUtilities.dp(16)) { if (action == MotionEvent.ACTION_UP && animateToZoom((float) Math.floor(getZoom() / 0.25f) * 0.25f - 0.25f)) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } else { @@ -135,7 +135,7 @@ public class ZoomControlView extends View { handled = true; } else if (x >= plusCx - AndroidUtilities.dp(16) && x <= plusCx + AndroidUtilities.dp(16) && y >= plusCy - AndroidUtilities.dp(16) && y <= plusCy + AndroidUtilities.dp(16)) { if (action == MotionEvent.ACTION_UP && animateToZoom((float) Math.floor(getZoom() / 0.25f) * 0.25f + 0.25f)) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP); } } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/VoIPHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/VoIPHelper.java index 293e9e5df..32a7bd9df 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/VoIPHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/voip/VoIPHelper.java @@ -61,7 +61,7 @@ import java.util.Collections; import java.util.Locale; import java.util.Set; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class VoIPHelper { @@ -103,7 +103,7 @@ public class VoIPHelper { return; } - if (!confirmed && NekomuraConfig.askBeforeCall.Bool()) { + if (!confirmed && NekoConfig.askBeforeCall.Bool()) { new AlertDialog.Builder(activity) .setTitle(LocaleController.getString("ConfirmCall", R.string.ConfirmCall)) .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallTo", R.string.CallTo, diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java index 19c02c878..ec8f78f9f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java @@ -57,15 +57,13 @@ import org.telegram.ui.Cells.ContextLinkCell; import org.telegram.ui.Cells.StickerCell; import org.telegram.ui.Cells.StickerEmojiCell; import org.telegram.ui.Components.AlertsCreator; -import org.telegram.ui.Components.ChatAvatarContainer; -import org.telegram.ui.Components.EmojiView; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RecyclerListView; import java.io.FileOutputStream; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ContentPreviewViewer { @@ -264,7 +262,7 @@ public class ContentPreviewViewer { close(); }); visibleDialog.show(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { containerView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } if (delegate != null && delegate.needRemove()) { @@ -358,7 +356,7 @@ public class ContentPreviewViewer { close(); }); visibleDialog.show(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { containerView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } if (canDelete) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DataSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DataSettingsActivity.java index 54b0f1450..f9851fee6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DataSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DataSettingsActivity.java @@ -52,10 +52,9 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.utils.EnvUtil; -import tw.nekomimi.nkmr.NekomuraConfig; public class DataSettingsActivity extends BaseFragment { @@ -342,7 +341,7 @@ public class DataSettingsActivity extends BaseFragment { AtomicReference target = new AtomicReference<>(); builder.addRadioItems(EnvUtil.getAvailableDirectories(), - (index, path) -> path.equals(NekomuraConfig.cachePath.String()), (__, path, cell) -> { + (index, path) -> path.equals(NekoConfig.cachePath.String()), (__, path, cell) -> { target.set(path); builder.doRadioCheck(cell); @@ -356,7 +355,7 @@ public class DataSettingsActivity extends BaseFragment { if (target.get() != null) { - NekomuraConfig.cachePath.setConfigString(target.get()); + NekoConfig.cachePath.setConfigString(target.get()); ImageLoader.getInstance().checkMediaPaths(); listAdapter.notifyItemChanged(position); @@ -482,7 +481,7 @@ public class DataSettingsActivity extends BaseFragment { } else if (position == dataUsageRow) { textCell.setText(LocaleController.getString("NetworkUsage", R.string.NetworkUsage), true); } else if (position == storageNumRow) { - textCell.setTextAndValue(LocaleController.getString("StoragePath", R.string.StoragePath), NekomuraConfig.cachePath.String(), false); + textCell.setTextAndValue(LocaleController.getString("StoragePath", R.string.StoragePath), NekoConfig.cachePath.String(), false); } else if (position == proxyRow) { textCell.setText(LocaleController.getString("ProxySettings", R.string.ProxySettings), false); } else if (position == resetDownloadRow) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java b/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java index 48d56c36c..2744d13ce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DatabaseMigrationHint.java @@ -20,10 +20,8 @@ import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RLottieImageView; -import java.util.concurrent.Executor; - import tw.nekomimi.nekogram.utils.EnvUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class DatabaseMigrationHint extends FrameLayout { @@ -82,8 +80,8 @@ public class DatabaseMigrationHint extends FrameLayout { // Move to /sdcard/Android/...... automatically if (Build.VERSION.SDK_INT >= 30) { ContextCompat.getMainExecutor(getContext()).execute(() -> { - if (!NekomuraConfig.cachePath.String().contains("/data/")) { - NekomuraConfig.cachePath.setConfigString(EnvUtil.getAvailableDirectories()[2]); + if (!NekoConfig.cachePath.String().contains("/data/")) { + NekoConfig.cachePath.setConfigString(EnvUtil.getAvailableDirectories()[2]); ImageLoader.getInstance().checkMediaPaths(); } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 79c7ea3fd..0164b43ab 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -176,10 +176,9 @@ import java.io.File; import java.util.ArrayList; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.InternalUpdater; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.utils.PrivacyUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; @@ -736,7 +735,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. viewPages[a].setTranslationY(0); } } - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { actionBar.setTranslationY(0); } searchViewPager.setTranslationY(0); @@ -759,7 +758,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - AndroidUtilities.dp(44) - topPadding; } else { - h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - ((onlySelect && !(initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool())) ? 0 : actionBar.getMeasuredHeight()) - topPadding; + h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - ((onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool())) ? 0 : actionBar.getMeasuredHeight()) - topPadding; } if (filtersTabAnimator != null && filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { @@ -776,7 +775,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. searchViewPager.setTranslationY(0); int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY); int h = View.MeasureSpec.getSize(heightMeasureSpec) + keyboardSize; - int contentHeightSpec = View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect && !(initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) ? 0 : actionBar.getMeasuredHeight()) - topPadding) - (searchTabsView == null ? 0 : AndroidUtilities.dp(44)), View.MeasureSpec.EXACTLY); + int contentHeightSpec = View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) ? 0 : actionBar.getMeasuredHeight()) - topPadding) - (searchTabsView == null ? 0 : AndroidUtilities.dp(44)), View.MeasureSpec.EXACTLY); child.measure(contentWidthSpec, contentHeightSpec); child.setPivotX(child.getMeasuredWidth() / 2); } else if (commentView != null && commentView.isPopupView(child)) { @@ -866,11 +865,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } else if (child == filterTabsView || child == searchTabsView || child == filtersView) { childTop = actionBar.getMeasuredHeight(); } else if (child == searchViewPager) { - childTop = (onlySelect && !(initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) ? 0 : actionBar.getMeasuredHeight()) + topPadding + (searchTabsView == null ? 0 : AndroidUtilities.dp(44)); + childTop = (onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) ? 0 : actionBar.getMeasuredHeight()) + topPadding + (searchTabsView == null ? 0 : AndroidUtilities.dp(44)); } else if (child instanceof DatabaseMigrationHint) { childTop = actionBar.getMeasuredHeight(); } else if (child instanceof ViewPage) { - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { childTop = AndroidUtilities.dp(44); } else { @@ -1264,7 +1263,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. @Override protected void onMeasure(int widthSpec, int heightSpec) { int t = 0; - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { t = AndroidUtilities.dp(44); } else { @@ -1283,7 +1282,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. ignoreLayout = false; } } - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { ignoreLayout = true; if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { t = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0); @@ -1307,7 +1306,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } checkIfAdapterValid(); super.onMeasure(widthSpec, heightSpec); - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { if (appliedPaddingTop != t && viewPages != null && viewPages.length > 1) { viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth()); } @@ -1447,7 +1446,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } if (!canShowHiddenArchive) { canShowHiddenArchive = true; - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } if (parentPage.pullForegroundDrawable != null) { @@ -1458,7 +1457,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. parentPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED; - if (NekomuraConfig.openArchiveOnPull.Bool()) { + if (NekoConfig.openArchiveOnPull.Bool()) { AndroidUtilities.runOnUIThread(() -> { // Open the folder. // Delay was taken from PullForegroundDrawable::startOutAnimation(). @@ -1824,7 +1823,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. getNotificationCenter().addObserver(this, NotificationCenter.dialogsNeedReload); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded); - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeSearchByActiveAction); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged); getNotificationCenter().addObserver(this, NotificationCenter.filterSettingsUpdated); @@ -1898,7 +1897,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (searchString == null) { getNotificationCenter().removeObserver(this, NotificationCenter.dialogsNeedReload); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded); - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeSearchByActiveAction); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.proxySettingsChanged); getNotificationCenter().removeObserver(this, NotificationCenter.filterSettingsUpdated); @@ -2129,7 +2128,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault)); actionBar.setOnLongClickListener(v -> { - if (NekomuraConfig.hideAllTab.Bool() && NekomuraConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) { + if (NekoConfig.hideAllTab.Bool() && NekoConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) { filterTabsView.toggleAllTabs(true); filterTabsView.selectFirstTab(); } @@ -2147,7 +2146,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } else { actionBar.setTitle(LocaleController.getString("NekoX", R.string.NekoX)); actionBar.setOnLongClickListener(v -> { - if (NekomuraConfig.hideAllTab.Bool() && NekomuraConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) { + if (NekoConfig.hideAllTab.Bool() && NekoConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE) { filterTabsView.toggleAllTabs(true); filterTabsView.selectFirstTab(); } @@ -2158,7 +2157,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. actionBar.setSupportsHolidayImage(true); } } - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { actionBar.setAddToContainer(false); actionBar.setCastShadows(false); actionBar.setClipContent(true); @@ -2170,7 +2169,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. scrollToTop(); }); - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || initialDialogsType == 0 && folderId == 0 && !onlySelect && TextUtils.isEmpty(searchString)) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || initialDialogsType == 0 && folderId == 0 && !onlySelect && TextUtils.isEmpty(searchString)) { scrimPaint = new Paint() { @Override public void setAlpha(int a) { @@ -2571,7 +2570,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. ContentView contentView = new ContentView(context); fragmentView = contentView; - int pagesCount = (initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || (folderId == 0 && initialDialogsType == 0 && !onlySelect) ? 2 : 1; + int pagesCount = (initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || (folderId == 0 && initialDialogsType == 0 && !onlySelect) ? 2 : 1; viewPages = new ViewPage[pagesCount]; for (int a = 0; a < pagesCount; a++) { final ViewPage viewPage = new ViewPage(context) { @@ -2764,7 +2763,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (canShowHiddenArchive != canShowInternal) { canShowHiddenArchive = canShowInternal; if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { viewPage.listView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } if (viewPage.pullForegroundDrawable != null) { @@ -3406,7 +3405,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (filterTabsView != null) { contentView.addView(filterTabsView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44)); } - if ((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) || !onlySelect) { + if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) || !onlySelect) { final FrameLayout.LayoutParams layoutParams = LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT); if (inPreviewMode && Build.VERSION.SDK_INT >= 21) { layoutParams.topMargin = AndroidUtilities.statusBarHeight; @@ -3709,7 +3708,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } private void updateFiltersView(boolean showMediaFilters, ArrayList users, ArrayList dates, boolean archive, boolean animated) { - if (!searchIsShowed || onlySelect && !(initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool())) { + if (!searchIsShowed || onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool())) { return; } boolean hasMediaFilter = false; @@ -4032,20 +4031,20 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. filterTabsView.addTab(Integer.MAX_VALUE, 0, LocaleController.getString("FilterAllChats", R.string.FilterAllChats)); for (int a = 0, N = filters.size(); a < N; a++) { MessagesController.DialogFilter dialogFilter = filters.get(a); - switch (NekomuraConfig.tabsTitleType.Int()) { - case NekoConfig.TITLE_TYPE_TEXT: + switch (NekoConfig.tabsTitleType.Int()) { + case NekoXConfig.TITLE_TYPE_TEXT: filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.name); break; - case NekoConfig.TITLE_TYPE_ICON: + case NekoXConfig.TITLE_TYPE_ICON: filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon : "📂"); break; - case NekoConfig.TITLE_TYPE_MIX: + case NekoXConfig.TITLE_TYPE_MIX: filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon + " " + dialogFilter.name : "📂 " + dialogFilter.name); break; } } id = filterTabsView.getCurrentTabId(); - boolean updateCurrentTab = NekomuraConfig.hideAllTab.Bool(); + boolean updateCurrentTab = NekoConfig.hideAllTab.Bool(); if (id >= 0) { if (viewPages[0].selectedType != id) { updateCurrentTab = true; @@ -4324,11 +4323,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. return false; } else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) { - if(!NekomuraConfig.hideAllTab.Bool()){ + if(!NekoConfig.hideAllTab.Bool()){ filterTabsView.selectFirstTab(); return false; } - if (!NekomuraConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null) { + if (!NekoConfig.pressTitleToOpenAllChats.Bool() && filterTabsView != null) { // not hideAllTab OR hideAllTab but not pressTitleToOpenAllChats filterTabsView.toggleAllTabs(true); filterTabsView.selectFirstTab(); @@ -5111,7 +5110,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. updateSelectedCount(); } else { if (dialog instanceof TLRPC.TL_dialogFolder) { - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } BottomBuilder builder = new BottomBuilder(getParentActivity()); @@ -5454,7 +5453,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. int maxPinnedCount; if (containsFilter) { maxPinnedCount = 100 - filter.alwaysShow.size(); - } else if (NekomuraConfig.unlimitedPinnedDialogs.Bool() || folderId != 0 || filter != null) { + } else if (NekoConfig.unlimitedPinnedDialogs.Bool() || folderId != 0 || filter != null) { maxPinnedCount = getMessagesController().maxFolderPinnedDialogsCount; } else { maxPinnedCount = getMessagesController().maxPinnedDialogsCount; @@ -6253,7 +6252,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); String proxyAddress = preferences.getString("proxy_ip", ""); boolean proxyEnabled; - if (!NekomuraConfig.useProxyItem.Bool() && (!NekomuraConfig.hideProxyByDefault.Bool() || (proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty())) { + if (!NekoConfig.useProxyItem.Bool() && (!NekoConfig.hideProxyByDefault.Bool() || (proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty())) { if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) { proxyItem.setVisibility(View.VISIBLE); } @@ -7820,7 +7819,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. @Override public boolean isSwipeBackEnabled(MotionEvent event) { - return !((initialDialogsType == 3 && NekomuraConfig.showTabsOnForward.Bool()) && viewPages[0].selectedType != filterTabsView.getFirstTabId()); + return !((initialDialogsType == 3 && NekoConfig.showTabsOnForward.Bool()) && viewPages[0].selectedType != filterTabsView.getFirstTabId()); } public void setShowSearch(String query, int i) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 55eb1e17a..d79ed3cbd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -101,7 +101,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import cn.hutool.core.collection.CollectionUtil; import kotlin.Unit; import tw.nekomimi.nekogram.utils.EnvUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.transtale.TranslatorKt; @@ -748,7 +748,7 @@ public class DocumentSelectActivity extends BaseFragment { sendPopupWindow.dismiss(); } if (num == 0) { - translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); } else if (num == 1) { AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), this::sendSelectedFiles); } else if (num == 2) { @@ -787,7 +787,7 @@ public class DocumentSelectActivity extends BaseFragment { view.getLocationInWindow(location); sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2)); sendPopupWindow.dimBehind(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java b/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java index 13bfc7b50..105a421ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/EmojiAnimationsOverlay.java @@ -33,7 +33,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Random; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCenterDelegate { @@ -154,7 +154,7 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe checkStickerPack(); } } else if (id == NotificationCenter.onEmojiInteractionsReceived) { - if (NekomuraConfig.disableRemoteEmojiInteractions.Bool()) + if (NekoConfig.disableRemoteEmojiInteractions.Bool()) return; long dialogId = (long) args[0]; TLRPC.TL_sendMessageEmojiInteraction action = (TLRPC.TL_sendMessageEmojiInteraction) args[1]; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java b/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java index 0d58fe39a..2aa889a45 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java @@ -75,7 +75,7 @@ import java.util.HashMap; import java.util.Locale; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index dac29989f..b116bb5b4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -35,8 +35,6 @@ import android.media.projection.MediaProjectionManager; import android.os.Build; import android.os.Bundle; import android.os.SystemClock; -import android.os.Vibrator; -import android.provider.Settings; import android.provider.Settings; import android.text.Editable; import android.text.InputType; @@ -44,9 +42,6 @@ import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Property; -import android.util.SparseArray; -import android.util.SparseBooleanArray; -import android.util.SparseIntArray; import android.util.TypedValue; import android.view.Gravity; import android.view.HapticFeedbackConstants; @@ -133,7 +128,6 @@ import org.telegram.ui.Components.GroupVoipInviteAlert; import org.telegram.ui.Components.HintView; import org.telegram.ui.Components.ImageUpdater; import org.telegram.ui.Components.JoinCallAlert; -import org.telegram.ui.Components.GroupVoipInviteAlert; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberPicker; import org.telegram.ui.Components.ProfileGalleryView; @@ -160,12 +154,10 @@ import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import static android.content.Context.AUDIO_SERVICE; -import com.google.android.exoplayer2.util.Log; - public class GroupCallActivity extends BottomSheet implements NotificationCenter.NotificationCenterDelegate, VoIPService.StateListener { public final static int TABLET_LIST_SIZE = 320; @@ -421,7 +413,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter if (call == null || !scheduled || VoIPService.getSharedInstance() == null) { return; } - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } updateMuteButton(MUTE_BUTTON_STATE_MUTE, true); @@ -4074,7 +4066,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter updateMuteButton(MUTE_BUTTON_STATE_UNMUTE, true); if (VoIPService.getSharedInstance() != null) { VoIPService.getSharedInstance().setMicMute(true, true, false); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } @@ -4202,13 +4194,13 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter } else if (muteButtonState == MUTE_BUTTON_STATE_UNMUTE) { updateMuteButton(MUTE_BUTTON_STATE_MUTE, true); VoIPService.getSharedInstance().setMicMute(false, false, true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } else { updateMuteButton(MUTE_BUTTON_STATE_UNMUTE, true); VoIPService.getSharedInstance().setMicMute(true, false, true); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { muteButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index fd66faf91..0b3dc1c09 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -51,10 +51,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; -import androidx.annotation.Keep; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; @@ -96,7 +92,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class GroupCreateActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, View.OnClickListener { @@ -1194,7 +1190,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen firstName = chat.title; lastName = ""; } - if (NekomuraConfig.nameOrder.Int() == 1) { + if (NekoConfig.nameOrder.Int() == 1) { if (!TextUtils.isEmpty(firstName)) { return firstName.substring(0, 1).toUpperCase(); } else if (!TextUtils.isEmpty(lastName)) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 352fd40a2..be2b07059 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -8,58 +8,31 @@ package org.telegram.ui; -import android.animation.ValueAnimator; import android.content.Context; -import android.content.DialogInterface; -import android.content.SharedPreferences; -import android.content.res.Configuration; -import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.FrameLayout; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import android.widget.LinearLayout; -import android.widget.TextView; - import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.Utilities; -import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.ThemeDescription; -import org.telegram.ui.Cells.HeaderCell; import org.telegram.ui.Cells.LanguageCell; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; -import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.ActionBar.Theme; -import org.telegram.ui.ActionBar.ThemeDescription; -import org.telegram.ui.Cells.LanguageCell; -import org.telegram.ui.ActionBar.Theme; -import org.telegram.ui.ActionBar.ThemeDescription; -import org.telegram.ui.Cells.HeaderCell; -import org.telegram.ui.Cells.LanguageCell; import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Components.AlertsCreator; -import org.telegram.ui.Cells.TextCheckCell; -import org.telegram.ui.Cells.TextInfoPrivacyCell; -import org.telegram.ui.Cells.TextRadioCell; -import org.telegram.ui.Cells.TextSettingsCell; -import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.EmptyTextProgressView; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RecyclerListView; @@ -67,13 +40,10 @@ import org.telegram.ui.Components.RecyclerListView; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; import java.util.Timer; -import java.util.TimerTask; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ShareUtil; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index ee7efadb5..4fbf81aa1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -155,10 +155,9 @@ import java.util.regex.Pattern; import cn.hutool.core.util.StrUtil; import kotlin.Unit; import kotlin.text.StringsKt; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.ExternalGcm; import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nkmr.NekomuraConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.settings.NekoSettingsActivity; import tw.nekomimi.nekogram.proxy.SubInfo; @@ -911,7 +910,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa ExternalGcm.checkUpdate(this); - if (NekomuraConfig.autoUpdateSubInfo.Bool()) for (SubInfo subInfo : SubManager.getSubList().find()) { + if (NekoConfig.autoUpdateSubInfo.Bool()) for (SubInfo subInfo : SubManager.getSubList().find()) { if (subInfo == null || !subInfo.enable) continue; @@ -4040,7 +4039,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa showPermissionErrorAlert(LocaleController.getString("VoipNeedCameraPermission", R.string.VoipNeedCameraPermission)); } } else if (requestCode == 4) { - NekoConfig.checkForceSystemPicker(); + NekoXConfig.checkForceSystemPicker(); if (!granted) { showPermissionErrorAlert(LocaleController.getString("PermissionStorage", R.string.PermissionStorage)); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index b89a583f9..4c4c28cf3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -134,9 +134,9 @@ import cn.hutool.core.codec.Base64; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.DataCenter; -import tw.nekomimi.nekogram.EditTextAutoFill; +import tw.nekomimi.nekogram.ui.EditTextAutoFill; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java index c72058787..94bc907f5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java @@ -76,7 +76,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ManageLinksActivity extends BaseFragment { @@ -644,7 +644,7 @@ public class ManageLinksActivity extends BaseFragment { if ((position >= linksStartRow && position < linksEndRow) || (position >= revokedLinksStartRow && position < revokedLinksEndRow)) { LinkCell cell = (LinkCell) view; cell.optionsView.callOnClick(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } return true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java index f92ed0fca..7e698e0ee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java @@ -79,7 +79,7 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import kotlin.Unit; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.transtale.TranslatorKt; @@ -513,7 +513,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati sendPopupWindow.dismiss(); } if (num == 0) { - translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); } else if (num == 1) { AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), (notify, scheduleDate) -> { sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, notify, scheduleDate); @@ -557,7 +557,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati view.getLocationInWindow(location); sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2)); sendPopupWindow.dimBehind(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index c593d4678..0f1b28145 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -78,7 +78,6 @@ import org.telegram.ui.ActionBar.ActionBarMenuSubItem; import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BaseFragment; -import org.telegram.ui.ActionBar.SimpleTextView; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.Cells.DividerCell; @@ -103,7 +102,7 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicBoolean; import kotlin.Unit; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; import tw.nekomimi.nekogram.transtale.TranslatorKt; @@ -1121,7 +1120,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen sendPopupWindow.dismiss(); } if (num == 0) { - translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); } else if (num == 1) { AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), this::sendSelectedPhotos); } else if (num == 2) { @@ -1161,7 +1160,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen view.getLocationInWindow(location); sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2)); sendPopupWindow.dimBehind(); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 1c093e987..b3214fefd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -66,7 +66,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearSmoothScrollerEnd; import androidx.recyclerview.widget.RecyclerView; -import android.text.Editable; import android.text.Layout; import android.text.Selection; import android.text.Spannable; @@ -122,29 +121,10 @@ import android.widget.Scroller; import android.widget.TextView; import android.widget.Toast; -import androidx.annotation.Keep; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.collection.ArrayMap; -import androidx.core.content.ContextCompat; -import androidx.core.content.FileProvider; -import androidx.core.graphics.ColorUtils; -import androidx.core.view.ViewCompat; -import androidx.core.widget.NestedScrollView; -import androidx.dynamicanimation.animation.DynamicAnimation; -import androidx.dynamicanimation.animation.SpringAnimation; -import androidx.dynamicanimation.animation.SpringForce; -import androidx.exifinterface.media.ExifInterface; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.LinearSmoothScrollerEnd; -import androidx.recyclerview.widget.RecyclerView; - import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.analytics.AnalyticsListener; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; -import com.google.android.exoplayer2.util.Log; import org.jetbrains.annotations.NotNull; import org.telegram.messenger.AndroidUtilities; @@ -179,14 +159,6 @@ import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; import org.telegram.messenger.VideoEditedInfo; import org.telegram.messenger.WebFile; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.FileLoader; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MediaController; -import org.telegram.messenger.MessagesController; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.R; import org.telegram.messenger.browser.Browser; import org.telegram.messenger.video.VideoPlayerRewinder; import org.telegram.tgnet.ConnectionsManager; @@ -274,8 +246,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import kotlin.Unit; -import tw.nekomimi.nekogram.MessageHelper; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.transtale.TranslateDb; import tw.nekomimi.nekogram.transtale.Translator; @@ -5296,7 +5267,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else if (a == 3) { sendPressed(true, 0); } else if (a == 4) { - translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekomuraConfig.translateInputLang.String()))); + translateComment(TranslateDb.getChatLanguage(chatId, TranslatorKt.getCode2Locale(NekoConfig.translateInputLang.String()))); } else if (a == 5) { sendPressed(true, 0, false, true); } @@ -5336,7 +5307,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat int[] location = new int[2]; view.getLocationInWindow(location); sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(14), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(18)); - if (!NekomuraConfig.disableVibration.Bool()) { + if (!NekoConfig.disableVibration.Bool()) { view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } @@ -10150,7 +10121,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat MessagesController.getInstance(currentAccount).loadDialogPhotos(avatarsDialogId, 80, 0, true, classGuid); } } - if (currentMessageObject != null && currentMessageObject.isVideo() || (NekomuraConfig.takeGIFasVideo.Bool() && currentMessageObject != null && currentMessageObject.isGif()) || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || pageBlocksAdapter != null && pageBlocksAdapter.isVideo(index)) { + if (currentMessageObject != null && currentMessageObject.isVideo() || (NekoConfig.takeGIFasVideo.Bool() && currentMessageObject != null && currentMessageObject.isGif()) || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || pageBlocksAdapter != null && pageBlocksAdapter.isVideo(index)) { playerAutoStarted = true; onActionClick(false); } else if (!imagesArrLocals.isEmpty()) { @@ -13247,7 +13218,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (photoPaintView != null) { photoPaintView.onResume(); } - if (pausedOnPause && NekomuraConfig.autoPauseVideo.Bool() && videoPlayer != null && !videoPlayer.isPlaying()) { + if (pausedOnPause && NekoConfig.autoPauseVideo.Bool() && videoPlayer != null && !videoPlayer.isPlaying()) { pausedOnPause = false; videoPlayer.play(); } @@ -13270,7 +13241,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (videoPlayer != null && playerLooping) { videoPlayer.setLooping(false); } - if (NekomuraConfig.autoPauseVideo.Bool() && videoPlayer != null && videoPlayer.isPlaying()) { + if (NekoConfig.autoPauseVideo.Bool() && videoPlayer != null && videoPlayer.isPlaying()) { pausedOnPause = true; videoPlayer.pause(); } @@ -14529,7 +14500,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public boolean onDown(MotionEvent e) { if (!doubleTap && checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) { float x = e.getX(); - int side = NekomuraConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); + int side = NekoConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); if (x < side) { if (leftImage.hasImageSet()) { drawPressedDrawable[0] = true; @@ -14549,7 +14520,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public boolean canDoubleTap(MotionEvent e) { if (checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) { float x = e.getX(); - int side = NekomuraConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); + int side = NekoConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); if (x < side || x > containerView.getMeasuredWidth() - side) { return currentMessageObject == null || currentMessageObject.isVideo() && (SystemClock.elapsedRealtime() - lastPhotoSetTime) >= 500 && canDoubleTapSeekVideo(e); } @@ -14643,7 +14614,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat float y = e.getY(); if (checkImageView.getVisibility() != View.VISIBLE) { if (y > ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight + AndroidUtilities.dp(40)) { - int side = NekomuraConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); + int side = NekoConfig.disablePhotoSideAction.Bool() ? 0 : Math.min(135, containerView.getMeasuredWidth() / 8); if (x < side) { if (leftImage.hasImageSet()) { switchToNextIndex(-1, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index fbfc66176..4aaa877ec 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -81,7 +81,7 @@ import org.telegram.ui.Components.TypingDotsDrawable; import java.io.File; import java.util.ArrayList; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class PopupNotificationActivity extends Activity implements NotificationCenter.NotificationCenterDelegate { @@ -932,7 +932,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC double lat = geoPoint.lat; double lon = geoPoint._long; - if (NekomuraConfig.mapPreviewProvider.Int() == 0) { + if (NekoConfig.mapPreviewProvider.Int() == 0) { imageView.setImage(ImageLocation.getForWebFile(WebFile.createWithGeoPoint(geoPoint, 100, 100, 15, Math.min(2, (int) Math.ceil(AndroidUtilities.density)))), null, null, null, messageObject); } else { String currentUrl = AndroidUtilities.formapMapUrl(false, lat, lon, 100, 100, true, 15); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index af9b2aa95..9b5fff838 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -179,9 +179,9 @@ import cn.hutool.core.util.RuntimeUtil; import cn.hutool.core.util.StrUtil; import kotlin.Unit; import libv2ray.Libv2ray; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.InternalUpdater; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.settings.NekoXSettingActivity; import tw.nekomimi.nekogram.parts.DialogTransKt; @@ -1975,7 +1975,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. avatarContainer2.setPivotX(avatarContainer2.getMeasuredWidth() / 2f); AndroidUtilities.updateViewVisibilityAnimated(avatarContainer2, !expanded, 0.95f, true); - if (Math.min(1f, extraHeight / AndroidUtilities.dp(88f)) > 0.85 && !searchMode && NekomuraConfig.showIdAndDc.Bool()) + if (Math.min(1f, extraHeight / AndroidUtilities.dp(88f)) > 0.85 && !searchMode && NekoConfig.showIdAndDc.Bool()) idTextView.setVisibility(expanded ? INVISIBLE : VISIBLE); callItem.setVisibility(expanded || !callItemVisible ? GONE : INVISIBLE); @@ -4849,7 +4849,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. nameTextView[a].setScaleY(nameScale); } - if (diff > 0.85 && !searchMode && NekomuraConfig.showIdAndDc.Bool()) { + if (diff > 0.85 && !searchMode && NekoConfig.showIdAndDc.Bool()) { idTextView.setVisibility(View.VISIBLE); } else { idTextView.setVisibility(View.GONE); @@ -6800,7 +6800,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. avatarContainer.setVisibility(View.VISIBLE); nameTextView[1].setVisibility(View.VISIBLE); onlineTextView[1].setVisibility(View.VISIBLE); - if (Math.min(1f, extraHeight / AndroidUtilities.dp(88f)) > 0.85 && !searchMode && NekomuraConfig.showIdAndDc.Bool()) + if (Math.min(1f, extraHeight / AndroidUtilities.dp(88f)) > 0.85 && !searchMode && NekoConfig.showIdAndDc.Bool()) idTextView.setVisibility(View.VISIBLE); actionBar.onSearchFieldVisibilityChanged(searchTransitionProgress > 0.5f); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java index 5137c691a..45629e0c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java @@ -91,7 +91,7 @@ import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.StrUtil; import kotlin.Unit; import okhttp3.HttpUrl; -import tw.nekomimi.nekogram.BottomBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.proxy.ShadowsocksRSettingsActivity; import tw.nekomimi.nekogram.proxy.ShadowsocksSettingsActivity; import tw.nekomimi.nekogram.proxy.SubSettingsActivity; @@ -105,7 +105,7 @@ import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.ProxyUtil; import tw.nekomimi.nekogram.utils.UIUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class ProxyListActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -685,7 +685,7 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente updateRows(true); } else if (position == enablePublicProxyRow) { - final boolean enabled = NekomuraConfig.enablePublicProxy.toggleConfigBool(); + final boolean enabled = NekoConfig.enablePublicProxy.toggleConfigBool(); TextCheckCell cell = (TextCheckCell) view; cell.setChecked(enabled); UIUtil.runOnIoDispatcher(() -> { @@ -1178,7 +1178,7 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente } else if (position == callsRow) { checkCell.setTextAndCheck(LocaleController.getString("UseProxyForCalls", R.string.UseProxyForCalls), useProxyForCalls, false); } else if (position == enablePublicProxyRow) { - checkCell.setTextAndCheck(LocaleController.getString("enablePublicProxy", R.string.enablePublicProxy), NekomuraConfig.enablePublicProxy.Bool(), false); + checkCell.setTextAndCheck(LocaleController.getString("enablePublicProxy", R.string.enablePublicProxy), NekoConfig.enablePublicProxy.Bool(), false); } break; } @@ -1213,7 +1213,7 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente } else if (position == callsRow) { checkCell.setChecked(useProxyForCalls); } else if (position == enablePublicProxyRow) { - checkCell.setChecked(NekomuraConfig.enablePublicProxy.Bool()); + checkCell.setChecked(NekoConfig.enablePublicProxy.Bool()); } } else { super.onBindViewHolder(holder, position, payloads); @@ -1231,7 +1231,7 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente } else if (position == callsRow) { checkCell.setChecked(useProxyForCalls); } else if (position == enablePublicProxyRow) { - checkCell.setChecked(NekomuraConfig.enablePublicProxy.Bool()); + checkCell.setChecked(NekoConfig.enablePublicProxy.Bool()); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java index b73beba28..babb3451c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java @@ -11,16 +11,12 @@ package org.telegram.ui; import android.Manifest; import android.content.Context; import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; -import android.net.Uri; import android.os.Build; import android.text.SpannableStringBuilder; import android.text.Spanned; -import android.text.style.ImageSpan; import android.util.Base64; import android.util.TypedValue; import android.view.Gravity; @@ -37,9 +33,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.BuildConfig; import org.telegram.messenger.FileLog; -import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.DocumentObject; import org.telegram.messenger.ImageLocation; import org.telegram.messenger.LocaleController; @@ -72,11 +66,8 @@ import org.telegram.ui.Components.ColoredImageSpan; import org.telegram.ui.Components.EmptyTextProgressView; import org.telegram.ui.Components.FlickerLoadingView; import org.telegram.ui.Components.LayoutHelper; -import org.telegram.ui.Components.RLottieImageView; import org.telegram.ui.Components.RecyclerItemsEnterAnimator; import org.telegram.ui.Components.RecyclerListView; -import org.telegram.ui.Components.ReplaceableIconDrawable; -import org.telegram.ui.Components.SlideChooseView; import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.UndoView; @@ -84,9 +75,6 @@ import java.util.ArrayList; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; -import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nekogram.utils.AlertUtil; public class SessionsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java index 5cf3b9709..96425c3da 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java @@ -92,9 +92,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nekogram.PinnedStickerHelper; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.ui.PinnedStickerHelper; import tw.nekomimi.nekogram.utils.AlertUtil; import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.ShareUtil; @@ -162,7 +162,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter if (source.getItemViewType() != target.getItemViewType()) { return false; } - if (NekomuraConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { + if (NekoConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { int from = source.getAdapterPosition(); int to = target.getAdapterPosition(); if (from < stickersStartRow + listAdapter.pinnedStickersCount) { @@ -633,7 +633,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount); final List newList = mediaDataController.getStickerSets(currentType); - if (MediaDataController.TYPE_IMAGE == currentType && NekomuraConfig.enableStickerPin.Bool()) { + if (MediaDataController.TYPE_IMAGE == currentType && NekoConfig.enableStickerPin.Bool()) { PinnedStickerHelper.getInstance(currentAccount).reorderPinnedStickers(newList); } @@ -787,7 +787,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter public ListAdapter(Context context, List stickerSets) { mContext = context; List temp = new ArrayList<>(stickerSets); - if (MediaDataController.TYPE_IMAGE == currentType && NekomuraConfig.enableStickerPin.Bool()) { + if (MediaDataController.TYPE_IMAGE == currentType && NekoConfig.enableStickerPin.Bool()) { if (PinnedStickerHelper.getInstance(currentAccount).reorderPinnedStickers(stickerSets)) { // Sync is needed // AndroidUtilities.runOnUIThread(() -> { @@ -803,7 +803,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter public void setStickerSets(List stickerSets) { this.stickerSets.clear(); -// if (MediaDataController.TYPE_IMAGE == currentType && NekomuraConfig.enableStickerPin.Bool()) { +// if (MediaDataController.TYPE_IMAGE == currentType && NekoConfig.enableStickerPin.Bool()) { // pinnedStickersCount = PinnedStickerHelper.getInstance(currentAccount).reorderPinnedStickers(stickerSets); // } this.stickerSets.addAll(stickerSets); @@ -949,14 +949,14 @@ public class StickersActivity extends BaseFragment implements NotificationCenter private void processSelectionOption(int which, TLRPC.TL_messages_stickerSet stickerSet) { if (which == MENU_ARCHIVE) { MediaDataController.getInstance(currentAccount).toggleStickerSet(getParentActivity(), stickerSet, !stickerSet.set.archived ? 1 : 2, StickersActivity.this, true, true); - if (NekomuraConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { + if (NekoConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { // Sticker will be removed from local list in toggleStickerSet pinnedStickersCount--; setStickerSetCellPinnedMarkVisibility(stickerSet.set.id, false); } } else if (which == MENU_DELETE) { MediaDataController.getInstance(currentAccount).toggleStickerSet(getParentActivity(), stickerSet, 0, StickersActivity.this, true, true); - if (NekomuraConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { + if (NekoConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { pinnedStickersCount--; setStickerSetCellPinnedMarkVisibility(stickerSet.set.id, false); } @@ -983,7 +983,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter if (index >= 0) { listAdapter.toggleSelected(stickersStartRow + index); } - } else if (which == MENU_TOGGLE_PIN && NekomuraConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { + } else if (which == MENU_TOGGLE_PIN && NekoConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { final PinnedStickerHelper ins = PinnedStickerHelper.getInstance(currentAccount); final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount); if (ins.isPinned(stickerSet.set.id)) { @@ -1158,7 +1158,7 @@ public class StickersActivity extends BaseFragment implements NotificationCenter }; icons = new int[]{R.drawable.baseline_archive_24, R.drawable.msg_reorder}; } else { - if (NekomuraConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { + if (NekoConfig.enableStickerPin.Bool() && currentType == MediaDataController.TYPE_IMAGE) { options = new int[]{MENU_ARCHIVE, 3, 4, 2, MENU_DELETE, MENU_TOGGLE_PIN}; items = new CharSequence[]{ LocaleController.getString("StickersHide", R.string.StickersHide), diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java index fa2e4cb32..976d12c20 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java @@ -12,7 +12,6 @@ import android.content.Context; import android.content.DialogInterface; import android.graphics.Typeface; import android.os.Bundle; -import android.os.Vibrator; import android.text.InputType; import android.text.TextUtils; import android.text.method.PasswordTransformationMethod; @@ -64,7 +63,7 @@ import org.telegram.ui.Components.RecyclerListView; import java.util.ArrayList; import java.util.Locale; -import tw.nekomimi.nekogram.EditTextAutoFill; +import tw.nekomimi.nekogram.ui.EditTextAutoFill; import tw.nekomimi.nekogram.utils.VibrateUtil; public class TwoStepVerificationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java index c863db6d3..20b96edbb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java @@ -23,7 +23,6 @@ import android.graphics.Rect; import android.graphics.Typeface; import android.os.Build; import android.os.Bundle; -import android.os.Vibrator; import android.text.Editable; import android.text.InputType; import android.text.TextUtils; @@ -46,8 +45,6 @@ import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; -import com.google.android.exoplayer2.util.Log; - import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; @@ -75,7 +72,7 @@ import org.telegram.ui.Components.RLottieImageView; import java.util.ArrayList; -import tw.nekomimi.nekogram.EditTextAutoFill; +import tw.nekomimi.nekogram.ui.EditTextAutoFill; import tw.nekomimi.nekogram.utils.VibrateUtil; public class TwoStepVerificationSetupActivity extends BaseFragment { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java index cb454e616..ed85f6905 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java @@ -7,7 +7,6 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; -import android.util.Base64; import android.widget.Toast; import androidx.core.content.FileProvider; @@ -26,16 +25,10 @@ import org.telegram.ui.ActionBar.AlertDialog; import java.io.File; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Locale; import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpUtil; import tw.nekomimi.nekogram.utils.FileUtil; -import tw.nekomimi.nkmr.CellGroup; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nkmr.NekomuraUtil; -import tw.nekomimi.nkmr.cells.NekomuraTGSelectBox; //TODO use UpdateAppAlertDialog / BlockingUpdateView? @@ -129,31 +122,7 @@ public class InternalUpdater { final ApkMetadata apk = matchBuild(release.assets); // match apk urls. these can be empty. - String urlChannel = ""; - String sha1 = ""; - try { - final String newBody = HttpUtil.get("https://api.github.com/repos/NekoX-Dev/updates/contents/" + release.name + ".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; - } - break; - } - } - } - } catch (Exception ignored) { - } - - String finalsha1 = sha1; - String finalUrlChannel = urlChannel; ReleaseMetadata finalRelease = release; AndroidUtilities.runOnUIThread(() -> { @@ -173,9 +142,7 @@ public class InternalUpdater { builder.setMessage(message); builder.setPositiveButton(LocaleController.getString("VersionUpdateConfirm", R.string.VersionUpdateConfirm), (dialog, which) -> { - showSelectDownloadSource(ctx, apk != null ? apk.name : finalRelease.name, - apk != null ? apk.browser_download_url : finalRelease.html_url, - finalUrlChannel, finalsha1); + Browser.openUrl(ctx, apk.browser_download_url); }); builder.setNeutralButton(LocaleController.getString("VersionUpdateIgnore", R.string.VersionUpdateIgnore), (dialog, which) -> NekoXConfig.setIgnoredUpdateTag(finalRelease.name)); builder.setNegativeButton(LocaleController.getString("VersionUpdateNotNow", R.string.VersionUpdateNotNow), (dialog, which) -> NekoXConfig.setNextUpdateCheck(System.currentTimeMillis() / 1000 + 3 * 24 * 3600)); @@ -188,33 +155,6 @@ public class InternalUpdater { } } - public static void showSelectDownloadSource(Context ctx, String title, String browser_download_url, String urlChannel, String sha1) { - CellGroup nkmrCells = new CellGroup(null); - - nkmrCells.callBackSettingsChanged = ((k, v) -> { - int source = NekomuraConfig.update_download_soucre.Int(); - switch (source) { - case 0: - Browser.openUrl(ctx, browser_download_url); - break; - case 1: - Browser.openUrl(ctx, urlChannel); - break; - } - }); - - ArrayList sources = new ArrayList<>(); - sources.add("Github Release"); // base of Current - if (!urlChannel.isEmpty()) sources.add("Telegram Channel"); - - String[] sources_ = new String[sources.size()]; - sources.toArray(sources_); - - NekomuraTGSelectBox sb = new NekomuraTGSelectBox(null, NekomuraConfig.update_download_soucre, sources_, null); - nkmrCells.appendCell(sb); // new - sb.onClickWithDialog(ctx); - } - public static boolean openApkInstall(Activity activity, File f) { if (!checkApkInstallPermissions(activity)) { return false; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index cc9266e81..b33b63f28 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -1,151 +1,460 @@ package tw.nekomimi.nekogram; -import android.Manifest; +import android.annotation.SuppressLint; import android.app.Activity; -import android.content.Intent; +import android.content.Context; import android.content.SharedPreferences; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.res.Configuration; -import android.graphics.Typeface; -import android.os.Build; -import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildVars; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.NotificationsService; -import org.telegram.messenger.R; -import org.telegram.ui.ActionBar.Theme; -import java.io.BufferedReader; -import java.io.FileReader; -import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.io.ByteArrayInputStream; +import java.io.ObjectInputStream; +import java.util.ArrayList; +import android.util.Base64; -import cn.hutool.core.util.StrUtil; -import tw.nekomimi.nkmr.NekomuraConfig; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; +import tw.nekomimi.nekogram.config.ConfigItem; + +import static tw.nekomimi.nekogram.config.ConfigItem.*; + +@SuppressLint("ApplySharedPref") public class NekoConfig { - public static final int TITLE_TYPE_TEXT = 0; - public static final int TITLE_TYPE_ICON = 1; - public static final int TITLE_TYPE_MIX = 2; + public static final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nkmrcfg", Context.MODE_PRIVATE); + public static final Object sync = new Object(); - public static boolean forceSystemPicker = false; // SDK23+ and no storage permission + private static boolean configLoaded = false; + private static final ArrayList configs = new ArrayList<>(); - public static String getOpenPGPAppName() { + // Configs + public static ConfigItem migrate = addConfig("NekoConfigMigrate", configTypeBool, false); + public static ConfigItem largeAvatarInDrawer = addConfig("AvatarAsBackground", configTypeInt, 0); // 0:TG Default 1:NekoX Default 2:Large Avatar + public static ConfigItem unreadBadgeOnBackButton = addConfig("unreadBadgeOnBackButton", configTypeBool, false); + public static ConfigItem customPublicProxyIP = addConfig("customPublicProxyIP", configTypeString, ""); + public static ConfigItem update_download_soucre = addConfig("update_download_soucre", configTypeInt, 0); // 0: Github 1: Channel 2:CDNDrive, removed + public static ConfigItem useCustomEmoji = addConfig("useCustomEmoji", configTypeBool, false); + public static ConfigItem repeatConfirm = addConfig("repeatConfirm", configTypeBool, false); + public static ConfigItem disableInstantCamera = addConfig("DisableInstantCamera", configTypeBool, false); + public static ConfigItem showSeconds = addConfig("showSeconds", configTypeBool, false); - if (StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) { + public static ConfigItem enablePublicProxy = addConfig("enablePublicProxy", configTypeBool, true); + public static ConfigItem autoUpdateSubInfo = addConfig("autoUpdateSubInfo", configTypeBool, true); - try { - PackageManager manager = ApplicationLoader.applicationContext.getPackageManager(); - ApplicationInfo info = manager.getApplicationInfo(NekomuraConfig.openPGPApp.String(), PackageManager.GET_META_DATA); - return (String) manager.getApplicationLabel(info); - } catch (PackageManager.NameNotFoundException e) { - NekomuraConfig.openPGPApp.setConfigString(""); - } + // From NekoConfig + public static ConfigItem useIPv6 = addConfig("IPv6", configTypeBool, false); + public static ConfigItem hidePhone = addConfig("HidePhone", configTypeBool, true); + public static ConfigItem ignoreBlocked = addConfig("IgnoreBlocked", configTypeBool, false); + public static ConfigItem tabletMode = addConfig("TabletMode", configTypeInt, 0); + public static ConfigItem inappCamera = addConfig("DebugMenuEnableCamera", configTypeBool, true); // fake + public static ConfigItem smoothKeyboard = addConfig("DebugMenuEnableSmoothKeyboard", configTypeBool, false);// fake - } + public static ConfigItem typeface = addConfig("TypefaceUseDefault", configTypeBool, false); + public static ConfigItem nameOrder = addConfig("NameOrder", configTypeInt, 1); + public static ConfigItem mapPreviewProvider = addConfig("MapPreviewProvider", configTypeInt, 0); + public static ConfigItem transparentStatusBar = addConfig("TransparentStatusBar", configTypeBool, false); + public static ConfigItem hideProxySponsorChannel = addConfig("HideProxySponsorChannel", configTypeBool, false); + public static ConfigItem showAddToSavedMessages = addConfig("showAddToSavedMessages", configTypeBool, true); + public static ConfigItem showReport = addConfig("showReport", configTypeBool, true); + public static ConfigItem showViewHistory = addConfig("showViewHistory", configTypeBool, true); + public static ConfigItem showAdminActions = addConfig("showAdminActions", configTypeBool, true); + public static ConfigItem showChangePermissions = addConfig("showChangePermissions", configTypeBool, true); + public static ConfigItem showDeleteDownloadedFile = addConfig("showDeleteDownloadedFile", configTypeBool, true); + public static ConfigItem showMessageDetails = addConfig("showMessageDetails", configTypeBool, false); + public static ConfigItem showTranslate = addConfig("showTranslate", configTypeBool, true); + public static ConfigItem showRepeat = addConfig("showRepeat", configTypeBool, false); + public static ConfigItem showShareMessages = addConfig("showShareMessages", configTypeBool, false); + public static ConfigItem showMessageHide = addConfig("showMessageHide", configTypeBool, false); - return LocaleController.getString("None", R.string.None); + public static ConfigItem eventType = addConfig("eventType", configTypeInt, 0); + public static ConfigItem actionBarDecoration = addConfig("ActionBarDecoration", configTypeInt, 0); + public static ConfigItem newYear = addConfig("ChristmasHat", configTypeBool, false); + public static ConfigItem stickerSize = addConfig("stickerSize", configTypeFloat, 14.0f); + public static ConfigItem unlimitedFavedStickers = addConfig("UnlimitedFavoredStickers", configTypeBool, false); + public static ConfigItem unlimitedPinnedDialogs = addConfig("UnlimitedPinnedDialogs", configTypeBool, false); + public static ConfigItem translationProvider = addConfig("translationProvider", configTypeInt, 1); + public static ConfigItem disablePhotoSideAction = addConfig("DisablePhotoViewerSideAction", configTypeBool, true); + public static ConfigItem openArchiveOnPull = addConfig("OpenArchiveOnPull", configTypeBool, false); + public static ConfigItem hideKeyboardOnChatScroll = addConfig("HideKeyboardOnChatScroll", configTypeBool, false); + public static ConfigItem avatarBackgroundBlur = addConfig("BlurAvatarBackground", configTypeBool, false); + public static ConfigItem avatarBackgroundDarken = addConfig("DarkenAvatarBackground", configTypeBool, false); + public static ConfigItem useSystemEmoji = addConfig("EmojiUseDefault", configTypeBool, false); + public static ConfigItem showTabsOnForward = addConfig("ShowTabsOnForward", configTypeBool, false); + public static ConfigItem rearVideoMessages = addConfig("RearVideoMessages", configTypeBool, false); + public static ConfigItem hideAllTab = addConfig("HideAllTab", configTypeBool, false); + public static ConfigItem pressTitleToOpenAllChats = addConfig("pressTitleToOpenAllChats", configTypeBool, false); - } + public static ConfigItem disableChatAction = addConfig("DisableChatAction", configTypeBool, false); + public static ConfigItem sortByUnread = addConfig("sort_by_unread", configTypeBool, false); + public static ConfigItem sortByUnmuted = addConfig("sort_by_unmuted", configTypeBool, true); + public static ConfigItem sortByUser = addConfig("sort_by_user", configTypeBool, true); + public static ConfigItem sortByContacts = addConfig("sort_by_contacts", configTypeBool, true); - public static String formatLang(String name) { + public static ConfigItem disableUndo = addConfig("DisableUndo", configTypeBool, false); - if (name == null || name.isEmpty()) { + public static ConfigItem filterUsers = addConfig("filter_users", configTypeBool, true); + public static ConfigItem filterContacts = addConfig("filter_contacts", configTypeBool, true); + public static ConfigItem filterGroups = addConfig("filter_groups", configTypeBool, true); + public static ConfigItem filterChannels = addConfig("filter_channels", configTypeBool, true); + public static ConfigItem filterBots = addConfig("filter_bots", configTypeBool, true); + public static ConfigItem filterAdmins = addConfig("filter_admins", configTypeBool, true); + public static ConfigItem filterUnmuted = addConfig("filter_unmuted", configTypeBool, true); + public static ConfigItem filterUnread = addConfig("filter_unread", configTypeBool, true); + public static ConfigItem filterUnmutedAndUnread = addConfig("filter_unmuted_and_unread", configTypeBool, true); - return LocaleController.getString("Default", R.string.Default); + public static ConfigItem disableSystemAccount = addConfig("DisableSystemAccount", configTypeBool, false); +// public static ConfigItem disableProxyWhenVpnEnabled = addConfig("DisableProxyWhenVpnEnabled", configTypeBool, false); + public static ConfigItem skipOpenLinkConfirm = addConfig("SkipOpenLinkConfirm", configTypeBool, false); - } else { + public static ConfigItem ignoreMutedCount = addConfig("IgnoreMutedCount", configTypeBool, true); + public static ConfigItem useDefaultTheme = addConfig("UseDefaultTheme", configTypeBool, false); + public static ConfigItem showIdAndDc = addConfig("ShowIdAndDc", configTypeBool, false); - if (name.contains("-")) { + public static ConfigItem googleCloudTranslateKey = addConfig("GoogleCloudTransKey", configTypeString, ""); + public static ConfigItem cachePath = addConfig("cache_path", configTypeString, ""); - return new Locale(StrUtil.subBefore(name, "-", false), StrUtil.subAfter(name, "-", false)).getDisplayName(LocaleController.getInstance().currentLocale); + public static ConfigItem translateToLang = addConfig("TransToLang", configTypeString, ""); // "" -> translate to current language (MessageTrans.kt & Translator.kt) + public static ConfigItem translateInputLang = addConfig("TransInputToLang", configTypeString, "en"); - } else { + public static ConfigItem ccToLang = addConfig("opencc_to_lang", configTypeString, ""); + public static ConfigItem ccInputLang = addConfig("opencc_input_to_lang", configTypeString, ""); - return new Locale(name).getDisplayName(LocaleController.getInstance().currentLocale); + public static ConfigItem tabsTitleType = addConfig("TabTitleType", configTypeInt, NekoXConfig.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); - } + public static ConfigItem useSystemDNS = addConfig("useSystemDNS", configTypeBool, false); + public static ConfigItem customDoH = addConfig("customDoH", configTypeString, ""); + public static ConfigItem hideProxyByDefault = addConfig("HideProxyByDefault", configTypeBool, false); + public static ConfigItem useProxyItem = addConfig("UseProxyItem", configTypeBool, true); - } + public static ConfigItem disableAppBarShadow = addConfig("DisableAppBarShadow", configTypeBool, false); + public static ConfigItem mediaPreview = addConfig("MediaPreview", configTypeBool, true); - } + public static ConfigItem proxyAutoSwitch = addConfig("ProxyAutoSwitch", configTypeBool, false); + + public static ConfigItem usePersianCalendar = addConfig("UsePersiancalendar", configTypeBool, false); + public static ConfigItem displayPersianCalendarByLatin = addConfig("DisplayPersianCalendarByLatin", configTypeBool, false); + public static ConfigItem openPGPApp = addConfig("OpenPGPApp", configTypeString, ""); + public static ConfigItem openPGPKeyId = addConfig("OpenPGPKey", configTypeLong, 0L); + + public static ConfigItem disableVibration = addConfig("DisableVibration", configTypeBool, false); + public static ConfigItem autoPauseVideo = addConfig("AutoPauseVideo", configTypeBool, false); + public static ConfigItem disableProximityEvents = addConfig("DisableProximityEvents", configTypeBool, false); + + public static ConfigItem ignoreContentRestrictions = addConfig("ignoreContentRestrictions", configTypeBool, !BuildVars.isPlay); + public static ConfigItem useChatAttachMediaMenu = addConfig("UseChatAttachEnterMenu", configTypeBool, true); + public static ConfigItem disableLinkPreviewByDefault = addConfig("DisableLinkPreviewByDefault", configTypeBool, false); + public static ConfigItem sendCommentAfterForward = addConfig("SendCommentAfterForward", configTypeBool, true); + public static ConfigItem increaseVoiceMessageQuality = addConfig("IncreaseVoiceMessageQuality", configTypeBool, true); + public static ConfigItem disableTrending = addConfig("DisableTrending", configTypeBool, true); + public static ConfigItem dontSendGreetingSticker = addConfig("DontSendGreetingSticker", configTypeBool, false); + public static ConfigItem hideTimeForSticker = addConfig("HideTimeForSticker", configTypeBool, false); + public static ConfigItem takeGIFasVideo = addConfig("TakeGIFasVideo", configTypeBool, false); + public static ConfigItem maxRecentStickerCount = addConfig("maxRecentStickerCount", configTypeInt, 20); + public static ConfigItem disableSwipeToNext = addConfig("disableSwipeToNextChannel", configTypeBool, true); + public static ConfigItem disableRemoteEmojiInteractions = addConfig("disableRemoteEmojiInteractions", configTypeBool, true); + public static ConfigItem disableChoosingSticker = addConfig("disableChoosingSticker", configTypeBool, false); + public static ConfigItem hideGroupSticker = addConfig("hideGroupSticker", configTypeBool, false); + public static ConfigItem hideSponsoredMessage = addConfig("hideSponsoredMessage", configTypeBool, false); + public static ConfigItem rememberAllBackMessages = addConfig("rememberAllBackMessages", configTypeBool, false); + public static ConfigItem hideSendAsChannel = addConfig("hideSendAsChannel", configTypeBool, false); + + public static ConfigItem disableAutoDownloadingWin32Executable = addConfig("Win32ExecutableFiles", configTypeBool, true); + public static ConfigItem disableAutoDownloadingArchive = addConfig("ArchiveFiles", configTypeBool, true); + + public static ConfigItem enableStickerPin = addConfig("EnableStickerPin", configTypeBool, false); + public static ConfigItem useMediaStreamInVoip = addConfig("UseMediaStreamInVoip", configTypeBool, false); + public static ConfigItem customAudioBitrate = addConfig("customAudioBitrate", configTypeInt, 32); + public static ConfigItem disableGroupVoipAudioProcessing = addConfig("disableGroupVoipAudioProcessing", configTypeBool, false); static { - checkForceSystemPicker(); + loadConfig(false); + checkMigrate(false); } - public static void checkForceSystemPicker() { - // TODO show alert? - // TODO not working: send photo (upstream bug) - if (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - forceSystemPicker = true; - BuildVars.NO_SCOPED_STORAGE = false; - } + public static ConfigItem addConfig(String k, int t, Object d) { + ConfigItem a = new ConfigItem(k, t, d); + configs.add(a); + return a; } + public static void loadConfig(boolean force) { + synchronized (sync) { + if (configLoaded && !force) { + return; + } + for (int i = 0; i < configs.size(); i++) { + ConfigItem o = configs.get(i); - private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf"; - - public static boolean loadSystemEmojiFailed = false; - private static Typeface systemEmojiTypeface; - - public static Typeface getSystemEmojiTypeface() { - if (!loadSystemEmojiFailed && systemEmojiTypeface == null) { - try { - Pattern p = Pattern.compile(">(.*emoji.*)", Pattern.CASE_INSENSITIVE); - BufferedReader br = new BufferedReader(new FileReader("/system/etc/fonts.xml")); - String line; - while ((line = br.readLine()) != null) { - Matcher m = p.matcher(line); - if (m.find()) { - systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + m.group(1)); - FileLog.d("emoji font file fonts.xml = " + m.group(1)); - break; + if (o.type == configTypeBool) { + o.value = preferences.getBoolean(o.key, (boolean) o.defaultValue); + } + if (o.type == configTypeInt) { + o.value = preferences.getInt(o.key, (int) o.defaultValue); + } + if (o.type == configTypeLong) { + o.value = preferences.getLong(o.key, (Long) o.defaultValue); + } + if (o.type == configTypeFloat) { + o.value = preferences.getFloat(o.key, (Float) o.defaultValue); + } + if (o.type == configTypeString) { + o.value = preferences.getString(o.key, (String) o.defaultValue); + } + if (o.type == configTypeSetInt) { + Set ss = preferences.getStringSet(o.key, new HashSet<>()); + HashSet si = new HashSet<>(); + for (String s : ss) { + si.add(Integer.parseInt(s)); + } + o.value = si; + } + if (o.type == configTypeMapIntInt) { + String cv = preferences.getString(o.key, ""); + // Log.e("NC", String.format("Getting pref %s val %s", o.key, cv)); + if (cv.length() == 0) { + o.value = new HashMap(); + } else { + try { + byte[] data = Base64.decode(cv, Base64.DEFAULT); + ObjectInputStream ois = new ObjectInputStream( + new ByteArrayInputStream(data)); + o.value = (HashMap) ois.readObject(); + if (o.value == null) { + o.value = new HashMap(); + } + ois.close(); + } catch (Exception e) { + o.value = new HashMap(); + } } } - br.close(); - } catch (Exception e) { - FileLog.e(e); - } - if (systemEmojiTypeface == null) { - try { - systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + EMOJI_FONT_AOSP); - FileLog.d("emoji font file = " + EMOJI_FONT_AOSP); - } catch (Exception e) { - FileLog.e(e); - loadSystemEmojiFailed = true; - } } + configLoaded = true; } - return systemEmojiTypeface; } - public static int getNotificationColor() { - int color = 0; - Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration(); - boolean isDark = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; - if (isDark) { - color = 0xffffffff; - } else { - if (Theme.getActiveTheme().hasAccentColors()) { - color = Theme.getActiveTheme().getAccentColor(Theme.getActiveTheme().currentAccentId); - } - if (Theme.getActiveTheme().isDark() || color == 0) { - color = Theme.getColor(Theme.key_actionBarDefault); - } - // too bright - if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) { - color = Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader) | 0xff000000; - } - } - return color; - } + public static void checkMigrate(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("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("showShareMessages")) + showShareMessages.setConfigBool(preferences.getBoolean("showShareMessages", 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("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", NekoXConfig.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("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)); + } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java index 3d9086ff0..a53fe7292 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoXConfig.java @@ -1,12 +1,32 @@ package tw.nekomimi.nekogram; +import android.Manifest; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Typeface; +import android.os.Build; +import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildConfig; import org.telegram.messenger.BuildVars; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; +import org.telegram.ui.ActionBar.Theme; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; import tw.nekomimi.nekogram.database.NitritesKt; public class NekoXConfig { @@ -25,6 +45,30 @@ public class NekoXConfig { 380570774, // Haruhi }; + public static final int TITLE_TYPE_TEXT = 0; + public static final int TITLE_TYPE_ICON = 1; + public static final int TITLE_TYPE_MIX = 2; + + public static boolean forceSystemPicker = false; // SDK23+ and no storage permission + + private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf"; + + public static boolean loadSystemEmojiFailed = false; + private static Typeface systemEmojiTypeface; + + static { + checkForceSystemPicker(); + } + + public static void checkForceSystemPicker() { + // TODO show alert? + // TODO not working: send photo (upstream bug) + if (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + forceSystemPicker = true; + BuildVars.NO_SCOPED_STORAGE = false; + } + } + public static SharedPreferences preferences = NitritesKt.openMainSharedPreference("nekox_config"); public static boolean developerMode = preferences.getBoolean("developer_mode", false); @@ -39,6 +83,9 @@ public class NekoXConfig { public static String ignoredUpdateTag = preferences.getString("ignoredUpdateTag", ""); public static long nextUpdateCheck = preferences.getLong("nextUpdateCheckTimestamp", 0); + public static int customApi = preferences.getInt("custom_api", 0); + public static int customAppId = preferences.getInt("custom_app_id", 0); + public static String customAppHash = preferences.getString("custom_app_hash", ""); public static void toggleDeveloperMode() { preferences.edit().putBoolean("developer_mode", developerMode = !developerMode).apply(); @@ -59,10 +106,6 @@ public class NekoXConfig { preferences.edit().putBoolean("disable_screenshot_detection", disableScreenshotDetection = !disableScreenshotDetection).apply(); } - public static int customApi = preferences.getInt("custom_api", 0); - public static int customAppId = preferences.getInt("custom_app_id", 0); - public static String customAppHash = preferences.getString("custom_app_hash", ""); - public static int currentAppId() { switch (customApi) { case 0: @@ -123,4 +166,81 @@ public class NekoXConfig { long myId = UserConfig.getInstance(UserConfig.selectedAccount).clientUserId; return NekoXConfig.developerMode || NekoXConfig.customApi > 0 || ArrayUtil.contains(NekoXConfig.developers, myId); } + + public static String getOpenPGPAppName() { + if (StrUtil.isNotBlank(NekoConfig.openPGPApp.String())) { + try { + PackageManager manager = ApplicationLoader.applicationContext.getPackageManager(); + ApplicationInfo info = manager.getApplicationInfo(NekoConfig.openPGPApp.String(), PackageManager.GET_META_DATA); + return (String) manager.getApplicationLabel(info); + } catch (PackageManager.NameNotFoundException e) { + NekoConfig.openPGPApp.setConfigString(""); + } + } + return LocaleController.getString("None", R.string.None); + } + + public static String formatLang(String name) { + if (name == null || name.isEmpty()) { + return LocaleController.getString("Default", R.string.Default); + } else { + if (name.contains("-")) { + return new Locale(StrUtil.subBefore(name, "-", false), StrUtil.subAfter(name, "-", false)).getDisplayName(LocaleController.getInstance().currentLocale); + } else { + return new Locale(name).getDisplayName(LocaleController.getInstance().currentLocale); + } + } + } + + public static Typeface getSystemEmojiTypeface() { + if (!loadSystemEmojiFailed && systemEmojiTypeface == null) { + try { + Pattern p = Pattern.compile(">(.*emoji.*)", Pattern.CASE_INSENSITIVE); + BufferedReader br = new BufferedReader(new FileReader("/system/etc/fonts.xml")); + String line; + while ((line = br.readLine()) != null) { + Matcher m = p.matcher(line); + if (m.find()) { + systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + m.group(1)); + FileLog.d("emoji font file fonts.xml = " + m.group(1)); + break; + } + } + br.close(); + } catch (Exception e) { + FileLog.e(e); + } + if (systemEmojiTypeface == null) { + try { + systemEmojiTypeface = Typeface.createFromFile("/system/fonts/" + EMOJI_FONT_AOSP); + FileLog.d("emoji font file = " + EMOJI_FONT_AOSP); + } catch (Exception e) { + FileLog.e(e); + loadSystemEmojiFailed = true; + } + } + } + return systemEmojiTypeface; + } + + public static int getNotificationColor() { + int color = 0; + Configuration configuration = ApplicationLoader.applicationContext.getResources().getConfiguration(); + boolean isDark = (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES; + if (isDark) { + color = 0xffffffff; + } else { + if (Theme.getActiveTheme().hasAccentColors()) { + color = Theme.getActiveTheme().getAccentColor(Theme.getActiveTheme().currentAccentId); + } + if (Theme.getActiveTheme().isDark() || color == 0) { + color = Theme.getColor(Theme.key_actionBarDefault); + } + // too bright + if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) { + color = Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader) | 0xff000000; + } + } + return color; + } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/SaveToDownloadReceiver.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/SaveToDownloadReceiver.java index 4e9c37467..b677896e5 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/SaveToDownloadReceiver.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/SaveToDownloadReceiver.java @@ -64,7 +64,7 @@ public class SaveToDownloadReceiver extends BroadcastReceiver { .setCategory(NotificationCompat.CATEGORY_STATUS) .setProgress(100, 0, true) .setSmallIcon(android.R.drawable.stat_sys_download) - .setColor(NekoConfig.getNotificationColor()) + .setColor(NekoXConfig.getNotificationColor()) .setOngoing(true) .addAction(R.drawable.ic_close_white, LocaleController.getString("Cancel", R.string.Cancel), pendingIntent); callbacks.put(notificationId, callback); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/CellGroup.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/CellGroup.java similarity index 82% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/CellGroup.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/CellGroup.java index 048b4e4a6..5bfa1c07a 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/CellGroup.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/CellGroup.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nkmr; +package tw.nekomimi.nekogram.config; import android.view.View; import android.view.ViewGroup; @@ -10,8 +10,8 @@ import org.telegram.ui.Components.RecyclerListView; import java.util.ArrayList; -import tw.nekomimi.nkmr.cells.AbstractCell; -import tw.nekomimi.nkmr.cells.NekomuraTGDivider; +import tw.nekomimi.nekogram.config.cell.AbstractConfigCell; +import tw.nekomimi.nekogram.config.cell.ConfigCellDivider; public class CellGroup { public static final int ITEM_TYPE_DIVIDER = 1; @@ -24,7 +24,7 @@ public class CellGroup { public BaseFragment thisFragment; public RecyclerListView listView; public RecyclerListView.SelectionAdapter listAdapter; - public ArrayList rows; + public ArrayList rows; public CallBackSettingsChanged callBackSettingsChanged; @@ -38,13 +38,13 @@ public class CellGroup { this.listAdapter = la; } - public AbstractCell appendCell(AbstractCell cell) { + public AbstractConfigCell appendCell(AbstractConfigCell cell) { cell.bindCellGroup(this); this.rows.add(cell); return cell; } - public AbstractCell appendCell(AbstractCell cell, boolean display) { + public AbstractConfigCell appendCell(AbstractConfigCell cell, boolean display) { cell.bindCellGroup(this); if (display) // For censored features, don't show it forever. this.rows.add(cell); @@ -83,8 +83,8 @@ public class CellGroup { cell.setLayoutParams(params); } - public boolean needSetDivider(AbstractCell cell) { - return !(rows.get(rows.indexOf(cell) + 1) instanceof NekomuraTGDivider); + public boolean needSetDivider(AbstractConfigCell cell) { + return !(rows.get(rows.indexOf(cell) + 1) instanceof ConfigCellDivider); } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/ConfigItem.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/ConfigItem.java new file mode 100644 index 000000000..97b69a225 --- /dev/null +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/ConfigItem.java @@ -0,0 +1,170 @@ +package tw.nekomimi.nekogram.config; + +import android.content.SharedPreferences; +import android.util.Base64; + +import org.telegram.messenger.FileLog; + +import java.io.ByteArrayOutputStream; +import java.io.ObjectOutputStream; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +import tw.nekomimi.nekogram.NekoConfig; + +public class ConfigItem { + public static final int configTypeBool = 0; + public static final int configTypeInt = 1; + public static final int configTypeString = 2; + public static final int configTypeSetInt = 3; + public static final int configTypeMapIntInt = 4; + public static final int configTypeLong = 5; + public static final int configTypeFloat = 6; + + public final String key; + public final int type; + public final Object defaultValue; + + public Object value; + + public ConfigItem(String key, int type, Object defaultValue) { + this.key = key; + this.type = type; + this.defaultValue = defaultValue; + } + + 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 SetInt() { + return (HashSet) value; + } + + public HashMap MapIntInt() { + return (HashMap) value; + } + + public boolean SetIntContains(Integer v) { + return ((HashSet) value).contains(v); + } + + + public void changed(Object o) { + value = o; + } + + //写配置 + //这里没有检查类型哦 + + public boolean toggleConfigBool() { + value = !this.Bool(); + saveConfig(); + return this.Bool();//返回toggle之后的 + } + + public void setConfigBool(boolean v) { + value = v; + saveConfig(); + } + + public void setConfigInt(int v) { + value = v; + saveConfig(); + } + + public void setConfigLong(Long v) { + value = v; + saveConfig(); + } + + public void setConfigFloat(Float v) { + value = v; + saveConfig(); + } + + public void setConfigString(String v) { + if (v == null) { + value = ""; + } else { + value = v; + } + saveConfig(); + } + + public void setConfigSetInt(HashSet v) { + value = v; + saveConfig(); + } + + public void setConfigMapInt(HashMap v) { + value = v; + saveConfig(); + } + + // save one item + public void saveConfig() { + synchronized (NekoConfig.sync) { + try { + SharedPreferences.Editor editor = NekoConfig.preferences.edit(); + + if (this.type == configTypeBool) { + editor.putBoolean(this.key, (boolean) this.value); + } + if (this.type == configTypeInt) { + editor.putInt(this.key, (int) this.value); + } + if (this.type == configTypeLong) { + editor.putLong(this.key, (Long) this.value); + } + if (this.type == configTypeFloat) { + editor.putFloat(this.key, (Float) this.value); + } + if (this.type == configTypeString) { + editor.putString(this.key, this.value.toString()); + } + if (this.type == configTypeSetInt) { + HashSet ss = new HashSet<>(); + for (Integer n : (Set) this.value) { + ss.add(Integer.toString(n)); + } + editor.putStringSet(this.key, ss); + } + if (this.type == configTypeMapIntInt) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(this.value); + oos.close(); + editor.putString(this.key, Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT)); + } + + editor.apply(); + } catch (Exception e) { + FileLog.e(e); + } + } + } +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/AbstractCell.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/AbstractConfigCell.java similarity index 74% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/AbstractCell.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/AbstractConfigCell.java index dc24de636..5c9167ce9 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/AbstractCell.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/AbstractConfigCell.java @@ -1,10 +1,10 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import androidx.recyclerview.widget.RecyclerView; -import tw.nekomimi.nkmr.CellGroup; +import tw.nekomimi.nekogram.config.CellGroup; -public abstract class AbstractCell { +public abstract class AbstractConfigCell { // can not be null! protected CellGroup cellGroup; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGCustom.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellCustom.java similarity index 71% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGCustom.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellCustom.java index d537102a8..07cf5592b 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGCustom.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellCustom.java @@ -1,12 +1,12 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import androidx.recyclerview.widget.RecyclerView; -public class NekomuraTGCustom extends AbstractCell { +public class ConfigCellCustom extends AbstractConfigCell { public final int type; public final boolean enabled; - public NekomuraTGCustom(int type, boolean enabled) { + public ConfigCellCustom(int type, boolean enabled) { this.type = type; this.enabled = enabled; } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGDivider.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellDivider.java similarity index 64% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGDivider.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellDivider.java index a842b866d..c2666c458 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGDivider.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellDivider.java @@ -1,10 +1,10 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import androidx.recyclerview.widget.RecyclerView; -import tw.nekomimi.nkmr.CellGroup; +import tw.nekomimi.nekogram.config.CellGroup; -public class NekomuraTGDivider extends AbstractCell { +public class ConfigCellDivider extends AbstractConfigCell { public int getType() { return CellGroup.ITEM_TYPE_DIVIDER; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGHeader.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellHeader.java similarity index 71% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGHeader.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellHeader.java index 33b181cf3..139f51951 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGHeader.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellHeader.java @@ -1,15 +1,15 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import androidx.recyclerview.widget.RecyclerView; import org.telegram.ui.Cells.HeaderCell; -import tw.nekomimi.nkmr.CellGroup; +import tw.nekomimi.nekogram.config.CellGroup; -public class NekomuraTGHeader extends AbstractCell { +public class ConfigCellHeader extends AbstractConfigCell { private final String title; - public NekomuraTGHeader(String title) { + public ConfigCellHeader(String title) { this.title = title; } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGSelectBox.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellSelectBox.java similarity index 94% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGSelectBox.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellSelectBox.java index fce6258d9..38c23771f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGSelectBox.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellSelectBox.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import android.content.Context; import android.view.View; @@ -15,14 +15,13 @@ import org.telegram.ui.Cells.RadioColorCell; import org.telegram.ui.Cells.TextSettingsCell; import kotlin.Unit; -import tw.nekomimi.nekogram.PopupBuilder; -import tw.nekomimi.nkmr.CellGroup; -import tw.nekomimi.nkmr.ConfigItem; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.ui.PopupBuilder; +import tw.nekomimi.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.ConfigItem; // TextSettingsCell, select from a list // Can be used without select list(custom) -public class NekomuraTGSelectBox extends AbstractCell { +public class ConfigCellSelectBox extends AbstractConfigCell { private final ConfigItem bindConfig; private final String[] selectList; // split by \n private final String title; @@ -30,7 +29,7 @@ public class NekomuraTGSelectBox extends AbstractCell { private Context ctxCustom; // default: customTitle=null customOnClick=null - public NekomuraTGSelectBox(String customTitle, ConfigItem bind, Object selectList_s, Runnable customOnClick) { + public ConfigCellSelectBox(String customTitle, ConfigItem bind, Object selectList_s, Runnable customOnClick) { this.bindConfig = bind; if (selectList_s == null) { this.selectList = null; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextCheck.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextCheck.java similarity index 81% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextCheck.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextCheck.java index 72e9cc7ed..e7bfab966 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextCheck.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextCheck.java @@ -1,33 +1,33 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; 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.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.ConfigItem; -public class NekomuraTGTextCheck extends AbstractCell { +public class ConfigCellTextCheck extends AbstractConfigCell { 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) { + public ConfigCellTextCheck(ConfigItem bind) { this.bindConfig = bind; this.title = LocaleController.getString(bindConfig.getKey()); this.subtitle = null; } - public NekomuraTGTextCheck(ConfigItem bind, String subtitle) { + public ConfigCellTextCheck(ConfigItem bind, String subtitle) { this.bindConfig = bind; this.title = LocaleController.getString(bindConfig.getKey()); this.subtitle = subtitle; } - public NekomuraTGTextCheck(ConfigItem bind, String subtitle, String customTitle) { + public ConfigCellTextCheck(ConfigItem bind, String subtitle, String customTitle) { this.bindConfig = bind; this.title = customTitle; this.subtitle = subtitle; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextDetail.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextDetail.java similarity index 81% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextDetail.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextDetail.java index 61f3d841e..4b196ff92 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextDetail.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextDetail.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import androidx.recyclerview.widget.RecyclerView; @@ -7,16 +7,16 @@ 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.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.ConfigItem; -public class NekomuraTGTextDetail extends AbstractCell { +public class ConfigCellTextDetail extends AbstractConfigCell { 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) { + public ConfigCellTextDetail(ConfigItem bind, RecyclerListView.OnItemClickListener onItemClickListener, String hint) { this.bindConfig = bind; this.title = LocaleController.getString(bindConfig.getKey()); this.hint = hint == null ? "" : hint; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextInput.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java similarity index 92% rename from TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextInput.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java index 32b6528f7..042203cbd 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/cells/NekomuraTGTextInput.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/config/cell/ConfigCellTextInput.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nkmr.cells; +package tw.nekomimi.nekogram.config.cell; import android.content.Context; import android.widget.LinearLayout; @@ -14,17 +14,17 @@ 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.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.ConfigItem; -public class NekomuraTGTextInput extends AbstractCell { +public class ConfigCellTextInput extends AbstractConfigCell { 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) { + public ConfigCellTextInput(String customTitle, ConfigItem bind, String hint, Runnable customOnClick) { this.bindConfig = bind; if (hint == null) { this.hint = ""; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/MessageTrans.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/MessageTrans.kt index 96274c9f2..866ad4ffa 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/MessageTrans.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/MessageTrans.kt @@ -1,11 +1,10 @@ package tw.nekomimi.nekogram.parts import kotlinx.coroutines.* -import org.telegram.messenger.LocaleController import org.telegram.messenger.MessageObject import org.telegram.tgnet.TLRPC import org.telegram.ui.ChatActivity -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import tw.nekomimi.nekogram.transtale.TranslateDb import tw.nekomimi.nekogram.transtale.Translator import tw.nekomimi.nekogram.transtale.code2Locale @@ -86,7 +85,7 @@ fun ChatActivity.translateMessages2(target: Locale) = translateMessages(target) @JvmName("translateMessages") fun ChatActivity.translateMessages3(messages: List) = translateMessages(messages = messages) -fun ChatActivity.translateMessages(target: Locale = NekomuraConfig.translateToLang.String().code2Locale +fun ChatActivity.translateMessages(target: Locale = NekoConfig.translateToLang.String().code2Locale , messages: List = messageForTranslate?.let { listOf(it) } ?: selectedObjectGroup?.messages ?: emptyList()) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxyLoads.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxyLoads.kt index 128e251a3..8fb0cc91e 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxyLoads.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxyLoads.kt @@ -7,8 +7,8 @@ import kotlinx.coroutines.* import org.telegram.messenger.FileLog import tw.nekomimi.nekogram.utils.DnsFactory import tw.nekomimi.nekogram.utils.ProxyUtil.parseProxies -import tw.nekomimi.nkmr.NekomuraConfig -import tw.nekomimi.nkmr.NekomuraUtil +import tw.nekomimi.nekogram.NekoConfig +import tw.nekomimi.nekogram.utils.StrUtil import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger import kotlin.coroutines.resume @@ -16,13 +16,13 @@ import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine fun loadProxiesPublic(urls: List, exceptions: MutableMap): List { - if (!NekomuraConfig.enablePublicProxy.Bool()) + if (!NekoConfig.enablePublicProxy.Bool()) return emptyList() // Try DoH first ( github.com is often blocked try { var content = DnsFactory.getTxts("nachonekodayo.sekai.icu").joinToString() - val proxiesString = NekomuraUtil.getSubString(content, "#NekoXStart#", "#NekoXEnd#") + val proxiesString = StrUtil.getSubString(content, "#NekoXStart#", "#NekoXEnd#") if (proxiesString.equals(content)) { throw Exception("DoH get public proxy: Not found") } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxySwitcher.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxySwitcher.kt index e4db670f6..8d11c207e 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxySwitcher.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/parts/ProxySwitcher.kt @@ -1,10 +1,8 @@ package tw.nekomimi.nekogram.parts -import org.telegram.messenger.AndroidUtilities import org.telegram.messenger.SharedConfig import org.telegram.tgnet.ConnectionsManager -import tw.nekomimi.nkmr.NekomuraConfig -import tw.nekomimi.nekogram.utils.UIUtil +import tw.nekomimi.nekogram.NekoConfig import java.util.* object ProxySwitcher { @@ -30,7 +28,7 @@ object ProxySwitcher { @JvmStatic fun didReceivedNotification(connectionState: Int) { - if (!NekomuraConfig.proxyAutoSwitch.Bool()) return + if (!NekoConfig.proxyAutoSwitch.Bool()) return currentConnectionState = connectionState diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ProxyManager.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ProxyManager.kt similarity index 95% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/ProxyManager.kt rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ProxyManager.kt index 980f44ac4..4a3a3e6eb 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ProxyManager.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ProxyManager.kt @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram +package tw.nekomimi.nekogram.proxy import java.net.InetSocketAddress import java.net.ServerSocket diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksRSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksRSettingsActivity.java index 1421e3038..0eca38f21 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksRSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksRSettingsActivity.java @@ -45,7 +45,7 @@ import java.util.ArrayList; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.PopupBuilder; +import tw.nekomimi.nekogram.ui.PopupBuilder; public class ShadowsocksRSettingsActivity extends BaseFragment { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksSettingsActivity.java index 07c62c885..f0b9d2895 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/ShadowsocksSettingsActivity.java @@ -56,8 +56,8 @@ import java.util.ArrayList; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nekogram.PopupBuilder; +import tw.nekomimi.nekogram.ui.BottomBuilder; +import tw.nekomimi.nekogram.ui.PopupBuilder; import tw.nekomimi.nekogram.utils.AlertUtil; @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/VmessSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/VmessSettingsActivity.java index fd131e34a..c753244e1 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/VmessSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/VmessSettingsActivity.java @@ -49,7 +49,7 @@ import java.util.ArrayList; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.PopupBuilder; +import tw.nekomimi.nekogram.ui.PopupBuilder; public class VmessSettingsActivity extends BaseFragment { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/WsLoader.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/WsLoader.kt index bcc870a85..2a5249d19 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/WsLoader.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/proxy/WsLoader.kt @@ -6,7 +6,7 @@ import okhttp3.Dns import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import tw.nekomimi.nekogram.proxy.tcp2ws.Tcp2wsServer -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import java.net.InetAddress class WsLoader { @@ -75,7 +75,7 @@ class WsLoader { class CustomDns : Dns { override fun lookup(hostname: String): List { val list = ArrayList() - val ip = NekomuraConfig.customPublicProxyIP.String() + val ip = NekoConfig.customPublicProxyIP.String() if (StrUtil.isBlank(ip)) { return Dns.SYSTEM.lookup(hostname) } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java index 46fdce31e..b582a9ef5 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoAccountSettingsActivity.java @@ -40,7 +40,7 @@ import org.telegram.ui.Components.UndoView; import java.util.ArrayList; -import tw.nekomimi.nekogram.MessageHelper; +import tw.nekomimi.nekogram.ui.MessageHelper; @SuppressLint("RtlHardcoded") public class NekoAccountSettingsActivity extends BaseFragment { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java index a64642278..e900bd15a 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -46,17 +46,17 @@ 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.AbstractCell; -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; +import tw.nekomimi.nekogram.ui.PopupBuilder; +import tw.nekomimi.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.config.cell.AbstractConfigCell; +import tw.nekomimi.nekogram.config.cell.ConfigCellCustom; +import tw.nekomimi.nekogram.config.cell.ConfigCellDivider; +import tw.nekomimi.nekogram.config.cell.ConfigCellHeader; +import tw.nekomimi.nekogram.config.cell.ConfigCellSelectBox; +import tw.nekomimi.nekogram.config.cell.ConfigCellTextCheck; +import tw.nekomimi.nekogram.config.cell.ConfigCellTextDetail; +import tw.nekomimi.nekogram.config.cell.ConfigCellTextInput; @SuppressLint("RtlHardcoded") public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { @@ -64,62 +64,62 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati private final CellGroup cellGroup = new CellGroup(this); private final boolean showCensoredFeatures = NekoXConfig.showCensoredFeatures(); - 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 showSeconds = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.showSeconds)); - 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, + private final AbstractConfigCell header0 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("StickerSize"))); + private final AbstractConfigCell stickerSizeRow = cellGroup.appendCell(new ConfigCellCustom(998, true)); + private final AbstractConfigCell divider0 = cellGroup.appendCell(new ConfigCellDivider()); + private final AbstractConfigCell header1 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Chat"))); + private final AbstractConfigCell unreadBadgeOnBackButton = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.unreadBadgeOnBackButton)); + private final AbstractConfigCell ignoreBlockedRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.ignoreBlocked, LocaleController.getString("IgnoreBlockedAbout"))); + private final AbstractConfigCell ignoreMutedCountRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.ignoreMutedCount)); + private final AbstractConfigCell disableChatActionRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChatAction)); + private final AbstractConfigCell disableChoosingStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChoosingSticker)); + private final AbstractConfigCell disablePhotoSideActionRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disablePhotoSideAction)); + private final AbstractConfigCell hideKeyboardOnChatScrollRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideKeyboardOnChatScroll)); + private final AbstractConfigCell disableVibrationRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableVibration)); + private final AbstractConfigCell skipOpenLinkConfirmRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.skipOpenLinkConfirm)); + private final AbstractConfigCell rearVideoMessagesRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.rearVideoMessages)); + private final AbstractConfigCell confirmAVRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.confirmAVMessage)); + private final AbstractConfigCell useChatAttachMediaMenuRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useChatAttachMediaMenu, LocaleController.getString("UseChatAttachEnterMenuNotice"))); + private final AbstractConfigCell disableLinkPreviewByDefaultRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableLinkPreviewByDefault, LocaleController.getString("DisableLinkPreviewByDefaultNotice"))); + private final AbstractConfigCell sendCommentAfterForwardRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.sendCommentAfterForward)); + private final AbstractConfigCell disableProximityEventsRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableProximityEvents)); + private final AbstractConfigCell disableTrendingRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableTrending)); + private final AbstractConfigCell dontSendGreetingStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.dontSendGreetingSticker)); + private final AbstractConfigCell hideTimeForStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideTimeForSticker)); + private final AbstractConfigCell hideGroupStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideGroupSticker)); + private final AbstractConfigCell takeGIFasVideoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.takeGIFasVideo)); + private final AbstractConfigCell showSeconds = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showSeconds)); + private final AbstractConfigCell maxRecentStickerCountRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell disableSwipeToNextRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableSwipeToNext)); + private final AbstractConfigCell disableRemoteEmojiInteractionsRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableRemoteEmojiInteractions)); + private final AbstractConfigCell mapPreviewRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.mapPreviewProvider, new String[]{ LocaleController.getString("MapPreviewProviderTelegram", R.string.MapPreviewProviderTelegram), LocaleController.getString("MapPreviewProviderYandex", R.string.MapPreviewProviderYandex), LocaleController.getString("MapPreviewProviderNobody", R.string.MapPreviewProviderNobody) }, null)); - private final AbstractCell messageMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> { + private final AbstractConfigCell messageMenuRow = cellGroup.appendCell(new ConfigCellSelectBox(LocaleController.getString("MessageMenu"), null, null, () -> { showMessageMenuAlert(); })); - private final AbstractCell repeatConfirmRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.repeatConfirm)); - private final AbstractCell rememberAllBackMessagesRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.rememberAllBackMessages)); - private final AbstractCell hideSendAsChannelRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideSendAsChannel)); - 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, + private final AbstractConfigCell repeatConfirmRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.repeatConfirm)); + private final AbstractConfigCell rememberAllBackMessagesRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.rememberAllBackMessages)); + private final AbstractConfigCell hideSendAsChannelRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideSendAsChannel)); + private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider()); + private final AbstractConfigCell header2 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("AutoDownload"))); + private final AbstractConfigCell win32Row = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingWin32Executable)); + private final AbstractConfigCell archiveRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingArchive)); + private final AbstractConfigCell divider2 = cellGroup.appendCell(new ConfigCellDivider()); + private final AbstractConfigCell header3 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Folder"))); + private final AbstractConfigCell showTabsOnForwardRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showTabsOnForward)); + private final AbstractConfigCell hideAllTabRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideAllTab, LocaleController.getString("HideAllTabAbout"))); + private final AbstractConfigCell pressTitleToOpenAllChatsRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.pressTitleToOpenAllChats)); + private final AbstractConfigCell tabsTitleTypeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.tabsTitleType, new String[]{ LocaleController.getString("TabTitleTypeText", R.string.TabTitleTypeText), LocaleController.getString("TabTitleTypeIcon", R.string.TabTitleTypeIcon), LocaleController.getString("TabTitleTypeMix", R.string.TabTitleTypeMix) }, null)); - private final AbstractCell divider3 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider3 = cellGroup.appendCell(new ConfigCellDivider()); private RecyclerListView listView; private ListAdapter listAdapter; @@ -151,7 +151,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati menuItem = menu.addItem(0, R.drawable.ic_ab_other); menuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); menuItem.addSubItem(1, R.drawable.msg_reset, LocaleController.getString("ResetStickerSize", R.string.ResetStickerSize)); - menuItem.setVisibility(NekomuraConfig.stickerSize.Float() != 14.0f ? View.VISIBLE : View.GONE); + menuItem.setVisibility(NekoConfig.stickerSize.Float() != 14.0f ? View.VISIBLE : View.GONE); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override @@ -159,7 +159,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati if (id == -1) { finishFragment(); } else if (id == 1) { - NekomuraConfig.stickerSize.setConfigFloat(14.0f); + NekoConfig.stickerSize.setConfigFloat(14.0f); menuItem.setVisibility(View.GONE); stickerSizeCell.invalidate(); } @@ -171,9 +171,9 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati cellGroup.rows.remove(disableChatActionRow); cellGroup.rows.remove(disableChoosingStickerRow); cellGroup.rows.remove(ignoreBlockedRow); - NekomuraConfig.disableChatAction.setConfigBool(false); - NekomuraConfig.disableChoosingSticker.setConfigBool(false); - NekomuraConfig.ignoreBlocked.setConfigBool(false); + NekoConfig.disableChatAction.setConfigBool(false); + NekoConfig.disableChoosingSticker.setConfigBool(false); + NekoConfig.ignoreBlocked.setConfigBool(false); } listAdapter = new ListAdapter(context); @@ -190,22 +190,22 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati // Fragment: Set OnClick Callbacks listView.setOnItemClickListener((view, position, x, y) -> { - AbstractCell a = cellGroup.rows.get(position); - if (a instanceof NekomuraTGTextCheck) { - ((NekomuraTGTextCheck) a).onClick((TextCheckCell) view); - } else if (a instanceof NekomuraTGSelectBox) { - ((NekomuraTGSelectBox) a).onClick(view); - } else if (a instanceof NekomuraTGTextInput) { - ((NekomuraTGTextInput) a).onClick(); - } else if (a instanceof NekomuraTGTextDetail) { - RecyclerListView.OnItemClickListener o = ((NekomuraTGTextDetail) a).onItemClickListener; + AbstractConfigCell a = cellGroup.rows.get(position); + if (a instanceof ConfigCellTextCheck) { + ((ConfigCellTextCheck) a).onClick((TextCheckCell) view); + } else if (a instanceof ConfigCellSelectBox) { + ((ConfigCellSelectBox) a).onClick(view); + } else if (a instanceof ConfigCellTextInput) { + ((ConfigCellTextInput) a).onClick(); + } else if (a instanceof ConfigCellTextDetail) { + RecyclerListView.OnItemClickListener o = ((ConfigCellTextDetail) a).onItemClickListener; if (o != null) { try { o.onItemClick(view, position); } catch (Exception e) { } } - } else if (a instanceof NekomuraTGCustom) { // Custom onclick + } else if (a instanceof ConfigCellCustom) { // Custom onclick if (position == cellGroup.rows.indexOf(maxRecentStickerCountRow)) { final int[] counts = {20, 30, 40, 50, 80, 100, 120, 150, 180, 200}; List types = Arrays.stream(counts) @@ -214,7 +214,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati .collect(Collectors.toList()); PopupBuilder builder = new PopupBuilder(view); builder.setItems(types, (i, str) -> { - NekomuraConfig.maxRecentStickerCount.setConfigInt(Integer.parseInt(str.toString())); + NekoConfig.maxRecentStickerCount.setConfigInt(Integer.parseInt(str.toString())); listAdapter.notifyItemChanged(position); return Unit.INSTANCE; }); @@ -225,15 +225,15 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati // Cells: Set OnSettingChanged Callbacks cellGroup.callBackSettingsChanged = (key, newValue) -> { - if (key.equals(NekomuraConfig.hideAllTab.getKey())) { + if (key.equals(NekoConfig.hideAllTab.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); - } else if (key.equals(NekomuraConfig.pressTitleToOpenAllChats.getKey())) { + } else if (key.equals(NekoConfig.pressTitleToOpenAllChats.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); - } else if (key.equals(NekomuraConfig.tabsTitleType.getKey())) { + } else if (key.equals(NekoConfig.tabsTitleType.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated); - } else if (key.equals(NekomuraConfig.disableProximityEvents.getKey())) { + } else if (key.equals(NekoConfig.disableProximityEvents.getKey())) { MediaController.getInstance().recreateProximityWakeLock(); - } else if (key.equals(NekomuraConfig.showSeconds.getKey())) { + } else if (key.equals(NekoConfig.showSeconds.getKey())) { tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } }; @@ -322,47 +322,47 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati TextCheckCell textCell = new TextCheckCell(context); switch (a) { case 0: { - textCell.setTextAndCheck(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile), NekomuraConfig.showDeleteDownloadedFile.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("DeleteDownloadedFile", R.string.DeleteDownloadedFile), NekoConfig.showDeleteDownloadedFile.Bool(), false); break; } case 1: { - textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekomuraConfig.showAddToSavedMessages.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages), NekoConfig.showAddToSavedMessages.Bool(), false); break; } case 2: { - textCell.setTextAndCheck(LocaleController.getString("Repeat", R.string.Repeat), NekomuraConfig.showRepeat.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("Repeat", R.string.Repeat), NekoConfig.showRepeat.Bool(), false); break; } case 3: { - textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekomuraConfig.showViewHistory.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("ViewHistory", R.string.ViewHistory), NekoConfig.showViewHistory.Bool(), false); break; } case 4: { - textCell.setTextAndCheck(LocaleController.getString("Translate", R.string.Translate), NekomuraConfig.showTranslate.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("Translate", R.string.Translate), NekoConfig.showTranslate.Bool(), false); break; } case 5: { - textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekomuraConfig.showReport.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("ReportChat", R.string.ReportChat), NekoConfig.showReport.Bool(), false); break; } case 6: { - textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekomuraConfig.showAdminActions.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("EditAdminRights", R.string.EditAdminRights), NekoConfig.showAdminActions.Bool(), false); break; } case 7: { - textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekomuraConfig.showChangePermissions.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("ChangePermissions", R.string.ChangePermissions), NekoConfig.showChangePermissions.Bool(), false); break; } case 8: { - textCell.setTextAndCheck(LocaleController.getString("Hide", R.string.Hide), NekomuraConfig.showMessageHide.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("Hide", R.string.Hide), NekoConfig.showMessageHide.Bool(), false); break; } case 9: { - textCell.setTextAndCheck(LocaleController.getString("ShareMessages", R.string.ShareMessages), NekomuraConfig.showShareMessages.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("ShareMessages", R.string.ShareMessages), NekoConfig.showShareMessages.Bool(), false); break; } case 10: { - textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekomuraConfig.showMessageDetails.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekoConfig.showMessageDetails.Bool(), false); break; } } @@ -373,47 +373,47 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati Integer tag = (Integer) v2.getTag(); switch (tag) { case 0: { - textCell.setChecked(NekomuraConfig.showDeleteDownloadedFile.toggleConfigBool()); + textCell.setChecked(NekoConfig.showDeleteDownloadedFile.toggleConfigBool()); break; } case 1: { - textCell.setChecked(NekomuraConfig.showAddToSavedMessages.toggleConfigBool()); + textCell.setChecked(NekoConfig.showAddToSavedMessages.toggleConfigBool()); break; } case 2: { - textCell.setChecked(NekomuraConfig.showRepeat.toggleConfigBool()); + textCell.setChecked(NekoConfig.showRepeat.toggleConfigBool()); break; } case 3: { - textCell.setChecked(NekomuraConfig.showViewHistory.toggleConfigBool()); + textCell.setChecked(NekoConfig.showViewHistory.toggleConfigBool()); break; } case 4: { - textCell.setChecked(NekomuraConfig.showTranslate.toggleConfigBool()); + textCell.setChecked(NekoConfig.showTranslate.toggleConfigBool()); break; } case 5: { - textCell.setChecked(NekomuraConfig.showReport.toggleConfigBool()); + textCell.setChecked(NekoConfig.showReport.toggleConfigBool()); break; } case 6: { - textCell.setChecked(NekomuraConfig.showAdminActions.toggleConfigBool()); + textCell.setChecked(NekoConfig.showAdminActions.toggleConfigBool()); break; } case 7: { - textCell.setChecked(NekomuraConfig.showChangePermissions.toggleConfigBool()); + textCell.setChecked(NekoConfig.showChangePermissions.toggleConfigBool()); break; } case 8: { - textCell.setChecked(NekomuraConfig.showMessageHide.toggleConfigBool()); + textCell.setChecked(NekoConfig.showMessageHide.toggleConfigBool()); break; } case 9: { - textCell.setChecked(NekomuraConfig.showShareMessages.toggleConfigBool()); + textCell.setChecked(NekoConfig.showShareMessages.toggleConfigBool()); break; } case 10: { - textCell.setChecked(NekomuraConfig.showMessageDetails.toggleConfigBool()); + textCell.setChecked(NekoConfig.showMessageDetails.toggleConfigBool()); break; } } @@ -461,7 +461,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati sizeBar.setDelegate(new SeekBarView.SeekBarViewDelegate() { @Override public void onSeekBarDrag(boolean stop, float progress) { - NekomuraConfig.stickerSize.setConfigFloat(startStickerSize + (endStickerSize - startStickerSize) * progress); + NekoConfig.stickerSize.setConfigFloat(startStickerSize + (endStickerSize - startStickerSize) * progress); StickerSizeCell.this.invalidate(); menuItem.setVisibility(View.VISIBLE); } @@ -480,13 +480,13 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati @Override protected void onDraw(Canvas canvas) { textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText)); - canvas.drawText("" + Math.round(NekomuraConfig.stickerSize.Float()), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint); + canvas.drawText("" + Math.round(NekoConfig.stickerSize.Float()), getMeasuredWidth() - AndroidUtilities.dp(39), AndroidUtilities.dp(28), textPaint); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - sizeBar.setProgress((NekomuraConfig.stickerSize.Float() - startStickerSize) / (float) (endStickerSize - startStickerSize)); + sizeBar.setProgress((NekoConfig.stickerSize.Float() - startStickerSize) / (float) (endStickerSize - startStickerSize)); } @Override @@ -514,7 +514,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati @Override public boolean isEnabled(RecyclerView.ViewHolder holder) { int position = holder.getAdapterPosition(); - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.isEnabled(); } @@ -523,7 +523,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati @Override public int getItemViewType(int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.getType(); } @@ -532,14 +532,14 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { - if (a instanceof NekomuraTGCustom) { + if (a instanceof ConfigCellCustom) { // Custom binds if (holder.itemView instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) holder.itemView; if (position == cellGroup.rows.indexOf(maxRecentStickerCountRow)) { - textCell.setTextAndValue(LocaleController.getString("maxRecentStickerCount", R.string.maxRecentStickerCount), String.valueOf(NekomuraConfig.maxRecentStickerCount.Int()), true); + textCell.setTextAndValue(LocaleController.getString("maxRecentStickerCount", R.string.maxRecentStickerCount), String.valueOf(NekoConfig.maxRecentStickerCount.Int()), true); } } } else { 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 4e347d538..6943ae943 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java @@ -8,9 +8,6 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; -import android.os.ParcelFileDescriptor; -import android.os.Parcelable; -import android.provider.DocumentsContract; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; @@ -52,13 +49,13 @@ import java.io.FileInputStream; import java.util.ArrayList; import kotlin.Unit; -import tw.nekomimi.nekogram.PopupBuilder; +import tw.nekomimi.nekogram.ui.PopupBuilder; +import tw.nekomimi.nekogram.utils.FileUtil; import tw.nekomimi.nekogram.utils.ZipUtil; -import tw.nekomimi.nkmr.NekomuraConfig; -import tw.nekomimi.nkmr.CellGroup; -import tw.nekomimi.nkmr.NekomuraUtil; -import tw.nekomimi.nkmr.cells.AbstractCell; -import tw.nekomimi.nkmr.cells.*; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.cell.AbstractConfigCell; +import tw.nekomimi.nekogram.config.cell.*; @SuppressLint("RtlHardcoded") public class NekoExperimentalSettingsActivity extends BaseFragment { @@ -72,21 +69,21 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { private final CellGroup cellGroup = new CellGroup(this); - private final AbstractCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Experiment"))); - private final AbstractCell useSystemEmojiRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useSystemEmoji)); - private final AbstractCell useCustomEmojiRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useCustomEmoji)); - 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 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 final AbstractConfigCell header1 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Experiment"))); + private final AbstractConfigCell useSystemEmojiRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useSystemEmoji)); + private final AbstractConfigCell useCustomEmojiRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useCustomEmoji)); + private final AbstractConfigCell smoothKeyboardRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.smoothKeyboard)); + private final AbstractConfigCell increaseVoiceMessageQualityRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.increaseVoiceMessageQuality)); + private final AbstractConfigCell mediaPreviewRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.mediaPreview)); + private final AbstractConfigCell proxyAutoSwitchRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.proxyAutoSwitch)); + private final AbstractConfigCell disableFilteringRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_CHECK, true)); + // private final NekomuraTGCell ignoreContentRestrictionsRow = addNekomuraTGCell(nkmrCells.new NekomuraTGTextCheck(NekoConfig.ignoreContentRestrictions, LocaleController.getString("IgnoreContentRestrictionsNotice"))); + private final AbstractConfigCell unlimitedFavedStickersRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.unlimitedFavedStickers, LocaleController.getString("UnlimitedFavoredStickersAbout"))); + private final AbstractConfigCell unlimitedPinnedDialogsRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.unlimitedPinnedDialogs, LocaleController.getString("UnlimitedPinnedDialogsAbout"))); + private final AbstractConfigCell enableStickerPinRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.enableStickerPin, LocaleController.getString("EnableStickerPinAbout"))); + private final AbstractConfigCell useMediaStreamInVoipRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useMediaStreamInVoip)); + private final AbstractConfigCell customAudioBitrateRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell divider0 = cellGroup.appendCell(new ConfigCellDivider()); private UndoView tooltip; @@ -131,22 +128,22 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { // Fragment: Set OnClick Callbacks listView.setOnItemClickListener((view, position, x, y) -> { - AbstractCell a = cellGroup.rows.get(position); - if (a instanceof NekomuraTGTextCheck) { - ((NekomuraTGTextCheck) a).onClick((TextCheckCell) view); - } else if (a instanceof NekomuraTGSelectBox) { - ((NekomuraTGSelectBox) a).onClick(view); - } else if (a instanceof NekomuraTGTextInput) { - ((NekomuraTGTextInput) a).onClick(); - } else if (a instanceof NekomuraTGTextDetail) { - RecyclerListView.OnItemClickListener o = ((NekomuraTGTextDetail) a).onItemClickListener; + AbstractConfigCell a = cellGroup.rows.get(position); + if (a instanceof ConfigCellTextCheck) { + ((ConfigCellTextCheck) a).onClick((TextCheckCell) view); + } else if (a instanceof ConfigCellSelectBox) { + ((ConfigCellSelectBox) a).onClick(view); + } else if (a instanceof ConfigCellTextInput) { + ((ConfigCellTextInput) a).onClick(); + } else if (a instanceof ConfigCellTextDetail) { + RecyclerListView.OnItemClickListener o = ((ConfigCellTextDetail) a).onItemClickListener; if (o != null) { try { o.onItemClick(view, position); } catch (Exception e) { } } - } else if (a instanceof NekomuraTGCustom) { // Custom onclick + } else if (a instanceof ConfigCellCustom) { // Custom onclick if (position == cellGroup.rows.indexOf(disableFilteringRow)) { sensitiveEnabled = !sensitiveEnabled; TLRPC.TL_account_setContentSettings req = new TLRPC.TL_account_setContentSettings(); @@ -175,22 +172,22 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { }, (i, __) -> { switch (i) { case 0: - NekomuraConfig.customAudioBitrate.setConfigInt(32); + NekoConfig.customAudioBitrate.setConfigInt(32); break; case 1: - NekomuraConfig.customAudioBitrate.setConfigInt(64); + NekoConfig.customAudioBitrate.setConfigInt(64); break; case 2: - NekomuraConfig.customAudioBitrate.setConfigInt(128); + NekoConfig.customAudioBitrate.setConfigInt(128); break; case 3: - NekomuraConfig.customAudioBitrate.setConfigInt(192); + NekoConfig.customAudioBitrate.setConfigInt(192); break; case 4: - NekomuraConfig.customAudioBitrate.setConfigInt(256); + NekoConfig.customAudioBitrate.setConfigInt(256); break; case 5: - NekomuraConfig.customAudioBitrate.setConfigInt(320); + NekoConfig.customAudioBitrate.setConfigInt(320); break; } listAdapter.notifyItemChanged(position); @@ -203,7 +200,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { // Cells: Set OnSettingChanged Callbacks cellGroup.callBackSettingsChanged = (key, newValue) -> { - if (key.equals(NekomuraConfig.smoothKeyboard.getKey())) { + if (key.equals(NekoConfig.smoothKeyboard.getKey())) { SharedConfig.setSmoothKeyboard((boolean) newValue); if (SharedConfig.smoothKeyboard && getParentActivity() != null) { getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); @@ -212,23 +209,23 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { 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.mediaPreview.getKey())) { + } else if (key.equals(NekoConfig.mediaPreview.getKey())) { 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())) { + } else if (key.equals(NekoConfig.enableStickerPin.getKey())) { 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())) { + } else if (key.equals(NekoConfig.useCustomEmoji.getKey())) { // Check if (!(boolean) newValue) { tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); return; } - NekomuraConfig.useCustomEmoji.setConfigBool(false); + NekoConfig.useCustomEmoji.setConfigBool(false); // Open picker Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); @@ -263,7 +260,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { //dirs File dir = new File(ApplicationLoader.applicationContext.getFilesDir(), "custom_emoji"); if (dir.exists()) { - NekomuraUtil.deleteDirectory(dir); + FileUtil.deleteDirectory(dir); } dir.mkdir(); @@ -275,10 +272,10 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { throw new Exception(LocaleController.getString("useCustomEmojiInvalid")); } - NekomuraConfig.useCustomEmoji.setConfigBool(true); + NekoConfig.useCustomEmoji.setConfigBool(true); } catch (Exception e) { FileLog.e(e); - NekomuraConfig.useCustomEmoji.setConfigBool(false); + NekoConfig.useCustomEmoji.setConfigBool(false); Toast.makeText(ApplicationLoader.applicationContext, "Failed: " + e.toString(), Toast.LENGTH_LONG).show(); } tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); @@ -403,7 +400,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { @Override public boolean isEnabled(RecyclerView.ViewHolder holder) { int position = holder.getAdapterPosition(); - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.isEnabled(); } @@ -412,7 +409,7 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { @Override public int getItemViewType(int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.getType(); } @@ -421,9 +418,9 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { - if (a instanceof NekomuraTGCustom) { + if (a instanceof ConfigCellCustom) { // Custom binds if (holder.itemView instanceof TextCheckCell) { TextCheckCell textCell = (TextCheckCell) holder.itemView; @@ -436,8 +433,8 @@ public class NekoExperimentalSettingsActivity extends BaseFragment { TextSettingsCell textCell = (TextSettingsCell) holder.itemView; textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); if (position == cellGroup.rows.indexOf(customAudioBitrateRow)) { - String value = String.valueOf(NekomuraConfig.customAudioBitrate.Int()) + "kbps"; - if (NekomuraConfig.customAudioBitrate.Int() == 32) + String value = String.valueOf(NekoConfig.customAudioBitrate.Int()) + "kbps"; + if (NekoConfig.customAudioBitrate.Int() == 32) value += " (" + LocaleController.getString("Default", R.string.Default) + ")"; textCell.setTextAndValue(LocaleController.getString("customGroupVoipAudioBitrate", R.string.customGroupVoipAudioBitrate), value, false); } 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 1d82cc400..b5b3b94d8 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -56,20 +56,19 @@ import java.util.List; import cn.hutool.core.util.StrUtil; import kotlin.Unit; -import tw.nekomimi.nekogram.BottomBuilder; -import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.ui.BottomBuilder; import tw.nekomimi.nekogram.NekoXConfig; -import tw.nekomimi.nekogram.PopupBuilder; +import tw.nekomimi.nekogram.ui.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.CellGroup; -import tw.nekomimi.nkmr.cells.AbstractCell; -import tw.nekomimi.nkmr.cells.*; +import tw.nekomimi.nekogram.config.ConfigItem; +import tw.nekomimi.nekogram.NekoConfig; +import tw.nekomimi.nekogram.config.CellGroup; +import tw.nekomimi.nekogram.config.cell.AbstractConfigCell; +import tw.nekomimi.nekogram.config.cell.*; @SuppressLint("RtlHardcoded") public class NekoGeneralSettingsActivity extends BaseFragment { @@ -82,87 +81,87 @@ public class NekoGeneralSettingsActivity extends BaseFragment { private final CellGroup cellGroup = new CellGroup(this); - 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 AbstractConfigCell profilePreviewRow = cellGroup.appendCell(new ConfigCellDrawerProfilePreview()); + private final AbstractConfigCell largeAvatarInDrawerRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.largeAvatarInDrawer, LocaleController.getString("valuesLargeAvatarInDrawer"), null)); + private final AbstractConfigCell avatarBackgroundBlurRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundBlur)); + private final AbstractConfigCell avatarBackgroundDarkenRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.avatarBackgroundDarken)); + private final AbstractConfigCell hidePhoneRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hidePhone)); + private final AbstractConfigCell divider0 = cellGroup.appendCell(new ConfigCellDivider()); - private final AbstractCell header1 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("Connection"))); - private final AbstractCell useIPv6Row = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useIPv6)); - private final AbstractCell useProxyItemRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.useProxyItem)); - private final AbstractCell hideProxyByDefaultRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.hideProxyByDefault)); - private final AbstractCell autoUpdateSubInfoRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.autoUpdateSubInfo)); - 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"); + private final AbstractConfigCell header1 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Connection"))); + private final AbstractConfigCell useIPv6Row = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useIPv6)); + private final AbstractConfigCell useProxyItemRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useProxyItem)); + private final AbstractConfigCell hideProxyByDefaultRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideProxyByDefault)); + private final AbstractConfigCell autoUpdateSubInfoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.autoUpdateSubInfo)); + private final AbstractConfigCell useSystemDNSRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useSystemDNS)); + private final AbstractConfigCell customDoHRow = cellGroup.appendCell(new ConfigCellTextInput(null, NekoConfig.customDoH, "https://1.0.0.1/dns-query", null)); + private final AbstractConfigCell customPublicProxyIPRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.customPublicProxyIP, (view, position) -> { + customDialog_BottomInputString(position, NekoConfig.customPublicProxyIP, LocaleController.getString("customPublicProxyIPNotice"), "IP"); }, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty))); - private final AbstractCell divider1 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider()); - 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"); + private final AbstractConfigCell header2 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Translate"))); + private final AbstractConfigCell translationProviderRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell translateToLangRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell translateInputToLangRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell googleCloudTranslateKeyRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.googleCloudTranslateKey, (view, position) -> { + customDialog_BottomInputString(position, NekoConfig.googleCloudTranslateKey, LocaleController.getString("GoogleCloudTransKeyNotice"), "Key"); }, LocaleController.getString("UsernameEmpty", R.string.UsernameEmpty))); - private final AbstractCell divider2 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider2 = cellGroup.appendCell(new ConfigCellDivider()); - 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) -> { + private final AbstractConfigCell header3 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("OpenKayChain"))); + private final AbstractConfigCell pgpAppRow = cellGroup.appendCell(new ConfigCellCustom(CellGroup.ITEM_TYPE_TEXT_SETTINGS_CELL, true)); + private final AbstractConfigCell keyRow = cellGroup.appendCell(new ConfigCellTextDetail(NekoConfig.openPGPKeyId, (view, position) -> { requestKey(new Intent(OpenPgpApi.ACTION_GET_SIGN_KEY_ID)); }, "0")); - private final AbstractCell divider3 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider3 = cellGroup.appendCell(new ConfigCellDivider()); - private final AbstractCell header4 = cellGroup.appendCell(new NekomuraTGHeader(LocaleController.getString("DialogsSettings"))); - private final AbstractCell sortMenuRow = cellGroup.appendCell(new NekomuraTGSelectBox(LocaleController.getString("SortMenu"), null, null, () -> { + private final AbstractConfigCell header4 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("DialogsSettings"))); + private final AbstractConfigCell sortMenuRow = cellGroup.appendCell(new ConfigCellSelectBox(LocaleController.getString("SortMenu"), null, null, () -> { showSortMenuAlert(); })); - private final AbstractCell divider4 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider4 = cellGroup.appendCell(new ConfigCellDivider()); - 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 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[]{ + private final AbstractConfigCell header5 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Appearance"))); + private final AbstractConfigCell typefaceRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.typeface)); + private final AbstractConfigCell useDefaultThemeRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useDefaultTheme)); + private final AbstractConfigCell transparentStatusBarRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.transparentStatusBar)); + private final AbstractConfigCell appBarShadowRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAppBarShadow)); + private final AbstractConfigCell newYearRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.newYear)); + private final AbstractConfigCell actionBarDecorationRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.actionBarDecoration, new String[]{ LocaleController.getString("DependsOnDate", R.string.DependsOnDate), LocaleController.getString("Snowflakes", R.string.Snowflakes), LocaleController.getString("Fireworks", R.string.Fireworks) }, null)); - private final AbstractCell tabletModeRow = cellGroup.appendCell(new NekomuraTGSelectBox(null, NekomuraConfig.tabletMode, new String[]{ + private final AbstractConfigCell tabletModeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.tabletMode, new String[]{ LocaleController.getString("TabletModeDefault", R.string.TabletModeDefault), LocaleController.getString("Enable", R.string.Enable), LocaleController.getString("Disable", R.string.Disable) }, null)); - private final AbstractCell divider5 = cellGroup.appendCell(new NekomuraTGDivider()); + private final AbstractConfigCell divider5 = cellGroup.appendCell(new ConfigCellDivider()); - 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 AbstractConfigCell header6 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("PrivacyTitle"))); + private final AbstractConfigCell disableSystemAccountRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableSystemAccount)); + private final AbstractConfigCell divider6 = cellGroup.appendCell(new ConfigCellDivider()); - 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 disableInstantCameraRow = cellGroup.appendCell(new NekomuraTGTextCheck(NekomuraConfig.disableInstantCamera)); - 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[]{ + private final AbstractConfigCell header7 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("General"))); + private final AbstractConfigCell disableUndoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableUndo)); + private final AbstractConfigCell showIdAndDcRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.showIdAndDc)); + private final AbstractConfigCell inappCameraRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.inappCamera)); + private final AbstractConfigCell disableInstantCameraRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableInstantCamera)); + private final AbstractConfigCell hideProxySponsorChannelRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideProxySponsorChannel)); + private final AbstractConfigCell hideSponsoredMessageRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.hideSponsoredMessage)); + private final AbstractConfigCell askBeforeCallRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.askBeforeCall)); + private final AbstractConfigCell autoPauseVideoRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.autoPauseVideo, LocaleController.getString("AutoPauseVideoAbout"))); + private final AbstractConfigCell disableNumberRoundingRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableNumberRounding, "4.8K -> 4777")); + private final AbstractConfigCell openArchiveOnPullRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.openArchiveOnPull)); + private final AbstractConfigCell nameOrderRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NekoConfig.nameOrder, new String[]{ LocaleController.getString("LastFirst", R.string.LastFirst), LocaleController.getString("FirstLast", R.string.FirstLast) }, null)); - 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 final AbstractConfigCell usePersianCalendarRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.usePersianCalendar, LocaleController.getString("UsePersiancalendarInfo"))); + private final AbstractConfigCell displayPersianCalendarByLatinRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.displayPersianCalendarByLatin)); + private final AbstractConfigCell divider7 = cellGroup.appendCell(new ConfigCellDivider()); private UndoView restartTooltip; @@ -214,22 +213,22 @@ public class NekoGeneralSettingsActivity extends BaseFragment { // Fragment: Set OnClick Callbacks listView.setOnItemClickListener((view, position, x, y) -> { - AbstractCell a = cellGroup.rows.get(position); - if (a instanceof NekomuraTGTextCheck) { - ((NekomuraTGTextCheck) a).onClick((TextCheckCell) view); - } else if (a instanceof NekomuraTGSelectBox) { - ((NekomuraTGSelectBox) a).onClick(view); - } else if (a instanceof NekomuraTGTextInput) { - ((NekomuraTGTextInput) a).onClick(); - } else if (a instanceof NekomuraTGTextDetail) { - RecyclerListView.OnItemClickListener o = ((NekomuraTGTextDetail) a).onItemClickListener; + AbstractConfigCell a = cellGroup.rows.get(position); + if (a instanceof ConfigCellTextCheck) { + ((ConfigCellTextCheck) a).onClick((TextCheckCell) view); + } else if (a instanceof ConfigCellSelectBox) { + ((ConfigCellSelectBox) a).onClick(view); + } else if (a instanceof ConfigCellTextInput) { + ((ConfigCellTextInput) a).onClick(); + } else if (a instanceof ConfigCellTextDetail) { + RecyclerListView.OnItemClickListener o = ((ConfigCellTextDetail) a).onItemClickListener; if (o != null) { try { o.onItemClick(view, position); } catch (Exception e) { } } - } else if (a instanceof NekomuraTGCustom) { // Custom OnClick + } else if (a instanceof ConfigCellCustom) { // Custom OnClick if (position == cellGroup.rows.indexOf(pgpAppRow)) { PopupBuilder builder = new PopupBuilder(view); @@ -257,8 +256,8 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } builder.setDelegate((i) -> { - NekomuraConfig.openPGPApp.setConfigString(appsMap.get(i)); - NekomuraConfig.openPGPKeyId.setConfigLong(0L); + NekoConfig.openPGPApp.setConfigString(appsMap.get(i)); + NekoConfig.openPGPKeyId.setConfigLong(0L); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(pgpAppRow)); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow)); @@ -278,8 +277,8 @@ public class NekoGeneralSettingsActivity extends BaseFragment { 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); + boolean needReset = NekoConfig.translationProvider.Int() - 1 != i && (NekoConfig.translationProvider.Int() == 1 || i == 0); + NekoConfig.translationProvider.setConfigInt(i + 1); if (needReset) { updateRows(true); } else { @@ -291,9 +290,9 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } 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)); + NekoConfig.translateToLang.setConfigString(TranslatorKt.getLocale2code(locale)); } else { - NekomuraConfig.translateInputLang.setConfigString(TranslatorKt.getLocale2code(locale)); + NekoConfig.translateInputLang.setConfigString(TranslatorKt.getLocale2code(locale)); } listAdapter.notifyItemChanged(position); return Unit.INSTANCE; @@ -306,38 +305,38 @@ public class NekoGeneralSettingsActivity extends BaseFragment { // Cells: Set OnSettingChanged Callbacks cellGroup.callBackSettingsChanged = (key, newValue) -> { - if (key.equals(NekomuraConfig.useIPv6.getKey())) { + if (key.equals(NekoConfig.useIPv6.getKey())) { for (int a : SharedConfig.activeAccounts) { if (UserConfig.getInstance(a).isClientActivated()) { ConnectionsManager.native_setIpStrategy(a, ConnectionsManager.getIpStrategy()); } } - } else if (key.equals(NekomuraConfig.inappCamera.getKey())) { + } else if (key.equals(NekoConfig.inappCamera.getKey())) { SharedConfig.setInappCamera((boolean) newValue); restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.hidePhone.getKey())) { + } else if (key.equals(NekoConfig.hidePhone.getKey())) { parentLayout.rebuildAllFragmentViews(false, false); getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow)); - } else if (key.equals(NekomuraConfig.transparentStatusBar.getKey())) { + } else if (key.equals(NekoConfig.transparentStatusBar.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.hideProxySponsorChannel.getKey())) { + } else if (key.equals(NekoConfig.hideProxySponsorChannel.getKey())) { for (int a : SharedConfig.activeAccounts) { if (UserConfig.getInstance(a).isClientActivated()) { MessagesController.getInstance(a).checkPromoInfo(true); } } - } else if (key.equals(NekomuraConfig.actionBarDecoration.getKey())) { + } else if (key.equals(NekoConfig.actionBarDecoration.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.tabletMode.getKey())) { + } else if (key.equals(NekoConfig.tabletMode.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.newYear.getKey())) { + } else if (key.equals(NekoConfig.newYear.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.usePersianCalendar.getKey())) { + } else if (key.equals(NekoConfig.usePersianCalendar.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.displayPersianCalendarByLatin.getKey())) { + } else if (key.equals(NekoConfig.displayPersianCalendarByLatin.getKey())) { restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); - } else if (key.equals(NekomuraConfig.disableSystemAccount.getKey())) { + } else if (key.equals(NekoConfig.disableSystemAccount.getKey())) { if ((boolean) newValue) { getContactsController().deleteUnknownAppAccounts(); } else { @@ -345,18 +344,18 @@ public class NekoGeneralSettingsActivity extends BaseFragment { ContactsController.getInstance(a).checkAppAccount(); } } - } else if (key.equals(NekomuraConfig.largeAvatarInDrawer.getKey())) { + } else if (key.equals(NekoConfig.largeAvatarInDrawer.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); TransitionManager.beginDelayedTransition(profilePreviewCell); setCanNotChange(); listAdapter.notifyDataSetChanged(); - } else if (key.equals(NekomuraConfig.avatarBackgroundBlur.getKey())) { + } else if (key.equals(NekoConfig.avatarBackgroundBlur.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow)); - } else if (key.equals(NekomuraConfig.avatarBackgroundDarken.getKey())) { + } else if (key.equals(NekoConfig.avatarBackgroundDarken.getKey())) { getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(profilePreviewRow)); - } else if (key.equals(NekomuraConfig.disableAppBarShadow.getKey())) { + } else if (key.equals(NekoConfig.disableAppBarShadow.getKey())) { ActionBarLayout.headerShadowDrawable = (boolean) newValue ? null : parentLayout.getResources().getDrawable(R.drawable.header_shadow).mutate(); parentLayout.rebuildAllFragmentViews(true, true); } @@ -371,7 +370,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { return fragmentView; } - private class NkmrDrawerProfilePreviewCell extends AbstractCell { + private class ConfigCellDrawerProfilePreview extends AbstractConfigCell { public int getType() { return 999; } @@ -396,7 +395,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { case OpenPgpApi.RESULT_CODE_SUCCESS: { long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, 0L); - NekomuraConfig.openPGPKeyId.setConfigLong(keyId); + NekoConfig.openPGPKeyId.setConfigLong(keyId); listAdapter.notifyItemChanged(cellGroup.rows.indexOf(keyRow)); @@ -476,19 +475,19 @@ public class NekoGeneralSettingsActivity extends BaseFragment { TextCheckCell textCell = new TextCheckCell(context); switch (a) { case 0: { - textCell.setTextAndCheck(LocaleController.getString("SortByUnread", R.string.SortByUnread), NekomuraConfig.sortByUnread.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("SortByUnread", R.string.SortByUnread), NekoConfig.sortByUnread.Bool(), false); break; } case 1: { - textCell.setTextAndCheck(LocaleController.getString("SortByUnmuted", R.string.SortByUnmuted), NekomuraConfig.sortByUnmuted.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("SortByUnmuted", R.string.SortByUnmuted), NekoConfig.sortByUnmuted.Bool(), false); break; } case 2: { - textCell.setTextAndCheck(LocaleController.getString("SortByUser", R.string.SortByUser), NekomuraConfig.sortByUser.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("SortByUser", R.string.SortByUser), NekoConfig.sortByUser.Bool(), false); break; } case 3: { - textCell.setTextAndCheck(LocaleController.getString("SortByContacts", R.string.SortByContacts), NekomuraConfig.sortByContacts.Bool(), false); + textCell.setTextAndCheck(LocaleController.getString("SortByContacts", R.string.SortByContacts), NekoConfig.sortByContacts.Bool(), false); break; } } @@ -499,30 +498,30 @@ public class NekoGeneralSettingsActivity extends BaseFragment { Integer tag = (Integer) view.getTag(); switch (tag) { case 0: { - NekomuraConfig.sortByUnread.toggleConfigBool(); + NekoConfig.sortByUnread.toggleConfigBool(); if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekomuraConfig.sortByUnread.Bool()); + ((TextCheckCell) view).setChecked(NekoConfig.sortByUnread.Bool()); } break; } case 1: { - NekomuraConfig.sortByUnmuted.toggleConfigBool(); + NekoConfig.sortByUnmuted.toggleConfigBool(); if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekomuraConfig.sortByUnmuted.Bool()); + ((TextCheckCell) view).setChecked(NekoConfig.sortByUnmuted.Bool()); } break; } case 2: { - NekomuraConfig.sortByUser.toggleConfigBool(); + NekoConfig.sortByUser.toggleConfigBool(); if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekomuraConfig.sortByUser.Bool()); + ((TextCheckCell) view).setChecked(NekoConfig.sortByUser.Bool()); } break; } case 3: { - NekomuraConfig.sortByContacts.toggleConfigBool(); + NekoConfig.sortByContacts.toggleConfigBool(); if (view instanceof TextCheckCell) { - ((TextCheckCell) view).setChecked(NekomuraConfig.sortByContacts.Bool()); + ((TextCheckCell) view).setChecked(NekoConfig.sortByContacts.Bool()); } break; } @@ -606,7 +605,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { @Override public boolean isEnabled(RecyclerView.ViewHolder holder) { int position = holder.getAdapterPosition(); - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.isEnabled(); } @@ -615,7 +614,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { @Override public int getItemViewType(int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { return a.getType(); } @@ -624,15 +623,15 @@ public class NekoGeneralSettingsActivity extends BaseFragment { @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - AbstractCell a = cellGroup.rows.get(position); + AbstractConfigCell a = cellGroup.rows.get(position); if (a != null) { - if (a instanceof NekomuraTGCustom) { + if (a instanceof ConfigCellCustom) { // Custom binds if (holder.itemView instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) holder.itemView; if (position == cellGroup.rows.indexOf(translationProviderRow)) { String value; - switch (NekomuraConfig.translationProvider.Int()) { + switch (NekoConfig.translationProvider.Int()) { case 1: value = LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate); break; @@ -659,11 +658,11 @@ public class NekoGeneralSettingsActivity extends BaseFragment { } textCell.setTextAndValue(LocaleController.getString("TranslationProvider", R.string.TranslationProvider), value, true); } else if (position == cellGroup.rows.indexOf(pgpAppRow)) { - textCell.setTextAndValue(LocaleController.getString("OpenPGPApp", R.string.OpenPGPApp), NekoConfig.getOpenPGPAppName(), true); + textCell.setTextAndValue(LocaleController.getString("OpenPGPApp", R.string.OpenPGPApp), NekoXConfig.getOpenPGPAppName(), true); } else if (position == cellGroup.rows.indexOf(translateToLangRow)) { - textCell.setTextAndValue(LocaleController.getString("TransToLang", R.string.TransToLang), NekoConfig.formatLang(NekomuraConfig.translateToLang.String()), true); + textCell.setTextAndValue(LocaleController.getString("TransToLang", R.string.TransToLang), NekoXConfig.formatLang(NekoConfig.translateToLang.String()), true); } else if (position == cellGroup.rows.indexOf(translateInputToLangRow)) { - textCell.setTextAndValue(LocaleController.getString("TransInputToLang", R.string.TransInputToLang), NekoConfig.formatLang(NekomuraConfig.translateInputLang.String()), true); + textCell.setTextAndValue(LocaleController.getString("TransInputToLang", R.string.TransInputToLang), NekoXConfig.formatLang(NekoConfig.translateInputLang.String()), true); } } } else { @@ -718,9 +717,9 @@ public class NekoGeneralSettingsActivity extends BaseFragment { boolean enabled; - enabled = NekomuraConfig.largeAvatarInDrawer.Int() > 0; - ((NekomuraTGTextCheck) avatarBackgroundBlurRow).enabled = enabled; - ((NekomuraTGTextCheck) avatarBackgroundDarkenRow).enabled = enabled; + enabled = NekoConfig.largeAvatarInDrawer.Int() > 0; + ((ConfigCellTextCheck) avatarBackgroundBlurRow).enabled = enabled; + ((ConfigCellTextCheck) avatarBackgroundDarkenRow).enabled = enabled; } //Custom dialogs diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/StickerSizePreviewMessagesCell.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/StickerSizePreviewMessagesCell.java index ebaff4f38..af605abd7 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/StickerSizePreviewMessagesCell.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/StickerSizePreviewMessagesCell.java @@ -25,7 +25,7 @@ import org.telegram.ui.Cells.ChatMessageCell; import org.telegram.ui.Components.BackgroundGradientDrawable; import org.telegram.ui.Components.LayoutHelper; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; @SuppressLint("ViewConstructor") public class StickerSizePreviewMessagesCell extends LinearLayout { @@ -94,7 +94,7 @@ public class StickerSizePreviewMessagesCell extends LinearLayout { message = new TLRPC.TL_message(); - message.message = NekomuraConfig.stickerSize.Float() < 9 ? LocaleController.getString("StickerSizeDialogMessageSmallOne", R.string.StickerSizeDialogMessageSmallOne) : LocaleController.getString("StickerSizeDialogMessageBigOne", R.string.StickerSizeDialogMessageBigOne); + message.message = NekoConfig.stickerSize.Float() < 9 ? LocaleController.getString("StickerSizeDialogMessageSmallOne", R.string.StickerSizeDialogMessageSmallOne) : LocaleController.getString("StickerSizeDialogMessageBigOne", R.string.StickerSizeDialogMessageBigOne); message.date = date + 1270; message.dialog_id = -1; message.flags = 259; @@ -124,7 +124,7 @@ public class StickerSizePreviewMessagesCell extends LinearLayout { super.invalidate(); for (int a = 0; a < cells.length; a++) { if (a == 1) { - messageObjects[a].messageOwner.message = NekomuraConfig.stickerSize.Float() < 9 ? LocaleController.getString("StickerSizeDialogMessageSmallOne", R.string.StickerSizeDialogMessageSmallOne) : LocaleController.getString("StickerSizeDialogMessageBigOne", R.string.StickerSizeDialogMessageBigOne); + messageObjects[a].messageOwner.message = NekoConfig.stickerSize.Float() < 9 ? LocaleController.getString("StickerSizeDialogMessageSmallOne", R.string.StickerSizeDialogMessageSmallOne) : LocaleController.getString("StickerSizeDialogMessageBigOne", R.string.StickerSizeDialogMessageBigOne); messageObjects[a].applyNewText(); messageObjects[a].resetLayout(); } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/shamsicalendar/PersianCalendar.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/shamsicalendar/PersianCalendar.java index f642a0533..9c8319ed7 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/shamsicalendar/PersianCalendar.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/shamsicalendar/PersianCalendar.java @@ -3,7 +3,7 @@ package tw.nekomimi.nekogram.shamsicalendar; import java.util.GregorianCalendar; import java.util.TimeZone; -import tw.nekomimi.nkmr.NekomuraConfig; +import tw.nekomimi.nekogram.NekoConfig; public class PersianCalendar extends GregorianCalendar { private static final long serialVersionUID = 5541422440580682494L; @@ -54,7 +54,7 @@ public class PersianCalendar extends GregorianCalendar { } public String getPersianYearName() { - if (NekomuraConfig.displayPersianCalendarByLatin.Bool()) { + if (NekoConfig.displayPersianCalendarByLatin.Bool()) { return getPersianYear() + ""; } else { return LanguageUtils.getPersianNumbers(String.valueOf(this.persianYear)); @@ -66,7 +66,7 @@ public class PersianCalendar extends GregorianCalendar { } public String getPersianMonthName() { - if (NekomuraConfig.displayPersianCalendarByLatin.Bool()) { + if (NekoConfig.displayPersianCalendarByLatin.Bool()) { return PersianCalendarConstants.persianMonthNamesLatin[this.persianMonth]; } else { return PersianCalendarConstants.persianMonthNames[this.persianMonth]; @@ -78,7 +78,7 @@ public class PersianCalendar extends GregorianCalendar { } public String getPersianDayName() { - if (NekomuraConfig.displayPersianCalendarByLatin.Bool()) { + if (NekoConfig.displayPersianCalendarByLatin.Bool()) { return getPersianDay() + ""; } else { return LanguageUtils.getPersianNumbers(String.valueOf(this.persianDay)); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/TranslateDb.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/TranslateDb.kt index 5c20956d1..788f88836 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/TranslateDb.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/TranslateDb.kt @@ -3,7 +3,7 @@ package tw.nekomimi.nekogram.transtale import org.dizitart.no2.objects.ObjectRepository import org.dizitart.no2.objects.filters.ObjectFilters import org.telegram.messenger.LocaleController -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import tw.nekomimi.nekogram.database.mkDatabase import tw.nekomimi.nekogram.utils.UIUtil import java.util.* @@ -51,14 +51,14 @@ class TranslateDb(val code: String) { } @JvmStatic - fun currentTarget() = NekomuraConfig.translateToLang.String()?.transDbByCode + fun currentTarget() = NekoConfig.translateToLang.String()?.transDbByCode ?: LocaleController.getInstance().currentLocale.transDb @JvmStatic fun forLocale(locale: Locale) = locale.transDb @JvmStatic - fun currentInputTarget() = NekomuraConfig.translateInputLang.String().transDbByCode + fun currentInputTarget() = NekoConfig.translateInputLang.String().transDbByCode @JvmStatic fun clearAll() { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/Translator.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/Translator.kt index 9cf2ccb67..a37a5be07 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/Translator.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/Translator.kt @@ -8,8 +8,8 @@ import org.apache.commons.lang3.LocaleUtils import org.telegram.messenger.LocaleController import org.telegram.messenger.R import org.telegram.messenger.SharedConfig -import tw.nekomimi.nkmr.NekomuraConfig -import tw.nekomimi.nekogram.PopupBuilder +import tw.nekomimi.nekogram.NekoConfig +import tw.nekomimi.nekogram.ui.PopupBuilder import tw.nekomimi.nekogram.cc.CCConverter import tw.nekomimi.nekogram.cc.CCTarget import tw.nekomimi.nekogram.transtale.source.* @@ -70,7 +70,8 @@ interface Translator { companion object { @Throws(Exception::class) - suspend fun translate(query: String) = translate(NekomuraConfig.translateToLang.String()?.code2Locale + suspend fun translate(query: String) = translate( + NekoConfig.translateToLang.String()?.code2Locale ?: LocaleController.getInstance().currentLocale, query) const val providerGoogle = 1 @@ -90,7 +91,7 @@ interface Translator { if (language == "in") language = "id" if (country.lowercase() == "duang") country = "CN" - val provider = NekomuraConfig.translationProvider.Int() + val provider = NekoConfig.translationProvider.Int() when (provider) { providerYouDao -> if (language == "zh") { language = "zh-CHS" @@ -243,7 +244,7 @@ interface Translator { @JvmStatic @JvmOverloads - fun translate(to: Locale = NekomuraConfig.translateToLang.String()?.code2Locale + fun translate(to: Locale = NekoConfig.translateToLang.String()?.code2Locale ?: LocaleController.getInstance().currentLocale, query: String, translateCallBack: TranslateCallBack) { UIUtil.runOnIoDispatcher { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleAppTranslator.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleAppTranslator.kt index 9e9664399..c9e1c3682 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleAppTranslator.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleAppTranslator.kt @@ -4,7 +4,7 @@ import cn.hutool.core.util.StrUtil import org.json.JSONObject import org.telegram.messenger.LocaleController import org.telegram.messenger.R -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import tw.nekomimi.nekogram.transtale.TransUtils import tw.nekomimi.nekogram.transtale.Translator import tw.nekomimi.nekogram.transtale.applyProxy @@ -14,7 +14,8 @@ object GoogleAppTranslator : Translator { override suspend fun doTranslate(from: String, to: String, query: String): String { - if (NekomuraConfig.translationProvider.Int() != 2 && StrUtil.isNotBlank(NekomuraConfig.googleCloudTranslateKey.String())) return GoogleCloudTranslator.doTranslate(from, to, query) + if (NekoConfig.translationProvider.Int() != 2 && StrUtil.isNotBlank( + NekoConfig.googleCloudTranslateKey.String())) return GoogleCloudTranslator.doTranslate(from, to, query) if (to !in targetLanguages) { @@ -22,7 +23,7 @@ object GoogleAppTranslator : Translator { } - val url = "https://translate.google." + (if (NekomuraConfig.translationProvider.Int() == 2) "cn" else "com") + "/translate_a/single?dj=1" + + val url = "https://translate.google." + (if (NekoConfig.translationProvider.Int() == 2) "cn" else "com") + "/translate_a/single?dj=1" + "&q=" + TransUtils.encodeURIComponent(query) + "&sl=auto" + "&tl=" + to + @@ -30,7 +31,7 @@ object GoogleAppTranslator : Translator { val response = cn.hutool.http.HttpUtil .createGet(url) - .applyIf(NekomuraConfig.translationProvider.Int() != 2) { applyProxy() } + .applyIf(NekoConfig.translationProvider.Int() != 2) { applyProxy() } .header("User-Agent", "GoogleTranslate/6.14.0.04.343003216 (Linux; U; Android 10; Redmi K20 Pro)") .execute() diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleCloudTranslator.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleCloudTranslator.kt index b7af2921d..620a2086b 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleCloudTranslator.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/transtale/source/GoogleCloudTranslator.kt @@ -5,7 +5,7 @@ import cn.hutool.http.HttpUtil import org.json.JSONObject import org.telegram.messenger.LocaleController import org.telegram.messenger.R -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import tw.nekomimi.nekogram.transtale.Translator object GoogleCloudTranslator : Translator { @@ -18,13 +18,13 @@ object GoogleCloudTranslator : Translator { } - if (StrUtil.isBlank(NekomuraConfig.googleCloudTranslateKey.String())) error("Missing Cloud Translate Key") + if (StrUtil.isBlank(NekoConfig.googleCloudTranslateKey.String())) error("Missing Cloud Translate Key") val response = HttpUtil.createPost("https://translation.googleapis.com/language/translate/v2") .form("q", query) .form("target", to) .form("format", "text") - .form("key", NekomuraConfig.googleCloudTranslateKey.String()) + .form("key", NekoConfig.googleCloudTranslateKey.String()) .apply { if (from != "auto") form("source", from) }.execute() diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt similarity index 99% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt index 146148f92..5a3a7a2f8 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/BottomBuilder.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/BottomBuilder.kt @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram +package tw.nekomimi.nekogram.ui import android.content.Context import android.text.TextUtils diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/EditTextAutoFill.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/EditTextAutoFill.java similarity index 94% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/EditTextAutoFill.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/EditTextAutoFill.java index 48214aa90..84eefbb41 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/EditTextAutoFill.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/EditTextAutoFill.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram; +package tw.nekomimi.nekogram.ui; import android.annotation.TargetApi; import android.content.Context; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalFilters.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/InternalFilters.java similarity index 99% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalFilters.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/InternalFilters.java index e9f5c8960..0688936ce 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalFilters.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/InternalFilters.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram; +package tw.nekomimi.nekogram.ui; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageDetailsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageDetailsActivity.java similarity index 99% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageDetailsActivity.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageDetailsActivity.java index 0a697230c..60d934c0f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageDetailsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageDetailsActivity.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram; +package tw.nekomimi.nekogram.ui; import android.annotation.SuppressLint; import android.content.Context; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java similarity index 99% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java index 92e23360e..200e9aae1 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/MessageHelper.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram; +package tw.nekomimi.nekogram.ui; import static tw.nekomimi.nekogram.utils.LangsKt.uDismiss; import static tw.nekomimi.nekogram.utils.LangsKt.uUpdate; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/PinnedStickerHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PinnedStickerHelper.java similarity index 99% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/PinnedStickerHelper.java rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PinnedStickerHelper.java index 43d4a42ae..b8f847f5f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/PinnedStickerHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PinnedStickerHelper.java @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram; +package tw.nekomimi.nekogram.ui; import org.apache.commons.lang3.StringUtils; import org.telegram.messenger.MessagesController; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/PopupBuilder.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PopupBuilder.kt similarity index 97% rename from TMessagesProj/src/main/java/tw/nekomimi/nekogram/PopupBuilder.kt rename to TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PopupBuilder.kt index fce5b2a42..90d71b7de 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/PopupBuilder.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/ui/PopupBuilder.kt @@ -1,4 +1,4 @@ -package tw.nekomimi.nekogram +package tw.nekomimi.nekogram.ui import android.annotation.SuppressLint import android.view.View diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/AlertUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/AlertUtil.kt index 9bb749fd1..32912f737 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/AlertUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/AlertUtil.kt @@ -13,9 +13,9 @@ import org.telegram.tgnet.TLRPC import org.telegram.ui.ActionBar.AlertDialog import org.telegram.ui.Components.EditTextBoldCursor import org.telegram.ui.Components.NumberPicker -import tw.nekomimi.nekogram.BottomBuilder -import tw.nekomimi.nekogram.PopupBuilder -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.ui.BottomBuilder +import tw.nekomimi.nekogram.ui.PopupBuilder +import tw.nekomimi.nekogram.NekoConfig import java.util.* import java.util.concurrent.atomic.AtomicReference @@ -252,7 +252,7 @@ object AlertUtil { reference.get().dismiss() - NekomuraConfig.translationProvider.setConfigInt(item + 1) + NekoConfig.translationProvider.setConfigInt(item + 1) retryRunnable.run() diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/DnsFactory.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/DnsFactory.kt index accfaa69e..7c7fb5e86 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/DnsFactory.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/DnsFactory.kt @@ -1,8 +1,5 @@ package tw.nekomimi.nekogram.utils -import android.util.Log -import cn.hutool.http.Header -import cn.hutool.http.HttpUtil import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.launch @@ -14,9 +11,8 @@ import okhttp3.RequestBody.Companion.toRequestBody import org.telegram.messenger.FileLog import org.telegram.tgnet.ConnectionsManager import org.xbill.DNS.* -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import java.net.InetAddress -import java.util.* import java.util.concurrent.atomic.AtomicInteger import kotlin.collections.ArrayList import kotlin.coroutines.resume @@ -24,7 +20,8 @@ import kotlin.coroutines.suspendCoroutine object DnsFactory { - fun providers() = if (NekomuraConfig.customDoH.String().isNotBlank()) arrayOf(NekomuraConfig.customDoH.String()) + fun providers() = if (NekoConfig.customDoH.String().isNotBlank()) arrayOf( + NekoConfig.customDoH.String()) else arrayOf( // behaviour: try all concurrently and stop when the first result returns. "https://1.1.1.1/dns-query", @@ -55,7 +52,7 @@ object DnsFactory { @JvmOverloads fun lookup(domain: String, fallback: Boolean = false): List { - if (!NekomuraConfig.useSystemDNS.Bool()) { + if (!NekoConfig.useSystemDNS.Bool()) { FileLog.d("Lookup $domain") @@ -64,7 +61,7 @@ object DnsFactory { val noFallback = !ConnectionsManager.hasIpv4 || !ConnectionsManager.hasIpv6 val type = if (noFallback) { if (ConnectionsManager.hasIpv4) Type.A else Type.AAAA - } else if (NekomuraConfig.useIPv6.Bool() xor !fallback) Type.A else Type.AAAA + } else if (NekoConfig.useIPv6.Bool() xor !fallback) Type.A else Type.AAAA val dc = DClass.IN val name = Name.fromConstantString("$domain.") diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt index 6135b39ac..28b9d65c0 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/EnvUtil.kt @@ -7,7 +7,7 @@ import android.os.storage.StorageManager import org.telegram.messenger.AndroidUtilities import org.telegram.messenger.ApplicationLoader import org.telegram.messenger.FileLog -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig import java.io.File import java.util.* @@ -50,12 +50,12 @@ object EnvUtil { @JvmStatic fun getTelegramPath(): File { - if (NekomuraConfig.cachePath.String() == "") { + if (NekoConfig.cachePath.String() == "") { // https://github.com/NekoX-Dev/NekoX/issues/284 - NekomuraConfig.cachePath.setConfigString(availableDirectories[2]); + NekoConfig.cachePath.setConfigString(availableDirectories[2]); } - var telegramPath = File(NekomuraConfig.cachePath.String()) + var telegramPath = File(NekoConfig.cachePath.String()) if (telegramPath.isDirectory || telegramPath.mkdirs()) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/FileUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/FileUtil.kt index bd0af2c3a..21aec6f2e 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/FileUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/FileUtil.kt @@ -10,6 +10,17 @@ import java.util.zip.ZipFile object FileUtil { + @JvmStatic + fun deleteDirectory(directoryToBeDeleted: File): Boolean { + val allContents = directoryToBeDeleted.listFiles() + if (allContents != null) { + for (file in allContents) { + deleteDirectory(file) + } + } + return directoryToBeDeleted.delete() + } + @JvmStatic fun initDir(dir: File) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt index b7014a9e7..8abce567f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/PGPUtil.kt @@ -5,7 +5,7 @@ import org.openintents.openpgp.util.OpenPgpApi import org.openintents.openpgp.util.OpenPgpServiceConnection import org.telegram.messenger.ApplicationLoader import org.telegram.messenger.FileLog -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig object PGPUtil { @@ -27,7 +27,7 @@ object PGPUtil { serviceConnection = OpenPgpServiceConnection( ApplicationLoader.applicationContext, - NekomuraConfig.openPGPApp.String() + NekoConfig.openPGPApp.String() ) diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/ProxyUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/ProxyUtil.kt index 41047c9d8..bd0458737 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/ProxyUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/ProxyUtil.kt @@ -43,7 +43,7 @@ import org.json.JSONException import org.telegram.messenger.* import org.telegram.messenger.browser.Browser import org.yaml.snakeyaml.Yaml -import tw.nekomimi.nekogram.BottomBuilder +import tw.nekomimi.nekogram.ui.BottomBuilder import tw.nekomimi.nekogram.proxy.ShadowsocksLoader import tw.nekomimi.nekogram.proxy.ShadowsocksRLoader import tw.nekomimi.nekogram.utils.AlertUtil.showToast diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StrUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StrUtil.kt index 5211e8772..e97040811 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StrUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/StrUtil.kt @@ -48,4 +48,24 @@ object StrUtil { textView.text = stringBuilder ?: text } + @JvmStatic + fun getSubString(text: String, left: String?, right: String?): String { + var llen: Int + if (left == null || left.isEmpty()) { + llen = 0 + } else { + llen = text.indexOf(left) + if (llen > -1) { + llen += left.length + } else { + llen = 0 + } + } + var rlen = text.indexOf(right!!, llen) + if (rlen < 0 || right.isEmpty()) { + rlen = text.length + } + return text.substring(llen, rlen) + } + } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/TelegramUtil.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/TelegramUtil.java new file mode 100644 index 000000000..c62ead1f7 --- /dev/null +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/TelegramUtil.java @@ -0,0 +1,47 @@ +package tw.nekomimi.nekogram.utils; + + +import org.telegram.messenger.MessageObject; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.zip.GZIPInputStream; + +public class TelegramUtil { + + public static String getFileNameWithoutEx(String filename) { + if ((filename != null) && (filename.length() > 0)) { + int dot = filename.lastIndexOf('.'); + if ((dot > -1) && (dot < (filename.length()))) { + return filename.substring(0, dot); + } + } + return filename; + } + + // 消息是否为文件 + public static boolean messageObjectIsFile(int type, MessageObject messageObject) { + boolean cansave = (type == 4 || type == 5 || type == 6 || type == 10); + boolean downloading = messageObject.loadedFileSize > 0; + + //图片的问题 + if (type == 4 && messageObject.getDocument() == null) { + return false; + } + return cansave || downloading; + } + + // 当文件有过加载过程,loadedFileSize > 0 ,所以不能用loadedFileSize判断是否正在下载 + public static boolean messageObjectIsDownloading(int type) { + boolean cansave = (type == 4 || type == 5 || type == 6 || type == 10); + return !cansave; + } + +} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/VibrateUtil.kt b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/VibrateUtil.kt index c00a5cd5d..3dd5793c0 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/VibrateUtil.kt +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/utils/VibrateUtil.kt @@ -8,7 +8,7 @@ import android.view.View import android.view.ViewGroup import androidx.core.view.children import org.telegram.messenger.ApplicationLoader -import tw.nekomimi.nkmr.NekomuraConfig +import tw.nekomimi.nekogram.NekoConfig object VibrateUtil { @@ -18,7 +18,7 @@ object VibrateUtil { @JvmOverloads fun vibrate(time: Long = 200L) { - if (NekomuraConfig.disableVibration.Bool()) return + if (NekoConfig.disableVibration.Bool()) return if (!::vibrator.isInitialized) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java b/TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java deleted file mode 100644 index 9f4fe2aeb..000000000 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/ConfigItem.java +++ /dev/null @@ -1,133 +0,0 @@ -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 SetInt() { - return (HashSet) value; - } - - public HashMap MapIntInt() { - return (HashMap) value; - } - - public boolean SetIntContains(Integer v) { - return ((HashSet) 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 v) { - value = v; - if (forceDefault) { - value = defaultValue; - } - saveConfig(this); - } - - public void setConfigMapInt(HashMap v) { - value = v; - saveConfig(this); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java deleted file mode 100644 index 5137749c6..000000000 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java +++ /dev/null @@ -1,530 +0,0 @@ -package tw.nekomimi.nkmr; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.Context; -import android.content.SharedPreferences; - -import cn.hutool.core.util.ArrayUtil; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.BuildVars; -import org.telegram.messenger.FileLog; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.ArrayList; -import android.util.Base64; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Set; - -import tw.nekomimi.nekogram.NekoConfig; -import tw.nekomimi.nekogram.NekoXConfig; - -@SuppressLint("ApplySharedPref") -public class NekomuraConfig { - private static final int configTypeBool = 0; - private static final int configTypeInt = 1; - private static final int configTypeString = 2; - private static final int configTypeSetInt = 3; - private static final int configTypeMapIntInt = 4; - private static final int configTypeLong = 5; - private static final int configTypeFloat = 6; - - private static boolean configLoaded; - private static final Object sync = new Object(); - private static final ArrayList configs = new ArrayList<>(); - - // Configs - public static ConfigItem migrate = addConfig("NekoConfigMigrate", configTypeBool, false); - public static ConfigItem largeAvatarInDrawer = addConfig("AvatarAsBackground", configTypeInt, 0); // 0:TG Default 1:NekoX Default 2:Large Avatar - public static ConfigItem unreadBadgeOnBackButton = addConfig("unreadBadgeOnBackButton", configTypeBool, false); - public static ConfigItem customPublicProxyIP = addConfig("customPublicProxyIP", configTypeString, ""); - public static ConfigItem update_download_soucre = addConfig("update_download_soucre", configTypeInt, 0); // 0: Github 1: Channel 2:CDNDrive, removed - public static ConfigItem useCustomEmoji = addConfig("useCustomEmoji", configTypeBool, false); - public static ConfigItem repeatConfirm = addConfig("repeatConfirm", configTypeBool, false); - public static ConfigItem disableInstantCamera = addConfig("DisableInstantCamera", configTypeBool, false); - public static ConfigItem showSeconds = addConfig("showSeconds", configTypeBool, false); - - public static ConfigItem enablePublicProxy = addConfig("enablePublicProxy", configTypeBool, true); - public static ConfigItem autoUpdateSubInfo = addConfig("autoUpdateSubInfo", configTypeBool, true); - - // From NekoConfig - public static ConfigItem useIPv6 = addConfig("IPv6", configTypeBool, false); - public static ConfigItem hidePhone = addConfig("HidePhone", configTypeBool, true); - public static ConfigItem ignoreBlocked = addConfig("IgnoreBlocked", configTypeBool, false); - public static ConfigItem tabletMode = addConfig("TabletMode", configTypeInt, 0); - public static ConfigItem inappCamera = addConfig("DebugMenuEnableCamera", configTypeBool, true); // fake - public static ConfigItem smoothKeyboard = addConfig("DebugMenuEnableSmoothKeyboard", configTypeBool, false);// fake - - public static ConfigItem typeface = addConfig("TypefaceUseDefault", configTypeBool, false); - public static ConfigItem nameOrder = addConfig("NameOrder", configTypeInt, 1); - public static ConfigItem mapPreviewProvider = addConfig("MapPreviewProvider", configTypeInt, 0); - public static ConfigItem transparentStatusBar = addConfig("TransparentStatusBar", configTypeBool, false); - public static ConfigItem hideProxySponsorChannel = addConfig("HideProxySponsorChannel", configTypeBool, false); - public static ConfigItem showAddToSavedMessages = addConfig("showAddToSavedMessages", configTypeBool, true); - public static ConfigItem showReport = addConfig("showReport", configTypeBool, true); - public static ConfigItem showViewHistory = addConfig("showViewHistory", configTypeBool, true); - public static ConfigItem showAdminActions = addConfig("showAdminActions", configTypeBool, true); - public static ConfigItem showChangePermissions = addConfig("showChangePermissions", configTypeBool, true); - public static ConfigItem showDeleteDownloadedFile = addConfig("showDeleteDownloadedFile", configTypeBool, true); - public static ConfigItem showMessageDetails = addConfig("showMessageDetails", configTypeBool, false); - public static ConfigItem showTranslate = addConfig("showTranslate", configTypeBool, true); - public static ConfigItem showRepeat = addConfig("showRepeat", configTypeBool, false); - public static ConfigItem showShareMessages = addConfig("showShareMessages", configTypeBool, false); - public static ConfigItem showMessageHide = addConfig("showMessageHide", configTypeBool, false); - - public static ConfigItem eventType = addConfig("eventType", configTypeInt, 0); - public static ConfigItem actionBarDecoration = addConfig("ActionBarDecoration", configTypeInt, 0); - public static ConfigItem newYear = addConfig("ChristmasHat", configTypeBool, false); - public static ConfigItem stickerSize = addConfig("stickerSize", configTypeFloat, 14.0f); - public static ConfigItem unlimitedFavedStickers = addConfig("UnlimitedFavoredStickers", configTypeBool, false); - public static ConfigItem unlimitedPinnedDialogs = addConfig("UnlimitedPinnedDialogs", configTypeBool, false); - public static ConfigItem translationProvider = addConfig("translationProvider", configTypeInt, 1); - public static ConfigItem disablePhotoSideAction = addConfig("DisablePhotoViewerSideAction", configTypeBool, true); - public static ConfigItem openArchiveOnPull = addConfig("OpenArchiveOnPull", configTypeBool, false); - public static ConfigItem hideKeyboardOnChatScroll = addConfig("HideKeyboardOnChatScroll", configTypeBool, false); - public static ConfigItem avatarBackgroundBlur = addConfig("BlurAvatarBackground", configTypeBool, false); - public static ConfigItem avatarBackgroundDarken = addConfig("DarkenAvatarBackground", configTypeBool, false); - public static ConfigItem useSystemEmoji = addConfig("EmojiUseDefault", configTypeBool, false); - public static ConfigItem showTabsOnForward = addConfig("ShowTabsOnForward", configTypeBool, false); - public static ConfigItem rearVideoMessages = addConfig("RearVideoMessages", configTypeBool, false); - public static ConfigItem hideAllTab = addConfig("HideAllTab", configTypeBool, false); - public static ConfigItem pressTitleToOpenAllChats = addConfig("pressTitleToOpenAllChats", configTypeBool, false); - - public static ConfigItem disableChatAction = addConfig("DisableChatAction", configTypeBool, false); - public static ConfigItem sortByUnread = addConfig("sort_by_unread", configTypeBool, false); - public static ConfigItem sortByUnmuted = addConfig("sort_by_unmuted", configTypeBool, true); - public static ConfigItem sortByUser = addConfig("sort_by_user", configTypeBool, true); - public static ConfigItem sortByContacts = addConfig("sort_by_contacts", configTypeBool, true); - - public static ConfigItem disableUndo = addConfig("DisableUndo", configTypeBool, false); - - public static ConfigItem filterUsers = addConfig("filter_users", configTypeBool, true); - public static ConfigItem filterContacts = addConfig("filter_contacts", configTypeBool, true); - public static ConfigItem filterGroups = addConfig("filter_groups", configTypeBool, true); - public static ConfigItem filterChannels = addConfig("filter_channels", configTypeBool, true); - public static ConfigItem filterBots = addConfig("filter_bots", configTypeBool, true); - public static ConfigItem filterAdmins = addConfig("filter_admins", configTypeBool, true); - public static ConfigItem filterUnmuted = addConfig("filter_unmuted", configTypeBool, true); - public static ConfigItem filterUnread = addConfig("filter_unread", configTypeBool, true); - public static ConfigItem filterUnmutedAndUnread = addConfig("filter_unmuted_and_unread", configTypeBool, true); - - public static ConfigItem disableSystemAccount = addConfig("DisableSystemAccount", configTypeBool, false); -// public static ConfigItem disableProxyWhenVpnEnabled = addConfig("DisableProxyWhenVpnEnabled", configTypeBool, false); - public static ConfigItem skipOpenLinkConfirm = addConfig("SkipOpenLinkConfirm", configTypeBool, false); - - public static ConfigItem ignoreMutedCount = addConfig("IgnoreMutedCount", configTypeBool, true); - public static ConfigItem useDefaultTheme = addConfig("UseDefaultTheme", configTypeBool, false); - public static ConfigItem showIdAndDc = addConfig("ShowIdAndDc", configTypeBool, false); - - public static ConfigItem googleCloudTranslateKey = addConfig("GoogleCloudTransKey", configTypeString, ""); - public static ConfigItem cachePath = addConfig("cache_path", configTypeString, ""); - - public static ConfigItem translateToLang = addConfig("TransToLang", configTypeString, ""); // "" -> translate to current language (MessageTrans.kt & Translator.kt) - public static ConfigItem translateInputLang = addConfig("TransInputToLang", configTypeString, "en"); - - 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, 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); - - public static ConfigItem useSystemDNS = addConfig("useSystemDNS", configTypeBool, false); - public static ConfigItem customDoH = addConfig("customDoH", configTypeString, ""); - public static ConfigItem hideProxyByDefault = addConfig("HideProxyByDefault", configTypeBool, false); - public static ConfigItem useProxyItem = addConfig("UseProxyItem", configTypeBool, true); - - public static ConfigItem disableAppBarShadow = addConfig("DisableAppBarShadow", configTypeBool, false); - public static ConfigItem mediaPreview = addConfig("MediaPreview", configTypeBool, true); - - public static ConfigItem proxyAutoSwitch = addConfig("ProxyAutoSwitch", configTypeBool, false); - - public static ConfigItem usePersianCalendar = addConfig("UsePersiancalendar", configTypeBool, false); - public static ConfigItem displayPersianCalendarByLatin = addConfig("DisplayPersianCalendarByLatin", configTypeBool, false); - public static ConfigItem openPGPApp = addConfig("OpenPGPApp", configTypeString, ""); - public static ConfigItem openPGPKeyId = addConfig("OpenPGPKey", configTypeLong, 0L); - - public static ConfigItem disableVibration = addConfig("DisableVibration", configTypeBool, false); - public static ConfigItem autoPauseVideo = addConfig("AutoPauseVideo", configTypeBool, false); - public static ConfigItem disableProximityEvents = addConfig("DisableProximityEvents", configTypeBool, false); - - public static ConfigItem ignoreContentRestrictions = addConfig("ignoreContentRestrictions", configTypeBool, !BuildVars.isPlay); - public static ConfigItem useChatAttachMediaMenu = addConfig("UseChatAttachEnterMenu", configTypeBool, true); - public static ConfigItem disableLinkPreviewByDefault = addConfig("DisableLinkPreviewByDefault", configTypeBool, false); - public static ConfigItem sendCommentAfterForward = addConfig("SendCommentAfterForward", configTypeBool, true); - public static ConfigItem increaseVoiceMessageQuality = addConfig("IncreaseVoiceMessageQuality", configTypeBool, true); - public static ConfigItem disableTrending = addConfig("DisableTrending", configTypeBool, true); - public static ConfigItem dontSendGreetingSticker = addConfig("DontSendGreetingSticker", configTypeBool, false); - public static ConfigItem hideTimeForSticker = addConfig("HideTimeForSticker", configTypeBool, false); - public static ConfigItem takeGIFasVideo = addConfig("TakeGIFasVideo", configTypeBool, false); - public static ConfigItem maxRecentStickerCount = addConfig("maxRecentStickerCount", configTypeInt, 20); - public static ConfigItem disableSwipeToNext = addConfig("disableSwipeToNextChannel", configTypeBool, true); - public static ConfigItem disableRemoteEmojiInteractions = addConfig("disableRemoteEmojiInteractions", configTypeBool, true); - public static ConfigItem disableChoosingSticker = addConfig("disableChoosingSticker", configTypeBool, false); - public static ConfigItem hideGroupSticker = addConfig("hideGroupSticker", configTypeBool, false); - public static ConfigItem hideSponsoredMessage = addConfig("hideSponsoredMessage", configTypeBool, false); - public static ConfigItem rememberAllBackMessages = addConfig("rememberAllBackMessages", configTypeBool, false); - public static ConfigItem hideSendAsChannel = addConfig("hideSendAsChannel", configTypeBool, false); - - public static ConfigItem disableAutoDownloadingWin32Executable = addConfig("Win32ExecutableFiles", configTypeBool, true); - public static ConfigItem disableAutoDownloadingArchive = addConfig("ArchiveFiles", configTypeBool, true); - - public static ConfigItem enableStickerPin = addConfig("EnableStickerPin", configTypeBool, false); - public static ConfigItem useMediaStreamInVoip = addConfig("UseMediaStreamInVoip", configTypeBool, false); - public static ConfigItem customAudioBitrate = addConfig("customAudioBitrate", configTypeInt, 32); - public static ConfigItem disableGroupVoipAudioProcessing = addConfig("disableGroupVoipAudioProcessing", configTypeBool, false); - - static { - loadConfig(false); - checkMigrage(false); - } - - public static ConfigItem addConfig(String k, int t, Object d) { - ConfigItem a = new ConfigItem(k, t, d); - configs.add(a); - return a; - } - - public static ConfigItem findOne(String key) { - for (int i = 0; i < configs.size(); i++) { - ConfigItem o = configs.get(i); - if (key.equals(o.key)) { - return o; - } - } - return null; - } - - public static void loadConfig(boolean force) { - synchronized (sync) { - if (configLoaded && !force) { - return; - } - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nkmrcfg", Activity.MODE_PRIVATE); - for (int i = 0; i < configs.size(); i++) { - ConfigItem o = configs.get(i); - - if (o.forceDefault) { - o.value = o.defaultValue; - continue; - } - - if (o.type == configTypeBool) { - o.value = preferences.getBoolean(o.key, (boolean) o.defaultValue); - } - if (o.type == configTypeInt) { - o.value = preferences.getInt(o.key, (int) o.defaultValue); - } - if (o.type == configTypeLong) { - o.value = preferences.getLong(o.key, (Long) o.defaultValue); - } - if (o.type == configTypeFloat) { - o.value = preferences.getFloat(o.key, (Float) o.defaultValue); - } - if (o.type == configTypeString) { - o.value = preferences.getString(o.key, (String) o.defaultValue); - } - if (o.type == configTypeSetInt) { - Set ss = preferences.getStringSet(o.key, new HashSet<>()); - HashSet si = new HashSet<>(); - for (String s : ss) { - si.add(Integer.parseInt(s)); - } - o.value = si; - } - if (o.type == configTypeMapIntInt) { - String cv = preferences.getString(o.key, ""); - // Log.e("NC", String.format("Getting pref %s val %s", o.key, cv)); - if (cv.length() == 0) { - o.value = new HashMap(); - } else { - try { - byte[] data = Base64.decode(cv, Base64.DEFAULT); - ObjectInputStream ois = new ObjectInputStream( - new ByteArrayInputStream(data)); - o.value = (HashMap) ois.readObject(); - if (o.value == null) { - o.value = new HashMap(); - } - ois.close(); - } catch (Exception e) { - o.value = new HashMap(); - } - } - } - } - configLoaded = true; - } - } - - // save one item - public static void saveConfig(ConfigItem item) { - synchronized (sync) { - try { - if (item == null) return; - - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nkmrcfg", Context.MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - - if (item.type == configTypeBool) { - editor.putBoolean(item.key, (boolean) item.value); - } - if (item.type == configTypeInt) { - editor.putInt(item.key, (int) item.value); - } - if (item.type == configTypeLong) { - editor.putLong(item.key, (Long) item.value); - } - if (item.type == configTypeFloat) { - editor.putFloat(item.key, (Float) item.value); - } - if (item.type == configTypeString) { - editor.putString(item.key, item.value.toString()); - } - if (item.type == configTypeSetInt) { - HashSet ss = new HashSet<>(); - for (Integer n : (Set) item.value) { - ss.add(Integer.toString(n)); - } - editor.putStringSet(item.key, ss); - } - if (item.type == configTypeMapIntInt) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(item.value); - oos.close(); - editor.putString(item.key, Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT)); - } - - editor.commit(); - } catch (Exception e) { - FileLog.e(e); - } - } - } - - 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("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("showShareMessages")) - showShareMessages.setConfigBool(preferences.getBoolean("showShareMessages", 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("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("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)); - } -} \ No newline at end of file diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraUtil.java b/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraUtil.java deleted file mode 100644 index 4b080613b..000000000 --- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraUtil.java +++ /dev/null @@ -1,179 +0,0 @@ -package tw.nekomimi.nkmr; - - -import org.telegram.messenger.MessageObject; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.zip.GZIPInputStream; - -public class NekomuraUtil { - /* - * Java文件操作 获取不带扩展名的文件名 - * - * Created on: 2011-8-2 - * Author: blueeagle - */ - public static String getFileNameNoEx(String filename) { - if ((filename != null) && (filename.length() > 0)) { - int dot = filename.lastIndexOf('.'); - if ((dot > -1) && (dot < (filename.length()))) { - return filename.substring(0, dot); - } - } - return filename; - } - - // 消息是否为文件 - public static boolean messageObjectIsFile(int type, MessageObject messageObject) { - boolean cansave = (type == 4 || type == 5 || type == 6 || type == 10); - boolean downloading = messageObject.loadedFileSize > 0; - - //图片的问题 - if (type == 4 && messageObject.getDocument() == null) { - return false; - } - return cansave || downloading; - } - - // 当文件有过加载过程,loadedFileSize > 0 ,所以不能用loadedFileSize判断是否正在下载 - public static boolean messageObjectIsDownloading(int type) { - boolean cansave = (type == 4 || type == 5 || type == 6 || type == 10); - return !cansave; - } - - // 取出整数的(二进制)某一位 - public static boolean getBit(int value, int i) { - int mask = 1 << i; - int ii = value & mask; - if (ii == 0) { - return false; - } else { - return true; - } - } - - public static int setBit(int value, int i, boolean v) { - int mask = 1 << i; - if (v) { - value |= mask; - } else { - value &= ~mask; - } - return value; - } - - public static int reverseBit(int value, int i) { - int mask = 1 << i; - return value ^ mask; - } - - /** - * 取两个文本之间的文本值 - * - * @param text 源文本 比如:欲取全文本为 12345 - * @param left 文本前面 - * @param right 后面文本 - * @return 返回 String - */ - public static String getSubString(String text, String left, String right) { - String result = ""; - int zLen; - if (left == null || left.isEmpty()) { - zLen = 0; - } else { - zLen = text.indexOf(left); - if (zLen > -1) { - zLen += left.length(); - } else { - zLen = 0; - } - } - int yLen = text.indexOf(right, zLen); - if (yLen < 0 || right == null || right.isEmpty()) { - yLen = text.length(); - } - result = text.substring(zLen, yLen); - return result; - } - - private static String convertToHex(byte[] data) { - StringBuilder buf = new StringBuilder(); - for (byte b : data) { - int halfbyte = (b >>> 4) & 0x0F; - int two_halfs = 0; - do { - buf.append((0 <= halfbyte) && (halfbyte <= 9) ? (char) ('0' + halfbyte) : (char) ('a' + (halfbyte - 10))); - halfbyte = b & 0x0F; - } while (two_halfs++ < 1); - } - return buf.toString(); - } - - - /** - * Read the file and calculate the SHA-1 checksum - * - * @param file the file to read - * @return the hex representation of the SHA-1 using uppercase chars - * @throws FileNotFoundException if the file does not exist, is a directory rather than a - * regular file, or for some other reason cannot be opened for - * reading - * @throws IOException if an I/O error occurs - * @throws NoSuchAlgorithmException should never happen - */ - public static String calcSHA1(File file) throws FileNotFoundException, - IOException, NoSuchAlgorithmException { - - MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); - try (InputStream input = new FileInputStream(file)) { - - byte[] buffer = new byte[8192]; - int len = input.read(buffer); - - while (len != -1) { - sha1.update(buffer, 0, len); - len = input.read(buffer); - } - - return convertToHex(sha1.digest()); - } - } - - public static byte[] uncompress(byte[] bytes) { - if (bytes == null || bytes.length == 0) { - return null; - } - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ByteArrayInputStream in = new ByteArrayInputStream(bytes); - try { - GZIPInputStream ungzip = new GZIPInputStream(in); - byte[] buffer = new byte[256]; - int n; - while ((n = ungzip.read(buffer)) >= 0) { - out.write(buffer, 0, n); - } - } catch (Exception e) { - e.printStackTrace(); - } - return out.toByteArray(); - } - - public static boolean deleteDirectory(File directoryToBeDeleted) { - File[] allContents = directoryToBeDeleted.listFiles(); - if (allContents != null) { - for (File file : allContents) { - deleteDirectory(file); - } - } - return directoryToBeDeleted.delete(); - } - -} \ No newline at end of file