Merge remote-tracking branch 'telegram/master'

This commit is contained in:
NekoInverter 2020-06-05 22:35:30 +08:00
commit a15a4f6961
No known key found for this signature in database
GPG Key ID: 280D6CCCF95715F9
10 changed files with 89 additions and 103 deletions

View File

@ -286,7 +286,7 @@ android {
} }
} }
defaultConfig.versionCode = 10 * 1985 defaultConfig.versionCode = 10 * 1986
def tgVoipDexFileName = "libtgvoip.dex" def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]

View File

@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false; public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 1985; public static int BUILD_VERSION = 1986;
public static String BUILD_VERSION_STRING = "6.2.0"; public static String BUILD_VERSION_STRING = "6.2.0";
public static int APP_ID = 336779; public static int APP_ID = 336779;
public static String APP_HASH = "b91eefacc86747c068c8d8a16b41500d"; public static String APP_HASH = "b91eefacc86747c068c8d8a16b41500d";

View File

@ -2052,8 +2052,8 @@ public class MessagesStorage extends BaseController {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS; flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
} }
if ((flags & flag) != 0) { if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) && if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) { ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0)) {
unreadCount--; unreadCount--;
} }
} }
@ -3553,15 +3553,23 @@ public class MessagesStorage extends BaseController {
public void resetMentionsCount(final long did, final int count) { public void resetMentionsCount(final long did, final int count) {
storageQueue.postRunnable(() -> { storageQueue.postRunnable(() -> {
try { try {
if (count == 0) { int prevUnreadCount = 0;
database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 2 WHERE uid = %d AND mention = 1 AND read_state IN(0, 1)", did)).stepThis().dispose(); SQLiteCursor cursor = database.queryFinalized("SELECT unread_count_i FROM dialogs WHERE did = " + did);
if (cursor.next()) {
prevUnreadCount = cursor.intValue(0);
} }
database.executeFast(String.format(Locale.US, "UPDATE dialogs SET unread_count_i = %d WHERE did = %d", count, did)).stepThis().dispose(); cursor.dispose();
LongSparseArray<Integer> sparseArray = new LongSparseArray<>(1); if (prevUnreadCount != 0 || count != 0) {
sparseArray.put(did, count); if (count == 0) {
getMessagesController().processDialogsUpdateRead(null, sparseArray); database.executeFast(String.format(Locale.US, "UPDATE messages SET read_state = read_state | 2 WHERE uid = %d AND mention = 1 AND read_state IN(0, 1)", did)).stepThis().dispose();
if (count == 0) { }
updateFiltersReadCounter(null, sparseArray, true); database.executeFast(String.format(Locale.US, "UPDATE dialogs SET unread_count_i = %d WHERE did = %d", count, did)).stepThis().dispose();
LongSparseArray<Integer> sparseArray = new LongSparseArray<>(1);
sparseArray.put(did, count);
getMessagesController().processDialogsUpdateRead(null, sparseArray);
if (count == 0) {
updateFiltersReadCounter(null, sparseArray, true);
}
} }
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
@ -3983,74 +3991,6 @@ public class MessagesStorage extends BaseController {
} }
} }
if (filter != null) { if (filter != null) {
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
int did = filter.alwaysShow.get(b);
if (did > 0) {
TLRPC.User user = usersDict.get(did);
if (user != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount--;
} else {
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount--;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount--;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount--;
}
}
}
}
user = encUsersDict.get(did);
if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0);
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount -= count;
} else {
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount -= count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount -= count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount -= count;
}
}
}
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0 && dialogsWithUnread.indexOfKey(-chat.id) < 0) {
unreadCount--;
} else {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount--;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
boolean hasUnread = dialogsWithUnread.indexOfKey(did) >= 0;
boolean hasMention = dialogsWithMentions.indexOfKey(did) >= 0;
if (!hasUnread && !hasMention) {
unreadCount--;
}
}
}
}
}
}
}
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) { for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
int did = filter.alwaysShow.get(b); int did = filter.alwaysShow.get(b);
if (did > 0) { if (did > 0) {
@ -4148,8 +4088,8 @@ public class MessagesStorage extends BaseController {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS; flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
} }
if ((flags & flag) != 0) { if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) && if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) { ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0)) {
unreadCount++; unreadCount++;
} }
} }

