Add "Disable instant camera"

Co-Authored-By: Vladislav Opolev <83278286+itsreallyv1eds@users.noreply.github.com>
This commit is contained in:
Ivan K
2022-03-19 11:59:39 +03:00
parent 26baea583c
commit abe1074655
4 changed files with 29 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ public class ExteraConfig {
public static boolean dateOfForwardedMsg;
public static boolean rearVideoMessages;
public static boolean disableCamera;
public static boolean pauseOnMinimize;
public static boolean disablePlayback;
@@ -78,6 +79,7 @@ public class ExteraConfig {
dateOfForwardedMsg = preferences.getBoolean("dateOfForwardedMsg", false);
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
disableCamera = preferences.getBoolean("disableCamera", false);
pauseOnMinimize = preferences.getBoolean("pauseOnMinimize", true);
disablePlayback = preferences.getBoolean("disablePlayback", true);
@@ -208,6 +210,14 @@ public class ExteraConfig {
editor.commit();
}
public static void toggleDisableCamera() {
disableCamera = !disableCamera;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("exteraconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("disableCamera", disableCamera);
editor.commit();
}
public static void togglePauseOnMinimize() {
pauseOnMinimize = !pauseOnMinimize;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("exteraconfig", Activity.MODE_PRIVATE);

View File

@@ -36,6 +36,9 @@ import org.telegram.ui.Components.SeekBarView;
import org.telegram.ui.Components.UndoView;
import com.exteragram.messenger.ExteraConfig;
import com.google.android.gms.vision.text.Text;
import java.util.Locale;
public class ChatsPreferencesEntry extends BaseFragment {
@@ -59,6 +62,7 @@ public class ChatsPreferencesEntry extends BaseFragment {
private int mediaHeaderRow;
private int rearVideoMessagesRow;
private int disableCameraRow;
private int pauseOnMinimizeRow;
private int disablePlaybackRow;
private int mediaDividerRow;
@@ -240,6 +244,11 @@ public class ChatsPreferencesEntry extends BaseFragment {
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(ExteraConfig.rearVideoMessages);
}
} else if (position == disableCameraRow) {
ExteraConfig.toggleDisableCamera();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(ExteraConfig.disableCamera);
}
} else if (position == pauseOnMinimizeRow) {
ExteraConfig.togglePauseOnMinimize();
if (view instanceof TextCheckCell) {
@@ -276,6 +285,7 @@ public class ChatsPreferencesEntry extends BaseFragment {
mediaHeaderRow = rowCount++;
rearVideoMessagesRow = rowCount++;
disableCameraRow = rowCount++;
pauseOnMinimizeRow = rowCount++;
disablePlaybackRow = rowCount++;
mediaDividerRow = rowCount++;
@@ -337,6 +347,8 @@ public class ChatsPreferencesEntry extends BaseFragment {
textCheckCell.setTextAndCheck(LocaleController.getString("DateOfForwardedMsg", R.string.DateOfForwardedMsg), ExteraConfig.dateOfForwardedMsg, true);
} else if (position == rearVideoMessagesRow) {
textCheckCell.setTextAndCheck(LocaleController.getString("RearVideoMessages", R.string.RearVideoMessages), ExteraConfig.rearVideoMessages, true);
} else if (position == disableCameraRow) {
textCheckCell.setTextAndCheck(LocaleController.getString("DisableCamera", R.string.DisableCamera), ExteraConfig.disableCamera, true);
} else if (position == pauseOnMinimizeRow) {
textCheckCell.setTextAndValueAndCheck(LocaleController.getString("PauseOnMinimize", R.string.PauseOnMinimize), LocaleController.getString("POMDescription", R.string.POMDescription), ExteraConfig.pauseOnMinimize, true, true);
} else if (position == disablePlaybackRow) {
@@ -385,7 +397,7 @@ public class ChatsPreferencesEntry extends BaseFragment {
return 2;
} else if (position == hideStickerTimeRow || position == hideSendAsChannelRow || position == hideKeyboardOnScrollRow ||
position == archiveOnPullRow || position == dateOfForwardedMsgRow || position == rearVideoMessagesRow ||
position == pauseOnMinimizeRow || position == disablePlaybackRow) {
position == disableCameraRow || position == pauseOnMinimizeRow || position == disablePlaybackRow) {
return 3;
} else if (position == stickerSizeRow) {
return 4;

View File

@@ -97,6 +97,8 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import com.exteragram.messenger.ExteraConfig;
public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayout implements NotificationCenter.NotificationCenterDelegate {
private RecyclerListView cameraPhotoRecyclerView;
@@ -684,7 +686,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
PhotoViewer.getInstance().setCaption(parentAlert.getCommentTextView().getText());
}
} else {
if (SharedConfig.inappCamera) {
if (SharedConfig.inappCamera && !ExteraConfig.disableCamera) {
openCamera(true);
} else {
if (parentAlert.delegate != null) {
@@ -1618,7 +1620,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}
boolean old = deviceHasGoodCamera;
boolean old2 = noCameraPermissions;
if (!SharedConfig.inappCamera) {
if (!SharedConfig.inappCamera || ExteraConfig.disableCamera) {
deviceHasGoodCamera = false;
} else {
if (Build.VERSION.SDK_INT >= 23) {
@@ -1844,7 +1846,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
for (int a = 0; a < count; a++) {
View child = gridView.getChildAt(a);
if (child instanceof PhotoAttachCameraCell) {
child.setVisibility(View.INVISIBLE);
if (cameraView != null) child.setVisibility(View.INVISIBLE);
break;
}
}

View File

@@ -44,6 +44,7 @@
<string name="Media">Media</string>
<string name="RearVideoMessages">Rear Camera in Video Messages</string>
<string name="DisableCamera">Disable instant camera</string>
<string name="PauseOnMinimize">Autopause</string>
<string name="POMDescription">Pauses a video playback when device is locked or exteraGram is minimized</string>
<string name="DisablePlayback">Disable playback</string>