From 36925e628236451e37f7ca7cce4c9ee0d8427099 Mon Sep 17 00:00:00 2001 From: NekoInverter <42698724+NekoInverter@users.noreply.github.com> Date: Fri, 17 Apr 2020 10:38:01 +0800 Subject: [PATCH] Added setting to set default camera for Video Messages close #41 --- .../telegram/ui/Components/InstantCameraView.java | 4 +++- .../main/java/tw/nekomimi/nekogram/NekoConfig.java | 11 +++++++++++ .../tw/nekomimi/nekogram/NekoSettingsActivity.java | 13 +++++++++++-- TMessagesProj/src/main/res/values/strings_neko.xml | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) 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 c6d7aa7f6..e2384adc5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java @@ -103,6 +103,8 @@ import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.egl.EGLSurface; import javax.microedition.khronos.opengles.GL; +import tw.nekomimi.nekogram.NekoConfig; + @TargetApi(18) public class InstantCameraView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { @@ -486,7 +488,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter textureOverlayView.setImageResource(R.drawable.icplaceholder); } cameraReady = false; - isFrontface = true; + isFrontface = !NekoConfig.rearVideoMessages; selectedCamera = null; recordedTime = 0; progress = 0; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index 3f43117a6..c28f108ec 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -26,6 +26,7 @@ public class NekoConfig { public static boolean disablePhotoSideAction = true; public static boolean hideKeyboardOnChatScroll = false; public static boolean chatMessageAnimation = false; + public static boolean rearVideoMessages = false; public static int mapPreviewProvider = 0; public static float stickerSize = 14.0f; public static int translationProvider = 1; @@ -97,6 +98,7 @@ public class NekoConfig { editor.putBoolean("useSystemEmoji", useSystemEmoji); editor.putBoolean("showTabsOnForward", showTabsOnForward); editor.putBoolean("chatMessageAnimation", chatMessageAnimation); + editor.putBoolean("rearVideoMessages", rearVideoMessages); editor.putFloat("stickerSize", stickerSize); editor.putInt("typeface", typeface); editor.putInt("nameOrder", nameOrder); @@ -154,6 +156,7 @@ public class NekoConfig { useSystemEmoji = preferences.getBoolean("useSystemEmoji", SharedConfig.useSystemEmoji); showTabsOnForward = preferences.getBoolean("showTabsOnForward", false); chatMessageAnimation = preferences.getBoolean("chatMessageAnimation", false); + rearVideoMessages = preferences.getBoolean("rearVideoMessages", false); configLoaded = true; } } @@ -448,4 +451,12 @@ public class NekoConfig { editor.putBoolean("chatMessageAnimation", chatMessageAnimation); editor.commit(); } + + public static void toggleRearVideoMessages() { + rearVideoMessages = !rearVideoMessages; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("rearVideoMessages", rearVideoMessages); + 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 44bd475c7..6cbceeb1c 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoSettingsActivity.java @@ -79,6 +79,7 @@ public class NekoSettingsActivity extends BaseFragment { private int pauseMusicOnRecordRow; private int disablePhotoSideActionRow; private int hideKeyboardOnChatScrollRow; + private int rearVideoMessagesRow; private int mapPreviewRow; private int stickerSizeRow; private int translationProviderRow; @@ -524,6 +525,11 @@ public class NekoSettingsActivity extends BaseFragment { if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(NekoConfig.chatMessageAnimation); } + } else if (position == rearVideoMessagesRow) { + NekoConfig.toggleRearVideoMessages(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(NekoConfig.rearVideoMessages); + } } }); @@ -554,6 +560,7 @@ public class NekoSettingsActivity extends BaseFragment { pauseMusicOnRecordRow = rowCount++; disablePhotoSideActionRow = rowCount++; hideKeyboardOnChatScrollRow = rowCount++; + rearVideoMessagesRow = rowCount++; mapPreviewRow = rowCount++; stickerSizeRow = rowCount++; messageMenuRow = rowCount++; @@ -1063,6 +1070,8 @@ public class NekoSettingsActivity extends BaseFragment { textCell.setTextAndCheck(LocaleController.getString("ShowTabsOnForward", R.string.ShowTabsOnForward), NekoConfig.showTabsOnForward, true); } else if (position == chatMessageAnimationRow) { textCell.setTextAndCheck(LocaleController.getString("ChatMessageAnimation", R.string.ChatMessageAnimation), NekoConfig.chatMessageAnimation, true); + } else if (position == rearVideoMessagesRow) { + textCell.setTextAndCheck(LocaleController.getString("RearVideoMessages", R.string.RearVideoMessages), NekoConfig.rearVideoMessages, true); } break; } @@ -1102,7 +1111,7 @@ public class NekoSettingsActivity extends BaseFragment { position == translationProviderRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || position == experimentRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow || - position == showTabsOnForwardRow || position == chatMessageAnimationRow; + position == showTabsOnForwardRow || position == chatMessageAnimationRow || position == rearVideoMessagesRow; } @Override @@ -1157,7 +1166,7 @@ public class NekoSettingsActivity extends BaseFragment { position == disableFilteringRow || position == smoothKeyboardRow || position == pauseMusicOnRecordRow || position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow || position == showTabsOnForwardRow || - position == chatMessageAnimationRow) { + position == chatMessageAnimationRow || position == rearVideoMessagesRow) { 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 915752466..c81347abc 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -89,4 +89,5 @@ Add administrated DeepL Translator (Web) Animate new messages + Rear camera in Video Messages \ No newline at end of file