From 7fa3f8e08e6cb5e0755392871c378c83e77d36f0 Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Mon, 17 Feb 2020 22:02:50 +0800 Subject: [PATCH] Allow disable photo viewer side action --- .../main/java/org/telegram/ui/PhotoViewer.java | 8 +++++--- .../java/tw/nekomimi/nekogram/NekoConfig.java | 11 +++++++++++ .../nekomimi/nekogram/NekoSettingsActivity.java | 15 +++++++++++++-- .../src/main/res/values/strings_neko.xml | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 9eb21b305..58f91d5d1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -180,6 +180,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Locale; +import tw.nekomimi.nekogram.NekoConfig; + @SuppressWarnings("unchecked") public class PhotoViewer implements NotificationCenter.NotificationCenterDelegate, GestureDetector2.OnGestureListener, GestureDetector2.OnDoubleTapListener { @@ -8830,7 +8832,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 = containerView.getMeasuredWidth() / 6; + int side = NekoConfig.disablePhotoSideAction ? 0 : containerView.getMeasuredWidth() / 6; if (x < side) { if (leftImage.hasImageSet()) { drawPressedDrawable[0] = true; @@ -8850,7 +8852,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 = containerView.getMeasuredWidth() / 6; + int side = NekoConfig.disablePhotoSideAction ? 0 : containerView.getMeasuredWidth() / 6; if (x < side || x > containerView.getMeasuredWidth() - side) { return currentMessageObject == null || currentMessageObject.isVideo() && (SystemClock.elapsedRealtime() - lastPhotoSetTime) >= 500; } @@ -8908,7 +8910,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } float x = e.getX(); if (checkImageView.getVisibility() != View.VISIBLE) { - int side = containerView.getMeasuredWidth() / 6; + int side = NekoConfig.disablePhotoSideAction ? 0 : containerView.getMeasuredWidth() / 6; if (x < side) { if (leftImage.hasImageSet()) { switchToNextIndex(-1, true); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index 1d7fbe5ae..9bd62e0cb 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -25,6 +25,7 @@ public class NekoConfig { public static boolean saveCacheToPrivateDirectory = Build.VERSION.SDK_INT >= 24; public static float stickerSize = 14.0f; public static boolean unlimitedFavedStickers = false; + public static boolean disablePhotoSideAction = true; public static boolean showAddToSavedMessages = true; public static boolean showReport = false; @@ -79,6 +80,7 @@ public class NekoConfig { editor.putBoolean("newYear", newYear); editor.putFloat("stickerSize", stickerSize); editor.putBoolean("unlimitedFavedStickers", unlimitedFavedStickers); + editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction); editor.putInt("translationProvider", translationProvider); editor.putInt("eventType", eventType); editor.putInt("actionBarDecoration", actionBarDecoration); @@ -124,6 +126,7 @@ public class NekoConfig { stickerSize = preferences.getFloat("stickerSize", 14.0f); unlimitedFavedStickers = preferences.getBoolean("unlimitedFavedStickers", false); translationProvider = preferences.getInt("translationProvider", 1); + disablePhotoSideAction = preferences.getBoolean("disablePhotoSideAction", true); configLoaded = true; } } @@ -351,4 +354,12 @@ public class NekoConfig { editor.commit(); } + public static void toggleDisablePhotoSideAction() { + disablePhotoSideAction = !disablePhotoSideAction; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("disablePhotoSideAction", disablePhotoSideAction); + editor.commit(); + } + } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java index e2a059dfd..44cf953a1 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java @@ -78,6 +78,7 @@ public class NekoSettingsActivity extends BaseFragment { private int hideProxySponsorChannelRow; private int saveCacheToPrivateDirectoryRow; private int pauseMusicOnRecordRow; + private int disablePhotoSideActionRow; private int mapPreviewRow; private int stickerSizeRow; private int translationProviderRow; @@ -488,6 +489,11 @@ public class NekoSettingsActivity extends BaseFragment { if (SharedConfig.smoothKeyboard && getParentActivity() != null) { getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); } + } else if (position == disablePhotoSideActionRow) { + NekoConfig.toggleDisablePhotoSideAction(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(NekoConfig.disablePhotoSideAction); + } } }); @@ -516,6 +522,7 @@ public class NekoSettingsActivity extends BaseFragment { hideProxySponsorChannelRow = rowCount++; saveCacheToPrivateDirectoryRow = Build.VERSION.SDK_INT >= 24 ? rowCount++ : -1; pauseMusicOnRecordRow = rowCount++; + disablePhotoSideActionRow = rowCount++; mapPreviewRow = rowCount++; stickerSizeRow = rowCount++; messageMenuRow = rowCount++; @@ -1003,6 +1010,8 @@ public class NekoSettingsActivity extends BaseFragment { textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), SharedConfig.pauseMusicOnRecord, true); } else if (position == smoothKeyboardRow) { textCell.setTextAndCheck(LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard), SharedConfig.smoothKeyboard, true); + } else if (position == disablePhotoSideActionRow) { + textCell.setTextAndCheck(LocaleController.getString("DisablePhotoViewerSideAction", R.string.DisablePhotoViewerSideAction), NekoConfig.disablePhotoSideAction, true); } break; } @@ -1039,7 +1048,8 @@ public class NekoSettingsActivity extends BaseFragment { position == hideProxySponsorChannelRow || position == saveCacheToPrivateDirectoryRow || (position == disableFilteringRow && sensitiveCanChange) || position == stickerSizeRow || position == unlimitedFavedStickersRow || position == messageMenuRow || position == deleteAccountRow || - position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow; + position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || + position == disablePhotoSideActionRow; } @Override @@ -1090,7 +1100,8 @@ public class NekoSettingsActivity extends BaseFragment { position == ignoreBlockedRow || position == useSystemEmojiRow || position == typefaceRow || position == forceTabletRow || position == newYearRow || position == saveCacheToPrivateDirectoryRow || position == unlimitedFavedStickersRow || - position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow) { + position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || + position == disablePhotoSideActionRow) { return 3; } else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) { return 4; diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml index 2945b4fb1..9c1816ceb 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -82,5 +82,6 @@ Lingocloud Undo translate Copy Details + Disable photo viewer side action Token \ No newline at end of file