mirror of
https://github.com/MGislv/NekoX.git
synced 2024-07-04 11:13:36 +00:00
Ask before calling
This commit is contained in:
parent
ea9200cc9c
commit
503afbf436
|
@ -57,6 +57,8 @@ import java.util.Collections;
|
|||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
public class VoIPHelper {
|
||||
|
||||
public static long lastCallTime = 0;
|
||||
|
@ -64,6 +66,10 @@ public class VoIPHelper {
|
|||
private static final int VOIP_SUPPORT_ID = 4244000;
|
||||
|
||||
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.UserFull userFull) {
|
||||
startCall(user, activity, userFull, false);
|
||||
}
|
||||
|
||||
public static void startCall(TLRPC.User user, final Activity activity, TLRPC.UserFull userFull, boolean confirmed) {
|
||||
if (userFull != null && userFull.phone_calls_private) {
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(LocaleController.getString("VoipFailed", R.string.VoipFailed))
|
||||
|
@ -91,6 +97,16 @@ public class VoIPHelper {
|
|||
if (Build.VERSION.SDK_INT >= 23 && activity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 101);
|
||||
} else {
|
||||
if (!confirmed && NekoConfig.askBeforeCall) {
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(LocaleController.getString("ConfirmCall", R.string.ConfirmCall))
|
||||
.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("CallTo", R.string.CallTo,
|
||||
ContactsController.formatName(user.first_name, user.last_name))))
|
||||
.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> startCall(user, activity, userFull, true))
|
||||
.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
initiateCall(user, activity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class NekoConfig {
|
|||
public static boolean rearVideoMessages = false;
|
||||
public static boolean hideAllTab = false;
|
||||
public static boolean confirmAVMessage = true;
|
||||
public static boolean askBeforeCall = true;
|
||||
public static int mapPreviewProvider = 0;
|
||||
public static float stickerSize = 14.0f;
|
||||
public static int translationProvider = 1;
|
||||
|
@ -108,6 +109,7 @@ public class NekoConfig {
|
|||
editor.putBoolean("rearVideoMessages", rearVideoMessages);
|
||||
editor.putBoolean("hideAllTab", hideAllTab);
|
||||
editor.putBoolean("confirmAVMessage", confirmAVMessage);
|
||||
editor.putBoolean("askBeforeCall", askBeforeCall);
|
||||
editor.putFloat("stickerSize", stickerSize);
|
||||
editor.putInt("typeface", typeface);
|
||||
editor.putInt("nameOrder", nameOrder);
|
||||
|
@ -170,6 +172,7 @@ public class NekoConfig {
|
|||
hideAllTab = preferences.getBoolean("hideAllTab", false);
|
||||
tabsTitleType = preferences.getInt("tabsTitleType", TITLE_TYPE_TEXT);
|
||||
confirmAVMessage = preferences.getBoolean("confirmAVMessage", true);
|
||||
askBeforeCall = preferences.getBoolean("askBeforeCall", true);
|
||||
configLoaded = true;
|
||||
}
|
||||
}
|
||||
|
@ -496,4 +499,12 @@ public class NekoConfig {
|
|||
editor.putBoolean("confirmAVMessage", confirmAVMessage);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void toggleAskBeforeCall() {
|
||||
askBeforeCall = !askBeforeCall;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("askBeforeCall", askBeforeCall);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
|||
private int rearVideoMessagesRow;
|
||||
private int hideAllTabRow;
|
||||
private int confirmAVRow;
|
||||
private int askBeforeCallRow;
|
||||
private int mapPreviewRow;
|
||||
private int stickerSizeRow;
|
||||
private int translationProviderRow;
|
||||
|
@ -585,6 +586,11 @@ public class NekoSettingsActivity extends BaseFragment {
|
|||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.confirmAVMessage);
|
||||
}
|
||||
} else if (position == askBeforeCallRow) {
|
||||
NekoConfig.toggleAskBeforeCall();
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(NekoConfig.askBeforeCall);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -616,6 +622,7 @@ public class NekoSettingsActivity extends BaseFragment {
|
|||
rearVideoMessagesRow = rowCount++;
|
||||
hideAllTabRow = rowCount++;
|
||||
confirmAVRow = rowCount++;
|
||||
askBeforeCallRow = rowCount++;
|
||||
mapPreviewRow = rowCount++;
|
||||
stickerSizeRow = rowCount++;
|
||||
messageMenuRow = rowCount++;
|
||||
|
@ -1140,6 +1147,8 @@ public class NekoSettingsActivity extends BaseFragment {
|
|||
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);
|
||||
} else if (position == askBeforeCallRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("AskBeforeCalling", R.string.AskBeforeCalling), NekoConfig.askBeforeCall, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1180,7 +1189,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 == confirmAVRow;
|
||||
position == hideAllTabRow || position == tabsTitleTypeRow || position == confirmAVRow || position == askBeforeCallRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1236,7 +1245,8 @@ 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 == confirmAVRow) {
|
||||
position == chatMessageAnimationRow || position == rearVideoMessagesRow || position == hideAllTabRow || position == confirmAVRow ||
|
||||
position == askBeforeCallRow) {
|
||||
return 3;
|
||||
} else if (position == settingsRow || position == connectionRow || position == chatRow || position == experimentRow) {
|
||||
return 4;
|
||||
|
|
|
@ -96,5 +96,8 @@
|
|||
<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>
|
||||
<string name="ConfirmAVMessage">Confirm sending video/voice message</string>
|
||||
<string name="AskBeforeCalling">Ask before calling</string>
|
||||
<string name="ConfirmCall">Confirm calling</string>
|
||||
<string name="CallTo">Call to **%1$s**?</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user