Update to 7.1.3 (2103)

This commit is contained in:
DrKLO 2020-10-15 03:39:36 +03:00
parent d3ad1316c4
commit 19599e6ea4
17 changed files with 125 additions and 55 deletions

View file

@ -33,8 +33,8 @@ dependencies {
implementation 'com.google.android.gms:play-services-vision:16.2.0'
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'
implementation "com.microsoft.appcenter:appcenter-distribute:3.2.2"
implementation "com.microsoft.appcenter:appcenter-crashes:3.2.2"
implementation "com.microsoft.appcenter:appcenter-distribute:3.3.1"
implementation "com.microsoft.appcenter:appcenter-crashes:3.3.1"
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation files('libs/libgsaverification-client.aar')
@ -284,7 +284,7 @@ android {
}
}
defaultConfig.versionCode = 2100
defaultConfig.versionCode = 2103
applicationVariants.all { variant ->
variant.outputs.all { output ->

View file

@ -2255,7 +2255,7 @@ public class AndroidUtilities {
}
public static CharSequence generateSearchName(String name, String name2, String q) {
if (name == null && name2 == null) {
if (name == null && name2 == null || TextUtils.isEmpty(q)) {
return "";
}
SpannableStringBuilder builder = new SpannableStringBuilder();
@ -2288,7 +2288,7 @@ public class AndroidUtilities {
int start = builder.length();
builder.append(query);
builder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)), start, start + query.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpanThemable(Theme.key_windowBackgroundWhiteBlueText4), start, start + query.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
lastIndex = end;
}

View file

@ -18,7 +18,7 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static int BUILD_VERSION = 2100;
public static int BUILD_VERSION = 2103;
public static String BUILD_VERSION_STRING = "7.1.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -10932,7 +10932,7 @@ public class MessagesController extends BaseController implements NotificationCe
messages.put(message.dialog_id, arr);
}
arr.add(obj);
if ((!obj.isOut() || obj.messageOwner.from_scheduled) && obj.isUnread() && !ChatObject.isNotInChat(chat) && chat.min) {
if ((!obj.isOut() || obj.messageOwner.from_scheduled) && obj.isUnread() && (chat == null || !ChatObject.isNotInChat(chat) && !chat.min)) {
if (pushMessages == null) {
pushMessages = new ArrayList<>();
}

View file

@ -1533,7 +1533,11 @@ public class MessagesStorage extends BaseController {
}
if (message.replyMessage == null) {
long messageId = message.reply_to.reply_to_msg_id;
if (message.peer_id.channel_id != 0) {
if (message.reply_to.reply_to_peer_id != null) {
if (message.reply_to.reply_to_peer_id.channel_id != 0) {
messageId |= ((long) message.reply_to.reply_to_peer_id.channel_id) << 32;
}
} else if (message.peer_id.channel_id != 0) {
messageId |= ((long) message.peer_id.channel_id) << 32;
}
if (!replyMessages.contains(messageId)) {
@ -2670,7 +2674,11 @@ public class MessagesStorage extends BaseController {
}
if (message.replyMessage == null) {
long messageId = message.reply_to.reply_to_msg_id;
if (message.peer_id.channel_id != 0) {
if (message.reply_to.reply_to_peer_id != null) {
if (message.reply_to.reply_to_peer_id.channel_id != 0) {
messageId |= ((long) message.reply_to.reply_to_peer_id.channel_id) << 32;
}
} else if (message.peer_id.channel_id != 0) {
messageId |= ((long) message.peer_id.channel_id) << 32;
}
if (!replyMessages.contains(messageId)) {
@ -5857,7 +5865,11 @@ public class MessagesStorage extends BaseController {
if (message.replyMessage == null) {
if (message.reply_to.reply_to_msg_id != 0) {
long messageId = message.reply_to.reply_to_msg_id;
if (message.peer_id.channel_id != 0) {
if (message.reply_to.reply_to_peer_id != null) {
if (message.reply_to.reply_to_peer_id.channel_id != 0) {
messageId |= ((long) message.reply_to.reply_to_peer_id.channel_id) << 32;
}
} else if (message.peer_id.channel_id != 0) {
messageId |= ((long) message.peer_id.channel_id) << 32;
}
if (!replyMessages.contains(messageId)) {
@ -6318,7 +6330,11 @@ public class MessagesStorage extends BaseController {
if (message.replyMessage == null) {
if (message.reply_to.reply_to_msg_id != 0) {
long messageId = message.reply_to.reply_to_msg_id;
if (message.peer_id.channel_id != 0) {
if (message.reply_to.reply_to_peer_id != null) {
if (message.reply_to.reply_to_peer_id.channel_id != 0) {
messageId |= ((long) message.reply_to.reply_to_peer_id.channel_id) << 32;
}
} else if (message.peer_id.channel_id != 0) {
messageId |= ((long) message.peer_id.channel_id) << 32;
}
if (!replyMessages.contains(messageId)) {
@ -10046,7 +10062,11 @@ public class MessagesStorage extends BaseController {
}
if (message.replyMessage == null) {
long messageId = message.reply_to.reply_to_msg_id;
if (message.peer_id.channel_id != 0) {
if (message.reply_to.reply_to_peer_id != null) {
if (message.reply_to.reply_to_peer_id.channel_id != 0) {
messageId |= ((long) message.reply_to.reply_to_peer_id.channel_id) << 32;
}
} else if (message.peer_id.channel_id != 0) {
messageId |= ((long) message.peer_id.channel_id) << 32;
}
if (!replyMessages.contains(messageId)) {

View file

@ -2576,8 +2576,10 @@ public class Theme {
public static final String key_chat_inAudioSelectedProgress = "chat_inAudioSelectedProgress";
public static final String key_chat_outAudioSelectedProgress = "chat_outAudioSelectedProgress";
public static final String key_chat_mediaTimeText = "chat_mediaTimeText";
public static final String key_chat_adminText = "chat_adminText";
public static final String key_chat_adminSelectedText = "chat_adminSelectedText";
public static final String key_chat_inAdminText = "chat_adminText";
public static final String key_chat_inAdminSelectedText = "chat_adminSelectedText";
public static final String key_chat_outAdminText = "chat_outAdminText";
public static final String key_chat_outAdminSelectedText = "chat_outAdminSelectedText";
public static final String key_chat_inTimeText = "chat_inTimeText";
public static final String key_chat_outTimeText = "chat_outTimeText";
public static final String key_chat_inTimeSelectedText = "chat_inTimeSelectedText";
@ -3287,11 +3289,13 @@ public class Theme {
defaultColors.put(key_chat_inAudioSelectedProgress, 0xffeff8fe);
defaultColors.put(key_chat_outAudioSelectedProgress, 0xffe1f8cf);
defaultColors.put(key_chat_mediaTimeText, 0xffffffff);
defaultColors.put(key_chat_inAdminText, 0xffc0c6cb);
defaultColors.put(key_chat_inAdminSelectedText, 0xff89b4c1);
defaultColors.put(key_chat_outAdminText, 0xff70b15c);
defaultColors.put(key_chat_outAdminSelectedText, 0xff70b15c);
defaultColors.put(key_chat_inTimeText, 0xffa1aab3);
defaultColors.put(key_chat_outTimeText, 0xff70b15c);
defaultColors.put(key_chat_adminText, 0xffc0c6cb);
defaultColors.put(key_chat_adminSelectedText, 0xff89b4c1);
defaultColors.put(key_chat_inTimeSelectedText, 0xff89b4c1);
defaultColors.put(key_chat_outTimeText, 0xff70b15c);
defaultColors.put(key_chat_outTimeSelectedText, 0xff70b15c);
defaultColors.put(key_chat_inAudioPerformerText, 0xff2f3438);
defaultColors.put(key_chat_inAudioPerformerSelectedText, 0xff2f3438);
@ -3618,8 +3622,8 @@ public class Theme {
defaultColors.put(key_statisticChartLineEmpty, 0xFFEEEEEE);
defaultColors.put(key_actionBarTipBackground, 0xFF446F94);
fallbackKeys.put(key_chat_adminText, key_chat_inTimeText);
fallbackKeys.put(key_chat_adminSelectedText, key_chat_inTimeSelectedText);
fallbackKeys.put(key_chat_inAdminText, key_chat_inTimeText);
fallbackKeys.put(key_chat_inAdminSelectedText, key_chat_inTimeSelectedText);
fallbackKeys.put(key_player_progressCachedBackground, key_player_progressBackground);
fallbackKeys.put(key_chat_inAudioCacheSeekbar, key_chat_inAudioSeekbar);
fallbackKeys.put(key_chat_outAudioCacheSeekbar, key_chat_outAudioSeekbar);
@ -3747,6 +3751,9 @@ public class Theme {
fallbackKeys.put(key_chat_inPsaNameText, key_avatar_nameInMessageGreen);
fallbackKeys.put(key_chat_outPsaNameText, key_avatar_nameInMessageGreen);
fallbackKeys.put(key_chat_outAdminText, key_chat_outTimeText);
fallbackKeys.put(key_chat_outAdminSelectedText, key_chat_outTimeSelectedText);
themeAccentExclusionKeys.addAll(Arrays.asList(keys_avatar_background));
themeAccentExclusionKeys.addAll(Arrays.asList(keys_avatar_nameInMessage));
themeAccentExclusionKeys.add(key_chat_attachFileBackground);

View file

@ -77,10 +77,10 @@ public class ContactsAdapter extends RecyclerListView.SectionsAdapter {
disableSections = value;
}
public void setSortType(int value) {
public void setSortType(int value, boolean force) {
sortType = value;
if (sortType == 2) {
if (onlineContacts == null) {
if (onlineContacts == null || force) {
onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
int selfId = UserConfig.getInstance(currentAccount).clientUserId;
for (int a = 0, N = onlineContacts.size(); a < N; a++) {
@ -191,7 +191,7 @@ public class ContactsAdapter extends RecyclerListView.SectionsAdapter {
}
}
}
if (needPhonebook) {
if (needPhonebook && position >= 0 && position < ContactsController.getInstance(currentAccount).phoneBookContacts.size()) {
return ContactsController.getInstance(currentAccount).phoneBookContacts.get(position);
}
return null;

View file

@ -10067,7 +10067,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
nameLayout.draw(canvas);
canvas.restore();
if (adminLayout != null) {
int color = Theme.getColor(isDrawSelectionBackground() ? Theme.key_chat_adminSelectedText : Theme.key_chat_adminText);
int color;
if (currentMessageObject.isOutOwner()) {
color = Theme.getColor(isDrawSelectionBackground() ? Theme.key_chat_outAdminSelectedText : Theme.key_chat_outAdminText);
} else {
color = Theme.getColor(isDrawSelectionBackground() ? Theme.key_chat_inAdminSelectedText : Theme.key_chat_inAdminText);
}
Theme.chat_adminPaint.setColor(color);
canvas.save();
float ax;

View file

@ -54,7 +54,7 @@ public class SharingLiveLocationCell extends FrameLayout {
private LocationActivity.LiveLocation liveLocation;
private Location location = new Location("network");
private int currentAccount;
private int currentAccount = UserConfig.selectedAccount;
private Runnable invalidateRunnable = new Runnable() {
@Override

View file

@ -2095,6 +2095,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
updateChatListViewTopPadding();
chatListView.setItemAnimator(null);
chatListView.invalidate();
}
@Override
@ -2309,6 +2310,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int chatListViewTop = (int) chatListView.getY();
int chatListViewBottom = chatListViewTop + chatListView.getMeasuredHeight();
float listTop = chatListView.getTop() + chatListView.getPaddingTop() - AndroidUtilities.dp(4);
if (threadMessageId != 0 && !replyMessageVisible) {
listTop += AndroidUtilities.dp(48);
}
MessageObject.GroupedMessages scrimGroup;
if (scrimView instanceof ChatMessageCell) {
scrimGroup = ((ChatMessageCell) scrimView).getCurrentMessagesGroup();
@ -2865,6 +2869,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean wasTrackingVibrate;
private float replyButtonProgress;
private long lastReplyButtonAnimationTime;
private float cilpTop;
private boolean ignoreLayout;
@ -2884,6 +2889,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (emptyViewContainer != null) {
emptyViewContainer.setTranslationY(translationY / 2f);
}
invalidate();
}
@ -3177,7 +3183,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
ArrayList<MessageObject.GroupedMessages> drawingGroups = new ArrayList<>(10);
@Override
@ -3380,8 +3385,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
canvas.save();
cilpTop = actionBar.getY() + actionBar.getMeasuredHeight() - getY();
if (pinnedMessageView != null) {
cilpTop += Math.max(0, AndroidUtilities.dp(48) + pinnedMessageEnterOffset);
}
canvas.clipRect(0, cilpTop, getMeasuredWidth(), getMeasuredHeight());
super.dispatchDraw(canvas);
canvas.restore();
}
@Override
@ -3391,7 +3402,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean skipDraw = child == scrimView;
ChatMessageCell cell;
if (child.getY() > getMeasuredHeight() || child.getY() + child.getMeasuredHeight() < 0) {
if (child.getY() > getMeasuredHeight() || child.getY() + child.getMeasuredHeight() < cilpTop) {
skipDraw = true;
}
@ -11365,20 +11376,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean updateChat = false;
boolean hasFromMe = false;
ArrayList<MessageObject> arr = (ArrayList<MessageObject>) args[1];
if (currentEncryptedChat != null && arr.size() == 1) {
MessageObject obj = arr.get(0);
if (currentEncryptedChat != null && obj.isOut() && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && getParentActivity() != null) {
if (AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 17 && currentEncryptedChat.ttl > 0 && currentEncryptedChat.ttl <= 60) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setMessage(LocaleController.formatString("CompatibilityChat", R.string.CompatibilityChat, currentUser.first_name, currentUser.first_name));
showDialog(builder.create());
}
}
}
if (chatListItemAniamtor != null) {
chatListItemAniamtor.setShouldAnimateEnterFromBottom(true);
@ -14452,6 +14449,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
animator.addUpdateListener(animation -> {
pinnedMessageEnterOffset = (float) animation.getAnimatedValue();
invalidateChatListViewTopPadding();
chatListView.invalidate();
});
pinnedMessageViewAnimator.playTogether(animator);
pinnedMessageViewAnimator.setDuration(200);
@ -14475,6 +14473,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
pinnedMessageEnterOffset = -AndroidUtilities.dp(50);
pinnedMessageView.setVisibility(View.GONE);
chatListView.invalidate();
}
return true;
}
@ -14548,6 +14547,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
pinnedMessageEnterOffset = translationY;
invalidateChatListViewTopPadding();
chatListView.invalidate();
}
});
pinnedMessageView.setVisibility(View.VISIBLE);
@ -14573,6 +14573,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
pinnedMessageEnterOffset = 0;
invalidateChatListViewTopPadding();
chatListView.invalidate();
if (firstLoading) {
updateChatListViewTopPadding();
}
@ -19730,8 +19731,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inTimeSelectedText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_adminText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_adminSelectedText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAdminText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAdminSelectedText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAdminText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outAdminSelectedText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_outTimeSelectedText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioPerformerText));
themeDescriptions.add(new ThemeDescription(chatListView, 0, new Class[]{ChatMessageCell.class}, null, null, null, Theme.key_chat_inAudioPerformerSelectedText));

View file

@ -3045,6 +3045,8 @@ public class AlertsCreator {
if (!(participant.participant instanceof TLRPC.TL_channelParticipantAdmin || participant.participant instanceof TLRPC.TL_channelParticipantCreator)) {
loadType = 0;
}
} else if (error != null && "USER_NOT_PARTICIPANT".equals(error.text)) {
loadType = 0;
}
createDeleteMessagesAlert(fragment, user, chat, encryptedChat, chatInfo, mergeDialogId, selectedMessage, selectedMessages, selectedGroup, scheduled, loadType, onDelete);
}));

View file

@ -1850,7 +1850,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public ChatActivityEnterView(Activity context, SizeNotifierFrameLayout parent, ChatActivity fragment, final boolean isChat) {
super(context);
smoothKeyboard = isChat && SharedConfig.smoothKeyboard;
smoothKeyboard = isChat && SharedConfig.smoothKeyboard && !AndroidUtilities.isInMultiwindow && (fragment == null || !fragment.isInBubbleMode());
dotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
dotPaint.setColor(Theme.getColor(Theme.key_chat_emojiPanelNewTrending));
setFocusable(true);
@ -3278,7 +3278,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
sizeNotifierLayout.removeView(emojiView);
emojiView = null;
} else {
if (emojiViewVisible && (!waitingForKeyboardOpen)) {
if (emojiViewVisible && !waitingForKeyboardOpen) {
removeEmojiViewAfterAnimation = true;
hidePopup(false);
} else {
@ -3289,8 +3289,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
emojiView = null;
}
}
}
allowStickers = value;
allowGifs = value2;
@ -6845,12 +6843,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
private void openKeyboardInternal() {
showPopup(AndroidUtilities.usingHardwareInput || isPaused ? 0 : 2, 0);
showPopup(AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow || parentFragment != null && parentFragment.isInBubbleMode() || isPaused ? 0 : 2, 0);
messageEditText.requestFocus();
AndroidUtilities.showKeyboard(messageEditText);
if (isPaused) {
showKeyboardOnResume = true;
} else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow) {
} else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && (parentFragment == null || !parentFragment.isInBubbleMode())) {
waitingForKeyboardOpen = true;
AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);

View file

@ -3210,7 +3210,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
setBackgroundResource(R.drawable.smiles_popup);
getBackground().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_emojiPanelBackground), PorterDuff.Mode.MULTIPLY));
if (needEmojiSearch) {
bottomTabContainerBackground.setBackgroundDrawable(null);
bottomTabContainerBackground.setBackgroundColor(Theme.getColor(Theme.key_chat_emojiPanelBackground));
}
currentBackgroundType = 1;
}

View file

@ -228,7 +228,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} else if (id == sort_button) {
SharedConfig.toggleSortContactsByName();
sortByName = SharedConfig.sortContactsByName;
listViewAdapter.setSortType(sortByName ? 1 : 2);
listViewAdapter.setSortType(sortByName ? 1 : 2, false);
sortItem.setIcon(sortByName ? R.drawable.contacts_sort_time : R.drawable.contacts_sort_name);
}
}
@ -332,7 +332,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
}
};
listViewAdapter.setSortType(sortItem != null ? (sortByName ? 1 : 2) : 0);
listViewAdapter.setSortType(sortItem != null ? (sortByName ? 1 : 2) : 0, false);
listViewAdapter.setDisableSections(disableSections);
fragmentView = new FrameLayout(context) {
@ -852,6 +852,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.contactsDidLoad) {
if (listViewAdapter != null) {
if (!sortByName) {
listViewAdapter.setSortType(2, true);
}
listViewAdapter.notifyDataSetChanged();
}
} else if (id == NotificationCenter.updateInterfaces) {

View file

@ -2163,7 +2163,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
final BaseFragment lastFragment = actionBarLayout.getLastFragment();
if (lastFragment != null && lastFragment.getParentActivity() != null) {
final String finalNewContactName = newContactName;
final String finalNewContactPhone = "+" + PhoneFormat.stripExceptNumbers(newContactPhone);
final String finalNewContactPhone = NewContactActivity.getPhoneNumber(this, UserConfig.getInstance(currentAccount).getCurrentUser(), newContactPhone, false);
final AlertDialog newContactAlertDialog = new AlertDialog.Builder(lastFragment.getParentActivity())
.setTitle(LocaleController.getString("NewContactAlertTitle", R.string.NewContactAlertTitle))
.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("NewContactAlertMessage", R.string.NewContactAlertMessage, PhoneFormat.getInstance().format(finalNewContactPhone))))
@ -2268,6 +2268,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
chatActivity.setThreadMessages(arrayList, chat, req.msg_id, res.read_inbox_max_id, res.read_outbox_max_id);
if (commentId != null) {
chatActivity.setHighlightMessageId(commentId);
} else if (threadId != null) {
chatActivity.setHighlightMessageId(messageId);
}
presentFragment(chatActivity);
chatOpened = true;

View file

@ -524,7 +524,7 @@ public class NewContactActivity extends BaseFragment implements AdapterView.OnIt
}
phoneField.setText(builder);
if (start >= 0) {
phoneField.setSelection(start <= phoneField.length() ? start : phoneField.length());
phoneField.setSelection(Math.min(start, phoneField.length()));
}
phoneField.onTextChange();
ignoreOnPhoneChange = false;
@ -618,6 +618,36 @@ public class NewContactActivity extends BaseFragment implements AdapterView.OnIt
return fragmentView;
}
public static String getPhoneNumber(Context context, TLRPC.User user, String number, boolean withCoutryCode) {
HashMap<String, String> codesMap = new HashMap<>();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(context.getResources().getAssets().open("countries.txt")));
String line;
while ((line = reader.readLine()) != null) {
String[] args = line.split(";");
codesMap.put(args[0], args[2]);
}
reader.close();
} catch (Exception e) {
FileLog.e(e);
}
if (number.startsWith("+")) {
return number;
} else if (withCoutryCode || user == null || TextUtils.isEmpty(user.phone)) {
return "+" + number;
} else {
String phone = user.phone;
for (int a = 4; a >= 1; a--) {
String sub = phone.substring(0, a);
String country = codesMap.get(sub);
if (country != null) {
return "+" + sub + number;
}
}
return number;
}
}
private void invalidateAvatar() {
avatarDrawable.setInfo(5, firstNameField.getText().toString(), lastNameField.getText().toString());
avatarImage.invalidate();

View file

@ -1217,7 +1217,7 @@
<string name="NoContactsYetLine2">Find people nearby to chat with</string>
<string name="NoContactsYetLine3">Search people by username</string>
<string name="NewContactAlertTitle">New contact</string>
<string name="NewContactAlertMessage">Phone number **%1$s** is not in your contact list. Do you want to add it?</string>
<string name="NewContactAlertMessage">Phone number **%1$s** is not in your contacts list. Do you want to add it?</string>
<string name="NewContactAlertButton">Add contact</string>
<!--group create view-->
<string name="SendMessageTo">Add people...</string>