View File

@ -21,6 +21,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import android.view.DisplayCutout; import android.view.DisplayCutout;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -468,6 +469,8 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
} }
inLayout = false; inLayout = false;
} else {
AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight;
} }
final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21; final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21;

View File

@ -969,6 +969,7 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
showMagnifier(lastX); showMagnifier(lastX);
} }
break; break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
hideMagnifier(); hideMagnifier();
movingHandle = false; movingHandle = false;

View File

@ -13862,6 +13862,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} }
} }
} }
chatListView.setItemAnimator(null);
} }
updateBottomOverlay(); updateBottomOverlay();
updateSecretStatus(); updateSecretStatus();

View File

@ -122,7 +122,7 @@ public class FiltersListBottomSheet extends BottomSheet implements NotificationC
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
int top = scrollOffsetY - backgroundPaddingTop - AndroidUtilities.dp(8); int top = scrollOffsetY - backgroundPaddingTop - AndroidUtilities.dp(8);
int height = getMeasuredHeight() + AndroidUtilities.dp(28) + backgroundPaddingTop; int height = getMeasuredHeight() + AndroidUtilities.dp(36) + backgroundPaddingTop;
int statusBarHeight = 0; int statusBarHeight = 0;
float radProgress = 1.0f; float radProgress = 1.0f;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
@ -360,7 +360,11 @@ public class FiltersListBottomSheet extends BottomSheet implements NotificationC
@Override @Override
public int getItemCount() { public int getItemCount() {
return dialogFilters.size() + 1; int count = dialogFilters.size();
if (count < 10) {
count++;
}
return count;
} }
@Override @Override

View File

@ -156,6 +156,7 @@ public class VideoPlayer implements ExoPlayer.EventListener, SimpleExoPlayer.Vid
} else { } else {
factory = new DefaultRenderersFactory(ApplicationLoader.applicationContext); factory = new DefaultRenderersFactory(ApplicationLoader.applicationContext);
} }
factory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER);
player = ExoPlayerFactory.newSimpleInstance(ApplicationLoader.applicationContext, factory, trackSelector, loadControl, null); player = ExoPlayerFactory.newSimpleInstance(ApplicationLoader.applicationContext, factory, trackSelector, loadControl, null);
player.addListener(this); player.addListener(this);

View File

