1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-17 07:49:34 +01:00

Confirm before sending video/voice message

This commit is contained in:
NekoInverter 2020-05-07 13:44:06 +08:00
parent 29c3e372c1
commit ea9200cc9c
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
4 changed files with 90 additions and 56 deletions

View File

@ -2393,16 +2393,22 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (!hasRecordVideo || calledRecordRunnable) {
startedDraggingX = -1;
if (hasRecordVideo && videoSendButton.getTag() != null) {
delegate.needStartRecordVideo(1, true, 0);
delegate.needStartRecordVideo(NekoConfig.confirmAVMessage ? 3 : 1, true, 0);
} else {
if (recordingAudioVideo && isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
if (NekoConfig.confirmAVMessage) {
MediaController.getInstance().stopRecording(2, true, 0);
} else {
if (recordingAudioVideo && isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
}
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
}
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
delegate.needStartRecordAudio(0);
}
recordingAudioVideo = false;
updateRecordIntefrace(RECORD_STATE_SENDING);
if (!NekoConfig.confirmAVMessage) {
recordingAudioVideo = false;
updateRecordIntefrace(RECORD_STATE_SENDING);
}
}
return false;
}
@ -2469,16 +2475,24 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
startedDraggingX = -1;
if (hasRecordVideo && videoSendButton.getTag() != null) {
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
delegate.needStartRecordVideo(1, true, 0);
delegate.needStartRecordVideo(NekoConfig.confirmAVMessage ? 3 : 1, true, 0);
} else {
if (recordingAudioVideo && isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
if (!NekoConfig.confirmAVMessage) {
if (recordingAudioVideo && isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
}
}
delegate.needStartRecordAudio(0);
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
if (!NekoConfig.confirmAVMessage) {
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
} else {
MediaController.getInstance().stopRecording(2, true, 0);
}
}
if (!NekoConfig.confirmAVMessage) {
recordingAudioVideo = false;
updateRecordIntefrace(RECORD_STATE_SENDING);
}
recordingAudioVideo = false;
updateRecordIntefrace(RECORD_STATE_SENDING);
}
}
} else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && recordingAudioVideo) {

View File

@ -32,6 +32,7 @@ public class NekoConfig {
public static boolean chatMessageAnimation = false;
public static boolean rearVideoMessages = false;
public static boolean hideAllTab = false;
public static boolean confirmAVMessage = true;
public static int mapPreviewProvider = 0;
public static float stickerSize = 14.0f;
public static int translationProvider = 1;
@ -106,6 +107,7 @@ public class NekoConfig {
editor.putBoolean("chatMessageAnimation", chatMessageAnimation);
editor.putBoolean("rearVideoMessages", rearVideoMessages);
editor.putBoolean("hideAllTab", hideAllTab);
editor.putBoolean("confirmAVMessage", confirmAVMessage);
editor.putFloat("stickerSize", stickerSize);
editor.putInt("typeface", typeface);
editor.putInt("nameOrder", nameOrder);
@ -167,6 +169,7 @@ public class NekoConfig {
rearVideoMessages = preferences.getBoolean("rearVideoMessages", false);
hideAllTab = preferences.getBoolean("hideAllTab", false);
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
confirmAVMessage = preferences.getBoolean("confirmAVMessage", true);
configLoaded = true;
}
}
@ -485,4 +488,12 @@ public class NekoConfig {
editor.putInt("tabsTitleType", tabsTitleType);
editor.commit();
}
public static void toggleConfirmAVMessage() {
confirmAVMessage = !confirmAVMessage;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("confirmAVMessage", confirmAVMessage);
editor.commit();
}
}

View File

@ -82,6 +82,7 @@ public class NekoSettingsActivity extends BaseFragment {
private int hideKeyboardOnChatScrollRow;
private int rearVideoMessagesRow;
private int hideAllTabRow;
private int confirmAVRow;
private int mapPreviewRow;
private int stickerSizeRow;
private int translationProviderRow;
@ -113,6 +114,47 @@ public class NekoSettingsActivity extends BaseFragment {
private int deleteAccountRow;
private int needRestartRow;
static public AlertDialog getTranslationProviderAlert(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
types.add(Translator.PROVIDER_GOOGLE);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
types.add(Translator.PROVIDER_GOOGLE_CN);
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
types.add(Translator.PROVIDER_LINGO);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
types.add(Translator.PROVIDER_GOOGLE_WEB);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
types.add(Translator.PROVIDER_GOOGLE_CN_WEB);
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
types.add(Translator.PROVIDER_BAIDU_WEB);
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
types.add(Translator.PROVIDER_DEEPL_WEB);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(LocaleController.getString("TranslationProvider", R.string.TranslationProvider));
final LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < arrayList.size(); a++) {
RadioColorCell cell = new RadioColorCell(context);
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
cell.setTag(a);
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
cell.setTextAndValue(arrayList.get(a), NekoConfig.translationProvider == types.get(a));
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
Integer which = (Integer) v.getTag();
NekoConfig.setTranslationProvider(types.get(which));
builder.getDismissRunnable().run();
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
@Override
public boolean onFragmentCreate() {
super.onFragmentCreate();
@ -538,8 +580,12 @@ public class NekoSettingsActivity extends BaseFragment {
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else if (position == confirmAVRow) {
NekoConfig.toggleConfirmAVMessage();
if (view instanceof TextCheckCell) {
((TextCheckCell) view).setChecked(NekoConfig.confirmAVMessage);
}
}
});
return fragmentView;
@ -569,6 +615,7 @@ public class NekoSettingsActivity extends BaseFragment {
hideKeyboardOnChatScrollRow = rowCount++;
rearVideoMessagesRow = rowCount++;
hideAllTabRow = rowCount++;
confirmAVRow = rowCount++;
mapPreviewRow = rowCount++;
stickerSizeRow = rowCount++;
messageMenuRow = rowCount++;
@ -688,47 +735,6 @@ public class NekoSettingsActivity extends BaseFragment {
}));
}
static public AlertDialog getTranslationProviderAlert(Context context) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("ProviderGoogleTranslate", R.string.ProviderGoogleTranslate));
types.add(Translator.PROVIDER_GOOGLE);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCN", R.string.ProviderGoogleTranslateCN));
types.add(Translator.PROVIDER_GOOGLE_CN);
arrayList.add(LocaleController.getString("ProviderLingocloud", R.string.ProviderLingocloud));
types.add(Translator.PROVIDER_LINGO);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateWeb", R.string.ProviderGoogleTranslateWeb));
types.add(Translator.PROVIDER_GOOGLE_WEB);
arrayList.add(LocaleController.getString("ProviderGoogleTranslateCNWeb", R.string.ProviderGoogleTranslateCNWeb));
types.add(Translator.PROVIDER_GOOGLE_CN_WEB);
arrayList.add(LocaleController.getString("ProviderBaiduFanyiWeb", R.string.ProviderBaiduFanyiWeb));
types.add(Translator.PROVIDER_BAIDU_WEB);
arrayList.add(LocaleController.getString("ProviderDeepLWeb", R.string.ProviderDeepLWeb));
types.add(Translator.PROVIDER_DEEPL_WEB);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(LocaleController.getString("TranslationProvider", R.string.TranslationProvider));
final LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
builder.setView(linearLayout);
for (int a = 0; a < arrayList.size(); a++) {
RadioColorCell cell = new RadioColorCell(context);
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
cell.setTag(a);
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
cell.setTextAndValue(arrayList.get(a), NekoConfig.translationProvider == types.get(a));
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
Integer which = (Integer) v.getTag();
NekoConfig.setTranslationProvider(types.get(which));
builder.getDismissRunnable().run();
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
return builder.create();
}
private void showMessageMenuAlert() {
if (getParentActivity() == null) {
return;
@ -1132,6 +1138,8 @@ public class NekoSettingsActivity extends BaseFragment {
textCell.setTextAndCheck(LocaleController.getString("RearVideoMessages", R.string.RearVideoMessages), NekoConfig.rearVideoMessages, true);
} else if (position == hideAllTabRow) {
textCell.setTextAndValueAndCheck(LocaleController.getString("HideAllTab", R.string.HideAllTab), LocaleController.getString("HideAllTabAbout", R.string.HideAllTabAbout), NekoConfig.hideAllTab, true, true);
} else if (position == confirmAVRow) {
textCell.setTextAndCheck(LocaleController.getString("ConfirmAVMessage", R.string.ConfirmAVMessage), NekoConfig.confirmAVMessage, true);
}
break;
}
@ -1172,7 +1180,7 @@ public class NekoSettingsActivity extends BaseFragment {
position == disablePhotoSideActionRow || position == unlimitedPinnedDialogsRow || position == openArchiveOnPullRow ||
position == experimentRow || position == hideKeyboardOnChatScrollRow || position == avatarAsDrawerBackgroundRow ||
position == showTabsOnForwardRow || position == chatMessageAnimationRow || position == rearVideoMessagesRow ||
position == hideAllTabRow || position == tabsTitleTypeRow;
position == hideAllTabRow || position == tabsTitleTypeRow || position == confirmAVRow;
}
@Override
@ -1228,7 +1236,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 == rearVideoMessagesRow || position == hideAllTabRow) {
position == chatMessageAnimationRow || position == rearVideoMessagesRow || position == hideAllTabRow || position == confirmAVRow) {
return 3;
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) {
return 4;

View File

@ -96,4 +96,5 @@
<string name="TabTitleTypeText">Titles</string>
<string name="TabTitleTypeIcon">Emoticons</string>
<string name="TabTitleTypeMix">Emoticons with titles</string>
<string name="ConfirmAVMessage">Confirm before sending video/voice message</string>
</resources>