From a5c29444a719aabd76219c37d10312d64231ba52 Mon Sep 17 00:00:00 2001
From: arm64v8a <48624112+arm64v8a@users.noreply.github.com>
Date: Thu, 18 Nov 2021 22:59:41 +0800
Subject: [PATCH] Allow disable instant camera
---
.../ui/Components/ChatAttachAlertPhotoLayout.java | 14 +++++++++++---
.../settings/NekoGeneralSettingsActivity.java | 2 ++
.../main/java/tw/nekomimi/nkmr/NekomuraConfig.java | 3 ++-
.../src/main/res/values-zh-rCN/strings_nekox.xml | 1 +
.../src/main/res/values/strings_nekox.xml | 3 ++-
5 files changed, 18 insertions(+), 5 deletions(-)
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 c18e85807..2bad86dd8 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayout.java
@@ -617,7 +617,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}
return;
- } else if (noGalleryPermissions) {
+ } else if (noGalleryPermissions && position != 0) {
try {
if (NekoConfig.forceSystemPicker) {
menu.onItemClick(open_in); // Use system photo picker
@@ -662,6 +662,9 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
PhotoViewer.getInstance().setCaption(parentAlert.getCommentTextView().getText());
} else {
if (SharedConfig.inappCamera) {
+ if (NekomuraConfig.disableInstantCamera.Bool()) {
+ showCamera();
+ }
openCamera(true);
} else {
if (parentAlert.delegate != null) {
@@ -1620,10 +1623,15 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
deviceHasGoodCamera = CameraController.getInstance().isCameraInitied();
}
}
+ if (deviceHasGoodCamera && NekomuraConfig.disableInstantCamera.Bool()) {
+ // Clear cached bitmap
+ File file = new File(ApplicationLoader.getFilesDirFixed(), "cthumb.jpg");
+ if (file.exists()) file.delete();
+ }
if ((old != deviceHasGoodCamera || old2 != noCameraPermissions) && adapter != null) {
adapter.notifyDataSetChanged();
}
- if (parentAlert.isShowing() && deviceHasGoodCamera && parentAlert.baseFragment != null && parentAlert.getBackDrawable().getAlpha() != 0 && !cameraOpened) {
+ if (parentAlert.isShowing() && deviceHasGoodCamera && parentAlert.baseFragment != null && parentAlert.getBackDrawable().getAlpha() != 0 && !cameraOpened && !NekomuraConfig.disableInstantCamera.Bool()) {
showCamera();
}
}
@@ -1912,7 +1920,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}
private void saveLastCameraBitmap() {
- if (!canSaveCameraPreview) {
+ if (!canSaveCameraPreview || NekomuraConfig.disableInstantCamera.Bool()) {
return;
}
try {
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 5dce339d3..056d57bb3 100644
--- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java
@@ -149,6 +149,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
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));
@@ -313,6 +314,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment {
}
} else if (key.equals(NekomuraConfig.inappCamera.getKey())) {
SharedConfig.setInappCamera((boolean) newValue);
+ restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
} else if (key.equals(NekomuraConfig.hidePhone.getKey())) {
parentLayout.rebuildAllFragmentViews(false, false);
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged);
diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java
index f5b5d79bc..31478af27 100644
--- a/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java
+++ b/TMessagesProj/src/main/java/tw/nekomimi/nkmr/NekomuraConfig.java
@@ -45,13 +45,14 @@ public class NekomuraConfig {
public static ConfigItem update_download_soucre = addConfig("update_download_soucre", configTypeInt, 0); // 0: Github 1: Channel 2:CDNDrive
public static ConfigItem useCustomEmoji = addConfig("useCustomEmoji", configTypeBool, false);
public static ConfigItem repeatConfirm = addConfig("repeatConfirm", configTypeBool, false);
+ public static ConfigItem disableInstantCamera = addConfig("DisableInstantCamera", configTypeBool, false);
// 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, false); // fake
+ 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);
diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_nekox.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_nekox.xml
index b56e35059..72cbbd374 100644
--- a/TMessagesProj/src/main/res/values-zh-rCN/strings_nekox.xml
+++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_nekox.xml
@@ -266,4 +266,5 @@
\n使用头像作为背景
\n使用大只头像作为背景
隐藏赞助消息
+ 禁用相机即时预览
\ No newline at end of file
diff --git a/TMessagesProj/src/main/res/values/strings_nekox.xml b/TMessagesProj/src/main/res/values/strings_nekox.xml
index e7445d4e2..9765f39af 100644
--- a/TMessagesProj/src/main/res/values/strings_nekox.xml
+++ b/TMessagesProj/src/main/res/values/strings_nekox.xml
@@ -258,8 +258,9 @@
Not a vaild emoji zip.
Ask before repeat
Are you sure to repeat?
-
Telegram Default\nAvatar as background\nBig avatar as background
Hide sponsored messages
Remember all clicked replies
+ Disable instant camera
+
\ No newline at end of file