From 7554c9b7269441d12b12dd4feee19b646431b026 Mon Sep 17 00:00:00 2001 From: xaxtix Date: Mon, 27 Feb 2023 09:38:13 +0400 Subject: [PATCH] update to 9.4.7 --- .../telegram/messenger/AndroidUtilities.java | 18 +++++++++-- .../org/telegram/messenger/BuildVars.java | 4 +-- .../telegram/messenger/MediaController.java | 12 ++++---- .../ui/ActionBar/ActionBarLayout.java | 3 ++ .../Reactions/ReactionsLayoutInBubble.java | 5 ++++ .../Components/ReactionsContainerLayout.java | 13 +++++++- .../telegram/ui/Components/VideoPlayer.java | 9 +++--- .../java/org/telegram/ui/LaunchActivity.java | 6 ++-- .../java/org/telegram/ui/LoginActivity.java | 30 ++++++++++++------- .../java/org/telegram/ui/ProfileActivity.java | 10 +++++-- .../webrtc/HardwareVideoEncoderFactory.java | 13 ++++---- .../src/main/res/xml/provider_paths.xml | 2 ++ gradle.properties | 4 +-- 13 files changed, 91 insertions(+), 38 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 9fb880173..bf4503ac3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -578,15 +578,23 @@ public class AndroidUtilities { return dir; } } catch (Exception e) { - ApplicationLoader.appCenterLog(e); + } try { File dir = new File(ApplicationLoader.applicationContext.getCacheDir() + "/logs"); dir.mkdirs(); return dir; } catch (Exception e) { - ApplicationLoader.appCenterLog(e); + } + try { + File dir = new File(ApplicationLoader.applicationContext.getFilesDir() + "/logs"); + dir.mkdirs(); + return dir; + } catch (Exception e) { + + } + ApplicationLoader.appCenterLog(new RuntimeException("can't create logs directory")); return null; } @@ -1949,7 +1957,11 @@ public class AndroidUtilities { try { File file = ApplicationLoader.applicationContext.getFilesDir(); if (file != null) { - return file; + File cacheFile = new File(file, "cache/"); + cacheFile.mkdirs(); + if ((file.exists() || file.mkdirs()) && file.canWrite()) { + return cacheFile; + } } } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 8e6e48b2d..c984fc721 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -24,8 +24,8 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; - public static int BUILD_VERSION = 3155; - public static String BUILD_VERSION_STRING = "9.4.6"; + public static int BUILD_VERSION = 3160; + public static String BUILD_VERSION_STRING = "9.4.7"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index c2463ad46..ae51a0e71 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -33,6 +33,7 @@ import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; +import android.media.AudioDeviceInfo; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioRecord; @@ -52,6 +53,7 @@ import android.provider.OpenableColumns; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.util.Log; import android.util.SparseArray; import android.view.HapticFeedbackConstants; import android.view.TextureView; @@ -60,6 +62,8 @@ import android.view.WindowManager; import android.webkit.MimeTypeMap; import android.widget.FrameLayout; +import androidx.annotation.RequiresApi; + import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; @@ -95,6 +99,7 @@ import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.Timer; import java.util.TimerTask; @@ -1623,10 +1628,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (raisedToBack == minCount || accelerometerVertical) { lastAccelerometerDetected = System.currentTimeMillis(); } - if (proximityTouched && (raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60) && !NotificationsController.audioManager.isWiredHeadsetOn()) { - if (BuildVars.LOGS_ENABLED) { - FileLog.d("sensor values reached"); - } + if (proximityTouched && (raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60) && !NotificationsController.audioManager.isWiredHeadsetOn() && !VoIPService.isAnyKindOfCallActive()) { if (playingMessageObject == null && recordStartRunnable == null && recordingAudio == null && !PhotoViewer.getInstance().isVisible() && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress) { if (!raiseToEarRecord) { if (BuildVars.LOGS_ENABLED) { @@ -1663,7 +1665,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, raisedToTop = 0; raisedToTopSign = 0; countLess = 0; - } else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null)) { + } else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null) && !VoIPService.isAnyKindOfCallActive()) { if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { if (!useFrontSpeaker && !NotificationsController.audioManager.isWiredHeadsetOn()) { if (BuildVars.LOGS_ENABLED) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index c755f5b65..e031d1998 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -1546,6 +1546,9 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F parent.removeView(fragmentView); } } + if (!fragment.hasOwnBackground && fragmentView.getBackground() == null) { + fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); + } containerView.addView(fragmentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); if (fragment.actionBar != null && fragment.actionBar.shouldAddToContainer()) { if (removeActionBarExtraHeight) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java index 62fc9baba..6ac3276ed 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java @@ -984,5 +984,10 @@ public class ReactionsLayoutInBubble { VisibleReaction that = (VisibleReaction) o; return documentId == that.documentId && Objects.equals(emojicon, that.emojicon); } + + @Override + public int hashCode() { + return Objects.hash(emojicon, documentId); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java index 4eaaeaa03..c92f29983 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java @@ -977,7 +977,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio allReactionsAvailable = true; fillRecentReactionsList(visibleReactions); } - + filterReactions(visibleReactions); setVisibleReactionsList(visibleReactions); if (message.messageOwner.reactions != null && message.messageOwner.reactions.results != null) { @@ -989,6 +989,17 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio } } + private void filterReactions(List visibleReactions) { + HashSet set = new HashSet<>(); + for (int i = 0; i < visibleReactions.size(); i++) { + if (set.contains(visibleReactions.get(i))) { + i--; + visibleReactions.remove(i); + } + set.add(visibleReactions.get(i)); + } + } + private void fillRecentReactionsList(List visibleReactions) { if (!allReactionsAvailable) { //fill default reactions diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java index e87bcb821..e254b82c2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoPlayer.java @@ -11,6 +11,7 @@ package org.telegram.ui.Components; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.SurfaceTexture; +import android.media.AudioManager; import android.net.Uri; import android.os.Handler; import android.os.Looper; @@ -501,13 +502,13 @@ public class VideoPlayer implements Player.Listener, VideoListener, AnalyticsLis public void setStreamType(int type) { if (player != null) { player.setAudioAttributes(new AudioAttributes.Builder() - .setContentType(type) - .build(), false); + .setUsage(type == AudioManager.STREAM_VOICE_CALL ? C.USAGE_VOICE_COMMUNICATION : C.USAGE_MEDIA) + .build(), false); } if (audioPlayer != null) { audioPlayer.setAudioAttributes(new AudioAttributes.Builder() - .setContentType(type) - .build(), false); + .setUsage(type == AudioManager.STREAM_VOICE_CALL ? C.USAGE_VOICE_COMMUNICATION : C.USAGE_MEDIA) + .build(), true); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 650eac3cd..8f2124c52 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -1077,7 +1077,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati } private BaseFragment getClientNotActivatedFragment() { - if (LoginActivity.loadCurrentState(false).getInt("currentViewNum", 0) != 0) { + if (LoginActivity.loadCurrentState(false, currentAccount).getInt("currentViewNum", 0) != 0) { return new LoginActivity(); } return new IntroActivity(); @@ -2977,7 +2977,9 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati } } } - actionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); + if (SharedConfig.useLNavigation) { + actionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); + } if (AndroidUtilities.isTablet()) { layersActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); rightActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index aa75d0af8..100fda427 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -589,7 +589,7 @@ public class LoginActivity extends BaseFragment { slideViewsContainer.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0)); } - Bundle savedInstanceState = activityMode == MODE_LOGIN ? loadCurrentState(newAccount) : null; + Bundle savedInstanceState = activityMode == MODE_LOGIN ? loadCurrentState(newAccount, currentAccount) : null; if (savedInstanceState != null) { currentViewNum = savedInstanceState.getInt("currentViewNum", 0); syncContacts = savedInstanceState.getInt("syncContacts", 1) == 1; @@ -873,13 +873,10 @@ public class LoginActivity extends BaseFragment { } } - public static Bundle loadCurrentState(boolean newAccount) { - if (newAccount) { - return null; - } + public static Bundle loadCurrentState(boolean newAccount, int currentAccount) { try { Bundle bundle = new Bundle(); - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", Context.MODE_PRIVATE); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2" + (newAccount ? "_" + currentAccount : ""), Context.MODE_PRIVATE); Map params = preferences.getAll(); for (Map.Entry entry : params.entrySet()) { String key = entry.getKey(); @@ -916,7 +913,7 @@ public class LoginActivity extends BaseFragment { } private void clearCurrentState() { - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", Context.MODE_PRIVATE); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2" + (newAccount ? "_" + currentAccount : ""), Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear(); editor.commit(); @@ -1529,7 +1526,7 @@ public class LoginActivity extends BaseFragment { v.saveStateParams(bundle); } } - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2", Context.MODE_PRIVATE); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("logininfo2" + (newAccount ? "_" + currentAccount : ""), Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.clear(); putBundleToEditor(bundle, editor, null); @@ -3475,7 +3472,10 @@ public class LoginActivity extends BaseFragment { timeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); timeText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL); timeText.setOnClickListener(v-> { - if (isRequestingFirebaseSms || isResendingCode) { +// if (isRequestingFirebaseSms || isResendingCode) { +// return; +// } + if (time > 0 && timeTimer != null) { return; } isResendingCode = true; @@ -3994,9 +3994,11 @@ public class LoginActivity extends BaseFragment { if (currentType == AUTH_TYPE_MESSAGE) { setProblemTextVisible(true); timeText.setVisibility(GONE); + problemText.setVisibility(VISIBLE); } else if (currentType == AUTH_TYPE_FLASH_CALL && (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_SMS)) { setProblemTextVisible(false); timeText.setVisibility(VISIBLE); + problemText.setVisibility(GONE); if (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_MISSED_CALL) { timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, 1, 0)); } else if (nextType == AUTH_TYPE_SMS) { @@ -4014,6 +4016,7 @@ public class LoginActivity extends BaseFragment { timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, 2, 0)); setProblemTextVisible(time < 1000); timeText.setVisibility(time < 1000 ? GONE : VISIBLE); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); String hash = preferences.getString("sms_hash", null); @@ -4036,9 +4039,11 @@ public class LoginActivity extends BaseFragment { timeText.setText(LocaleController.formatString("SmsAvailableIn", R.string.SmsAvailableIn, 2, 0)); setProblemTextVisible(time < 1000); timeText.setVisibility(time < 1000 ? GONE : VISIBLE); + problemText.setVisibility(time < 1000 ? VISIBLE : GONE); createTimer(); } else { timeText.setVisibility(GONE); + problemText.setVisibility(VISIBLE); setProblemTextVisible(false); createCodeTimer(); } @@ -4090,6 +4095,7 @@ public class LoginActivity extends BaseFragment { if (codeTime <= 1000) { setProblemTextVisible(true); timeText.setVisibility(GONE); + problemText.setVisibility(VISIBLE); destroyCodeTimer(); } }); @@ -5889,6 +5895,10 @@ public class LoginActivity extends BaseFragment { showKeyboard(codeFieldContainer.codeField[0]); codeFieldContainer.requestFocus(); + + if (!restore && params.containsKey("nextType")) { + AndroidUtilities.runOnUIThread(resendCodeTimeout, params.getInt("timeout")); + } } private void onPasscodeError(boolean clear) { @@ -6141,8 +6151,6 @@ public class LoginActivity extends BaseFragment { codeFieldContainer.setText(""); codeFieldContainer.codeField[0].requestFocus(); } - - AndroidUtilities.runOnUIThread(resendCodeTimeout, 60000); }, SHOW_DELAY); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 4eea77ac8..2ac6f59b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1142,9 +1142,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } catch (Throwable e) { FileLog.e(e); AndroidUtilities.runOnUIThread(() -> { - RecyclerListView innerListView = sharedMediaLayout.getCurrentListView(); - if (innerListView != null && innerListView.getAdapter() != null) { - innerListView.getAdapter().notifyDataSetChanged(); + try { + RecyclerListView innerListView = sharedMediaLayout.getCurrentListView(); + if (innerListView != null && innerListView.getAdapter() != null) { + innerListView.getAdapter().notifyDataSetChanged(); + } + } catch (Throwable e2) { + } }); } diff --git a/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java b/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java index a14729569..e9f5ee622 100644 --- a/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java +++ b/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java @@ -18,7 +18,6 @@ import static org.webrtc.MediaCodecUtils.QCOM_PREFIX; import android.media.MediaCodecInfo; import android.os.Build; -import android.util.Log; import androidx.annotation.Nullable; @@ -162,20 +161,24 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) { ArrayList infos = MediaCodecUtils.getSortedCodecsList(); int count = infos.size(); + MediaCodecInfo info2 = null; for (int i = 0; i < count; ++i) { MediaCodecInfo info = infos.get(i); if (info == null || !info.isEncoder()) { continue; } - if (isSupportedCodec(info, type)) { + if (isSupportedCodec(info, type, true)) { return info; } + if (isSupportedCodec(info, type, false)) { + info2 = info; + } } - return null; // No support for this type. + return info2; // No support for this type. } // Returns true if the given MediaCodecInfo indicates a supported encoder for the given type. - private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecMimeType type) { + private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecMimeType type, boolean isHardwareSupportedInSdk) { if (!MediaCodecUtils.codecSupportsType(info, type)) { return false; } @@ -185,7 +188,7 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { == null) { return false; } - return isHardwareSupportedInCurrentSdk(info, type) && isMediaCodecAllowed(info); + return (!isHardwareSupportedInSdk || isHardwareSupportedInCurrentSdk(info, type)) && isMediaCodecAllowed(info); } // Returns true if the given MediaCodecInfo indicates a hardware module that is supported on the diff --git a/TMessagesProj/src/main/res/xml/provider_paths.xml b/TMessagesProj/src/main/res/xml/provider_paths.xml index 12d80cd18..4bb926990 100644 --- a/TMessagesProj/src/main/res/xml/provider_paths.xml +++ b/TMessagesProj/src/main/res/xml/provider_paths.xml @@ -1,5 +1,7 @@ + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 96f835ba6..5ab01576d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_NAME=9.4.6 -APP_VERSION_CODE=3155 +APP_VERSION_NAME=9.4.7 +APP_VERSION_CODE=3160 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=android RELEASE_KEY_ALIAS=androidkey