1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-03 13:10:32 +01:00

Allow disable photo viewer side action

This commit is contained in:
NekoInverter 2020-02-17 22:02:50 +08:00
parent 1806b30b35
commit 7fa3f8e08e
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
4 changed files with 30 additions and 5 deletions

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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;

View File

@ -82,5 +82,6 @@
<string name="ProviderLingocloud">Lingocloud</string>
<string name="UndoTranslate">Undo translate</string>
<string name="CopyDetails">Copy Details</string>
<string name="DisablePhotoViewerSideAction">Disable photo viewer side action</string>
<string name="BotToken">Token</string>
</resources>