@ -2118,7 +2118,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
boolean hideProgressDialog = true; boolean hideProgressDialog = true;
if (error == null && actionBarLayout != null) { if (error == null && actionBarLayout != null) {
TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response; TLRPC.ChatInvite invite = (TLRPC.ChatInvite) response;
if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || !invite.chat.kicked && !TextUtils.isEmpty(invite.chat.username))) { if (invite.chat != null && (!ChatObject.isLeftFromChat(invite.chat) || !invite.chat.kicked && (!TextUtils.isEmpty(invite.chat.username) || BuildVars.DEBUG_PRIVATE_VERSION))) {
MessagesController.getInstance(intentAccount).putChat(invite.chat, false); MessagesController.getInstance(intentAccount).putChat(invite.chat, false);
ArrayList<TLRPC.Chat> chats = new ArrayList<>(); ArrayList<TLRPC.Chat> chats = new ArrayList<>();
chats.add(invite.chat); chats.add(invite.chat);

View File

@ -1117,6 +1117,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private float[] animAlphas = new float[3]; private float[] animAlphas = new float[3];
private float[] alphas = new float[3]; private float[] alphas = new float[3];
private float scale = 1.0f; private float scale = 1.0f;
private boolean visible;
public PhotoProgressView(View parentView) { public PhotoProgressView(View parentView) {
if (decelerateInterpolator == null) { if (decelerateInterpolator == null) {
@ -1206,12 +1207,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else { } else {
previousBackgroundState = -2; previousBackgroundState = -2;
} }
backgroundState = state; onBackgroundStateUpdated(backgroundState = state);
parent.invalidate(); parent.invalidate();
} }
protected void onBackgroundStateUpdated(int state) {
}
public void setAlpha(float value) { public void setAlpha(float value) {
alphas[0] = animAlphas[0] = value; alphas[0] = animAlphas[0] = value;
checkVisibility();
} }
public void setScale(float value) { public void setScale(float value) {
@ -1224,6 +1229,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!animated) { if (!animated) {
animAlphas[index] = alpha; animAlphas[index] = alpha;
} }
checkVisibility();
parent.invalidate(); parent.invalidate();
} }
} }
@ -1232,6 +1238,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
for (int i = 0; i < alphas.length; i++) { for (int i = 0; i < alphas.length; i++) {
alphas[i] = animAlphas[i] = 1.0f; alphas[i] = animAlphas[i] = 1.0f;
} }
checkVisibility();
} }
private float calculateAlpha() { private float calculateAlpha() {
@ -1246,13 +1253,25 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return alpha; return alpha;
} }
public boolean isVisible() { private void checkVisibility() {
boolean newVisible = true;
for (int i = 0; i < alphas.length; i++) { for (int i = 0; i < alphas.length; i++) {
if (alphas[i] != 1.0f) { if (alphas[i] != 1.0f) {
return false; newVisible = false;
break;
} }
} }
return true; if (newVisible != visible) {
visible = newVisible;
onVisibilityChanged(visible);
}
}
protected void onVisibilityChanged(boolean visible) {
}
public boolean isVisible() {
return visible;
} }
public int getX() { public int getX() {
@ -2813,6 +2832,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
heightSize += AndroidUtilities.statusBarHeight; heightSize += AndroidUtilities.statusBarHeight;
} }
AndroidUtilities.displaySize.y = heightSize - AndroidUtilities.statusBarHeight - insets.getStableInsetBottom();
heightSize -= insets.getSystemWindowInsetBottom(); heightSize -= insets.getSystemWindowInsetBottom();
} else { } else {
if (heightSize > AndroidUtilities.displaySize.y) { if (heightSize > AndroidUtilities.displaySize.y) {
@ -3496,7 +3516,21 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
setCaptionHwLayerEnabled(true); setCaptionHwLayerEnabled(true);
for (int a = 0; a < 3; a++) { for (int a = 0; a < 3; a++) {
photoProgressViews[a] = new PhotoProgressView(containerView); photoProgressViews[a] = new PhotoProgressView(containerView) {
@Override
protected void onBackgroundStateUpdated(int state) {
if (this == photoProgressViews[0]) {
updateAccessibilityOverlayVisibility();
}
}
@Override
protected void onVisibilityChanged(boolean visible) {
if (this == photoProgressViews[0]) {
updateAccessibilityOverlayVisibility();
}
}
};
photoProgressViews[a].setBackgroundState(PROGRESS_EMPTY, false); photoProgressViews[a].setBackgroundState(PROGRESS_EMPTY, false);
} }
@ -5270,7 +5304,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (!isPlaying) { if (!isPlaying) {
isPlaying = true; isPlaying = true;
photoProgressViews[0].setBackgroundState(isCurrentVideo ? PROGRESS_NONE : PROGRESS_PAUSE, false); photoProgressViews[0].setBackgroundState(isCurrentVideo ? PROGRESS_NONE : PROGRESS_PAUSE, false);
photoProgressViews[0].setIndexedAlpha(1, !isCurrentVideo && ((playerAutoStarted && !playerWasPlaying) || !isActionBarVisible) ? 0f : 1f, false); photoProgressViews[0].setIndexedAlpha(1, !isCurrentVideo && !isAccessibilityEnabled() && ((playerAutoStarted && !playerWasPlaying) || !isActionBarVisible) ? 0f : 1f, false);
playerWasPlaying = true; playerWasPlaying = true;
AndroidUtilities.runOnUIThread(updateProgressRunnable); AndroidUtilities.runOnUIThread(updateProgressRunnable);
} }
@ -5586,8 +5620,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
inPreview = preview; inPreview = preview;
updateAccessibilityOverlayVisibility();
} }
private void createVideoTextureView(MediaController.SavedFilterState savedFilterState) { private void createVideoTextureView(MediaController.SavedFilterState savedFilterState) {
@ -5638,7 +5670,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
videoPlayer.releasePlayer(true); videoPlayer.releasePlayer(true);
videoPlayer = null; videoPlayer = null;
updateAccessibilityOverlayVisibility();
} else { } else {
playerWasPlaying = false; playerWasPlaying = false;
} }
@ -7854,7 +7885,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
animateCaption = false; animateCaption = false;
} }
isCurrentVideo = true; isCurrentVideo = true;
updateAccessibilityOverlayVisibility();
boolean isMuted = false; boolean isMuted = false;
float start = 0.0f; float start = 0.0f;
float end = 1.0f; float end = 1.0f;
@ -7899,7 +7929,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
animateCaption = false; animateCaption = false;
} }
isCurrentVideo = false; isCurrentVideo = false;
updateAccessibilityOverlayVisibility();
compressItem.setVisibility(View.GONE); compressItem.setVisibility(View.GONE);
if (isAnimation || sendPhotoType == SELECT_TYPE_QR || isDocumentsPicker) { if (isAnimation || sendPhotoType == SELECT_TYPE_QR || isDocumentsPicker) {
paintItem.setVisibility(View.GONE); paintItem.setVisibility(View.GONE);
@ -8220,6 +8249,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
photoProgressViews[0] = photoProgressViews[2]; photoProgressViews[0] = photoProgressViews[2];
photoProgressViews[2] = tempProgress; photoProgressViews[2] = tempProgress;
setIndexToImage(leftImage, currentIndex - 1); setIndexToImage(leftImage, currentIndex - 1);
updateAccessibilityOverlayVisibility();
checkProgress(1, true, false); checkProgress(1, true, false);
checkProgress(2, true, false); checkProgress(2, true, false);
@ -8233,6 +8263,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
photoProgressViews[0] = photoProgressViews[1]; photoProgressViews[0] = photoProgressViews[1];
photoProgressViews[1] = tempProgress; photoProgressViews[1] = tempProgress;
setIndexToImage(rightImage, currentIndex + 1); setIndexToImage(rightImage, currentIndex + 1);
updateAccessibilityOverlayVisibility();
checkProgress(1, true, false); checkProgress(1, true, false);
checkProgress(2, true, false); checkProgress(2, true, false);
@ -9440,7 +9471,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
MediaController.getInstance().injectVideoPlayer(videoPlayer, currentMessageObject); MediaController.getInstance().injectVideoPlayer(videoPlayer, currentMessageObject);
videoPlayer = null; videoPlayer = null;
updateAccessibilityOverlayVisibility();
} }
} }
@ -11711,12 +11741,18 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
private void updateAccessibilityOverlayVisibility() { private void updateAccessibilityOverlayVisibility() {
if (playButtonAccessibilityOverlay == null) if (playButtonAccessibilityOverlay != null) {
return; final int state = photoProgressViews[0].backgroundState;
if (isCurrentVideo && (videoPlayer == null || !videoPlayer.isPlaying())) { if (photoProgressViews[0].isVisible() && (state == PROGRESS_PLAY || state == PROGRESS_PAUSE)) {
playButtonAccessibilityOverlay.setVisibility(View.VISIBLE); if (state == PROGRESS_PLAY) {
} else { playButtonAccessibilityOverlay.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay));
playButtonAccessibilityOverlay.setVisibility(View.INVISIBLE); } else {
playButtonAccessibilityOverlay.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause));
}
playButtonAccessibilityOverlay.setVisibility(View.VISIBLE);
} else {
playButtonAccessibilityOverlay.setVisibility(View.INVISIBLE);
}
} }
} }