update to 9.6.5 (3356)

This commit is contained in:
xaxtix 2023-05-04 16:25:48 +04:00
parent 816ffc52f5
commit 7c62a5da96
29 changed files with 248 additions and 63 deletions

View file

@ -211,7 +211,7 @@ void resumeNetwork(JNIEnv *env, jclass c, jint instanceNum, jboolean partial) {
}
void updateDcSettings(JNIEnv *env, jclass c, jint instanceNum) {
ConnectionsManager::getInstance(instanceNum).updateDcSettings(0, false);
ConnectionsManager::getInstance(instanceNum).updateDcSettings(0, false, false);
}
void setIpStrategy(JNIEnv *env, jclass c, jint instanceNum, jbyte value) {

View file

@ -297,7 +297,7 @@ void ConnectionsManager::select() {
sendPing(datacenter, false);
}
if (abs((int32_t) (now / 1000) - lastDcUpdateTime) >= DC_UPDATE_TIME) {
updateDcSettings(0, false);
updateDcSettings(0, false, false);
}
processRequestQueue(0, 0);
} else if (!datacenter->isHandshakingAny()) {
@ -1914,7 +1914,7 @@ void ConnectionsManager::setUserId(int64_t userId) {
registerForInternalPushUpdates();
}
if (currentUserId != userId && userId != 0) {
updateDcSettings(0, false);
updateDcSettings(0, false, false);
}
if (currentUserId != 0 && pushConnectionEnabled) {
Datacenter *datacenter = getDatacenterWithId(currentDatacenterId);
@ -2773,7 +2773,7 @@ void ConnectionsManager::processRequestQueue(uint32_t connectionTypes, uint32_t
}
if (!unknownDatacenterIds.empty()) {
updateDcSettings(0, false);
updateDcSettings(0, false, false);
}
size_t count = neededDatacenters.size();
@ -3004,7 +3004,7 @@ inline std::string decodeSecret(std::string secret) {
return base64UrlDecode(secret);
}
void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround) {
void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround, bool ifLoadingTryAgain) {
if (workaround) {
if (updatingDcSettingsWorkaround) {
return;
@ -3012,6 +3012,10 @@ void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround) {
updatingDcSettingsWorkaround = true;
} else {
if (updatingDcSettings) {
if (ifLoadingTryAgain) {
updatingDcSettingsAgain = true;
updatingDcSettingsAgainDcNum = dcNum;
}
return;
}
updatingDcSettings = true;
@ -3023,6 +3027,14 @@ void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround) {
if ((!workaround && !updatingDcSettings) || (workaround && !updatingDcSettingsWorkaround)) {
return;
}
if (!workaround && updatingDcSettingsAgain) {
updatingDcSettingsAgain = false;
for (auto & datacenter : datacenters) {
datacenter.second->resetInitVersion();
}
updateDcSettings(updatingDcSettingsAgainDcNum, false, false);
return;
}
if (response != nullptr) {
auto config = (TL_config *) response;
@ -3143,7 +3155,7 @@ void ConnectionsManager::moveToDatacenter(uint32_t datacenterId) {
void ConnectionsManager::authorizeOnMovingDatacenter() {
Datacenter *datacenter = getDatacenterWithId(movingToDatacenterId);
if (datacenter == nullptr) {
updateDcSettings(0, false);
updateDcSettings(0, false, false);
return;
}
datacenter->recreateSessions(HandshakeTypeAll);
@ -3194,7 +3206,7 @@ void ConnectionsManager::applyDatacenterAddress(uint32_t datacenterId, std::stri
if (datacenter->isHandshakingAny()) {
datacenter->beginHandshake(HandshakeTypeCurrent, true);
}
updateDcSettings(datacenterId, false);
updateDcSettings(datacenterId, false, false);
}
});
}
@ -3287,7 +3299,7 @@ void ConnectionsManager::applyDnsConfig(NativeByteBuffer *buffer, std::string ph
if (datacenter->isHandshakingAny()) {
datacenter->beginHandshake(HandshakeTypeCurrent, true);
}
updateDcSettings(rule->dc_id, true);
updateDcSettings(rule->dc_id, true, false);
}
} else {
if (LOGS_ENABLED) DEBUG_D("config datacenter %d not found", rule->dc_id);
@ -3373,7 +3385,7 @@ void ConnectionsManager::init(uint32_t version, int32_t layer, int32_t apiId, st
pthread_create(&networkThread, nullptr, (ConnectionsManager::ThreadProc), this);
if (needLoadConfig) {
updateDcSettings(0, false);
updateDcSettings(0, false, false);
}
}
@ -3439,7 +3451,7 @@ void ConnectionsManager::setRegId(std::string regId) {
for (auto & datacenter : datacenters) {
datacenter.second->resetInitVersion();
}
updateDcSettings(0, false);
updateDcSettings(0, false, true);
saveConfig();
});
}
@ -3454,7 +3466,7 @@ void ConnectionsManager::setSystemLangCode(std::string langCode) {
datacenter.second->resetInitVersion();
}
saveConfig();
updateDcSettings(0, false);
updateDcSettings(0, false, false);
});
}

View file

@ -69,7 +69,7 @@ public:
void setLangCode(std::string langCode);
void setRegId(std::string regId);
void setSystemLangCode(std::string langCode);
void updateDcSettings(uint32_t datacenterId, bool workaround);
void updateDcSettings(uint32_t datacenterId, bool workaround, bool ifLoadingTryAgain);
void setPushConnectionEnabled(bool value);
void applyDnsConfig(NativeByteBuffer *buffer, std::string phone, int32_t date);
int64_t checkProxy(std::string address, uint16_t port, std::string username, std::string password, std::string secret, onRequestTimeFunc requestTimeFunc, jobject ptr1);
@ -151,6 +151,8 @@ private:
bool sendingPushPing = false;
bool sendingPing = false;
bool updatingDcSettings = false;
bool updatingDcSettingsAgain = false;
uint32_t updatingDcSettingsAgainDcNum = 0;
bool updatingDcSettingsWorkaround = false;
int32_t disconnectTimeoutAmount = 0;
bool requestingSecondAddressByTlsHashMismatch = false;

View file

@ -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 = 3344;
public static String BUILD_VERSION_STRING = "9.6.3";
public static int BUILD_VERSION = 3356;
public static String BUILD_VERSION_STRING = "9.6.5";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -53,7 +53,6 @@ import android.provider.OpenableColumns;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import android.view.HapticFeedbackConstants;
@ -1487,6 +1486,33 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return proximityTouched && (isRecordingAudio() || playingMessageObject != null && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()));
}
private boolean forbidRaiseToListen() {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
AudioDeviceInfo[] devices = NotificationsController.audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
for (AudioDeviceInfo device : devices) {
final int type = device.getType();
if ((
type == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP ||
type == AudioDeviceInfo.TYPE_BLUETOOTH_SCO ||
type == AudioDeviceInfo.TYPE_BLE_HEADSET ||
type == AudioDeviceInfo.TYPE_BLE_SPEAKER ||
type == AudioDeviceInfo.TYPE_WIRED_HEADPHONES ||
type == AudioDeviceInfo.TYPE_WIRED_HEADSET
) && device.isSink()) {
return true;
}
}
return false;
} else {
return NotificationsController.audioManager.isWiredHeadsetOn() || NotificationsController.audioManager.isBluetoothA2dpOn() || NotificationsController.audioManager.isBluetoothScoOn();
}
} catch (Exception e) {
FileLog.e(e);
}
return false;
}
@Override
public void onSensorChanged(SensorEvent event) {
if (!sensorsStarted || VoIPService.getSharedInstance() != null) {
@ -1644,7 +1670,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() && !NotificationsController.audioManager.isBluetoothA2dpOn() && !VoIPService.isAnyKindOfCallActive() && !manualRecording) {
if (proximityTouched && (raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60) && !VoIPService.isAnyKindOfCallActive() && !manualRecording && !forbidRaiseToListen()) {
if (SharedConfig.enabledRaiseTo(true) && playingMessageObject == null && recordStartRunnable == null && recordingAudio == null && !PhotoViewer.getInstance().isVisible() && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress) {
if (!raiseToEarRecord) {
if (BuildVars.LOGS_ENABLED) {
@ -1683,7 +1709,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
countLess = 0;
} else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null || ignoreAccelerometerGestures()) && !VoIPService.isAnyKindOfCallActive()) {
if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()) && SharedConfig.enabledRaiseTo(false)) {
if (!useFrontSpeaker && !NotificationsController.audioManager.isWiredHeadsetOn() && !NotificationsController.audioManager.isBluetoothA2dpOn() && !manualRecording) {
if (!useFrontSpeaker && !manualRecording && !forbidRaiseToListen()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("start listen by proximity only");
}
@ -3418,7 +3444,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return true;
}
private boolean ignoreAccelerometerGestures() {
public static boolean ignoreAccelerometerGestures() {
return Build.MANUFACTURER.equalsIgnoreCase("samsung");
}

View file

@ -213,7 +213,8 @@ public class NotificationsSettingsFacade {
} else {
String path = NotificationsSoundActivity.findRingtonePathByName(localSound.title);
if (path == null) {
settings = new TLRPC.TL_notificationSoundDefault();
// settings = new TLRPC.TL_notificationSoundDefault();
return;
} else {
localSound.data = path;
}

View file

@ -1284,10 +1284,12 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
globalCount = 4;
}
int contactsCount = searchContacts.size();
if (i >= 0 && i < contactsCount) {
return false;
if (contactsCount > 0) {
if (i >= 0 && i < contactsCount) {
return false;
}
i -= contactsCount + 1;
}
i -= contactsCount + 1;
if (i >= 0 && i < localCount) {
return false;
}

View file

@ -12073,7 +12073,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
loadingProgressLayout = null;
return;
}
long hash = loadedSize << 16 + totalSize;
long hash = (loadedSize << 16) + totalSize;
if (loadingProgressLayout != null && loadingProgressLayoutHash == hash) {
return;
}

View file

@ -72,6 +72,7 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.AnimationNotificationsLocker;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.AutoDeleteMediaTask;
import org.telegram.messenger.BuildVars;
@ -597,7 +598,13 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
if (!initCamera()) {
return;
}
MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject());
if (MediaController.getInstance().getPlayingMessageObject() != null) {
if (MediaController.getInstance().getPlayingMessageObject().isVideo() || MediaController.getInstance().getPlayingMessageObject().isRoundVideo()) {
MediaController.getInstance().cleanupPlayer(true, true);
} else {
MediaController.getInstance().pauseMessage(MediaController.getInstance().getPlayingMessageObject());
}
}
cameraFile = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_DOCUMENT), System.currentTimeMillis() + "_" + SharedConfig.getLastLocalId() + ".mp4") {
@Override
@ -1571,8 +1578,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
GLES20.glGenTextures(1, cameraTexture, 0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexture[0]);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
@ -2089,20 +2096,31 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
FileLog.e(e);
}
long dt, alphaDt;
boolean cameraChanged = false;
if (!lastCameraId.equals(cameraId)) {
if (timestampNanos - lastTimestamp > 10_000) {
lastTimestamp = -1;
}
cameraChanged = true;
lastCameraId = cameraId;
}
if (lastTimestamp == -1) {
lastTimestamp = timestampNanos;
if (cameraChanged || lastTimestamp == -1) {
if (currentTimestamp != 0) {
dt = (System.currentTimeMillis() - lastCommitedFrameTime) * 1000000;
//real dt lead to asynchron aduio and video
//surface may return wrong measured timestamp so big or negative
// `\_(._.)_/`
long dtTimestamps = (timestampNanos - lastTimestamp);
long dtReal = (System.currentTimeMillis() - lastCommitedFrameTime) * 1000000;
if (dtTimestamps < 0 || Math.abs(dtReal - dtTimestamps) > 100_000_000) {
dt = dtReal;
} else {
dt = dtTimestamps;
}
if (dt < 0) {
dt = 0;
}
alphaDt = 0;
} else {
alphaDt = dt = 0;
}
lastTimestamp = timestampNanos;
} else {
alphaDt = dt = (timestampNanos - lastTimestamp);
lastTimestamp = timestampNanos;
@ -2749,7 +2767,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
}
private String createFragmentShader(Size previewSize) {
if (!SharedConfig.deviceIsHigh() || !allowBigSizeCamera() || Math.max(previewSize.getHeight(), previewSize.getWidth()) * 0.7f < MessagesController.getInstance(currentAccount).roundVideoSize) {
if (SharedConfig.deviceIsLow() || !allowBigSizeCamera() || Math.max(previewSize.getHeight(), previewSize.getWidth()) * 0.7f < MessagesController.getInstance(currentAccount).roundVideoSize) {
return "#extension GL_OES_EGL_image_external : require\n" +
"precision highp float;\n" +
"varying vec2 vTextureCoord;\n" +
@ -2767,12 +2785,12 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
" gl_FragColor = vec4(color * alpha, alpha);\n" +
"}\n";
}
//apply box blur
//apply bilinear filtering
return "#extension GL_OES_EGL_image_external : require\n" +
"precision highp float;\n" +
"varying vec2 vTextureCoord;\n" +
"uniform vec2 resolution;\n" +
"uniform vec2 preview;\n" +
"uniform vec2 preview;\n" +// original texture size
"uniform float alpha;\n" +
"uniform samplerExternalOES sTexture;\n" +
@ -2782,16 +2800,22 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
" float d = length(coord - gl_FragCoord.xy) - radius;\n" +
" float t = clamp(d, 0.0, 1.0);\n" +
" if (t == 0.0) {\n" +
" float pixelSizeX = 1.0 / preview.x;\n" +
" float pixelSizeY = 1.0 / preview.y;\n" +
" vec3 accumulation = vec3(0);\n" +
" for (float x = 0.0; x < 2.0; x++){\n" +
" for (float y = 0.0; y < 2.0; y++){\n" +
" accumulation += texture2D(sTexture, vTextureCoord + vec2(x * pixelSizeX, y * pixelSizeY)).xyz;\n" +
" }\n" +
" }\n" +
" vec4 textColor = vec4(accumulation / vec3(4, 4, 4), 1);\n" +
" gl_FragColor = textColor * alpha;\n" +
" vec2 c_textureSize = preview;\n" +
" vec2 c_onePixel = (1.0 / c_textureSize);\n" +
" vec2 uv = vTextureCoord;\n" +
" vec2 pixel = uv * c_textureSize + 0.5;\n" +
" vec2 frac = fract(pixel);\n" +
" pixel = (floor(pixel) / c_textureSize) - vec2(c_onePixel);\n" +
" vec4 tl = texture2D(sTexture, pixel + vec2(0.0 , 0.0));\n" +
" vec4 tr = texture2D(sTexture, pixel + vec2(c_onePixel.x, 0.0));\n" +
" vec4 bl = texture2D(sTexture, pixel + vec2(0.0 , c_onePixel.y));\n" +
" vec4 br = texture2D(sTexture, pixel + vec2(c_onePixel.x, c_onePixel.y));\n" +
" vec4 x1 = mix(tl, tr, frac.x);\n" +
" vec4 x2 = mix(bl, br, frac.x);\n" +
" gl_FragColor = mix(x1, x2, frac.y) * alpha;" +
" } else {\n" +
" gl_FragColor = vec4(1, 1, 1, alpha);\n" +
" }\n" +

View file

@ -5,6 +5,7 @@ import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
@ -29,13 +30,15 @@ public class ProxyDrawable extends Drawable {
private boolean connected;
private boolean isEnabled;
private int colorKey = -1;
public ProxyDrawable(Context context) {
super();
emptyDrawable = context.getResources().getDrawable(R.drawable.proxy_off);
fullDrawable = context.getResources().getDrawable(R.drawable.proxy_on);
emptyDrawable = context.getResources().getDrawable(R.drawable.msg2_proxy_off);
fullDrawable = context.getResources().getDrawable(R.drawable.msg2_proxy_on);
outerPaint.setStyle(Paint.Style.STROKE);
outerPaint.setStrokeWidth(AndroidUtilities.dp(2));
outerPaint.setStrokeWidth(AndroidUtilities.dp(1.66f));
outerPaint.setStrokeCap(Paint.Cap.ROUND);
lastUpdateTime = SystemClock.elapsedRealtime();
}
@ -57,13 +60,13 @@ public class ProxyDrawable extends Drawable {
lastUpdateTime = newTime;
if (!isEnabled) {
emptyDrawable.setBounds(getBounds());
setBounds(emptyDrawable);
emptyDrawable.draw(canvas);
} else if (!connected || connectedAnimationProgress != 1.0f) {
emptyDrawable.setBounds(getBounds());
setBounds(emptyDrawable);
emptyDrawable.draw(canvas);
outerPaint.setColor(Theme.getColor(Theme.key_contextProgressOuter2));
outerPaint.setColor(Theme.getColor(colorKey < 0 ? Theme.key_contextProgressOuter2 : colorKey));
outerPaint.setAlpha((int) (255 * (1.0f - connectedAnimationProgress)));
radOffset += 360 * dt / 1000.0f;
@ -71,16 +74,17 @@ public class ProxyDrawable extends Drawable {
int width = getBounds().width();
int height = getBounds().height();
int x = width / 2 - AndroidUtilities.dp(3);
int y = height / 2 - AndroidUtilities.dp(3);
cicleRect.set(x, y, x + AndroidUtilities.dp(6), y + AndroidUtilities.dp(6));
int r = AndroidUtilities.dp(4);
int x = width / 2 - r;
int y = height / 2 - r;
cicleRect.set(x, y, x + r + r, y + r + r);
canvas.drawArc(cicleRect, -90 + radOffset, 90, false, outerPaint);
invalidateSelf();
}
if (isEnabled && (connected || connectedAnimationProgress != 0.0f)) {
fullDrawable.setAlpha((int) (255 * connectedAnimationProgress));
fullDrawable.setBounds(getBounds());
setBounds(fullDrawable);
fullDrawable.draw(canvas);
}
@ -99,6 +103,16 @@ public class ProxyDrawable extends Drawable {
}
}
private void setBounds(Drawable drawable) {
Rect bounds = getBounds();
drawable.setBounds(
bounds.centerX() - drawable.getIntrinsicWidth() / 2,
bounds.centerY() - drawable.getIntrinsicHeight() / 2,
bounds.centerX() + drawable.getIntrinsicWidth() / 2,
bounds.centerY() + drawable.getIntrinsicHeight() / 2
);
}
@Override
public void setAlpha(int alpha) {
@ -110,6 +124,10 @@ public class ProxyDrawable extends Drawable {
fullDrawable.setColorFilter(cf);
}
public void setColorKey(int colorKey) {
this.colorKey = colorKey;
}
@Override
public int getOpacity() {
return PixelFormat.TRANSPARENT;

View file

@ -7158,8 +7158,8 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
} else {
boolean allow = true; // TODO: Make it a flag inside fragment itself, maybe BaseFragment#isDrawerOpenAllowed()?
if (fragment instanceof LoginActivity || fragment instanceof IntroActivity) {
if (mainFragmentsStack.size() == 0 || mainFragmentsStack.get(0) instanceof IntroActivity) {
if (fragment instanceof LoginActivity || fragment instanceof IntroActivity || fragment instanceof ProxyListActivity) {
if (mainFragmentsStack.size() == 0 || mainFragmentsStack.get(0) instanceof IntroActivity || mainFragmentsStack.get(0) instanceof LoginActivity) {
allow = false;
}
} else if (fragment instanceof CountrySelectActivity) {
@ -7175,7 +7175,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
@Override
public boolean needAddFragmentToStack(BaseFragment fragment, INavigationLayout layout) {
if (AndroidUtilities.isTablet()) {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof IntroActivity || fragment instanceof CountrySelectActivity) && layersActionBarLayout.getView().getVisibility() != View.VISIBLE, true);
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity || fragment instanceof IntroActivity || fragment instanceof CountrySelectActivity || fragment instanceof ProxyListActivity) && layersActionBarLayout.getView().getVisibility() != View.VISIBLE, true);
if (fragment instanceof DialogsActivity) {
DialogsActivity dialogsActivity = (DialogsActivity) fragment;
if (dialogsActivity.isMainDialogList() && layout != actionBarLayout) {
@ -7241,7 +7241,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
} else {
boolean allow = true;
if (fragment instanceof LoginActivity || fragment instanceof IntroActivity) {
if (fragment instanceof LoginActivity || fragment instanceof IntroActivity || fragment instanceof ProxyListActivity) {
if (mainFragmentsStack.size() == 0 || mainFragmentsStack.get(0) instanceof IntroActivity) {
allow = false;
}

View file

@ -98,6 +98,7 @@ import com.google.zxing.common.detector.MathUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.AuthTokensHelper;
@ -147,6 +148,7 @@ import org.telegram.ui.Components.LinkPath;
import org.telegram.ui.Components.LoadingDrawable;
import org.telegram.ui.Components.LoginOrView;
import org.telegram.ui.Components.OutlineTextContainerView;
import org.telegram.ui.Components.ProxyDrawable;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.RadialProgressView;
@ -179,7 +181,7 @@ import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicReference;
@SuppressLint("HardwareIds")
public class LoginActivity extends BaseFragment {
public class LoginActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public final static boolean ENABLE_PASTED_TEXT_PROCESSING = false;
private final static int SHOW_DELAY = SharedConfig.getDevicePerformanceClass() <= SharedConfig.PERFORMANCE_CLASS_AVERAGE ? 150 : 100;
@ -307,6 +309,9 @@ public class LoginActivity extends BaseFragment {
private ImageView backButtonView;
private RadialProgressView radialProgressView;
private ImageView proxyButtonView;
private ProxyDrawable proxyDrawable;
// Open animation stuff
private LinearLayout keyboardLinearLayout;
private FrameLayout slideViewsContainer;
@ -453,6 +458,13 @@ public class LoginActivity extends BaseFragment {
AndroidUtilities.cancelRunOnUIThread(callback);
}
}
getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateConnectionState);
}
@Override
public boolean onFragmentCreate() {
getNotificationCenter().addObserver(this, NotificationCenter.didUpdateConnectionState);
return super.onFragmentCreate();
}
@Override
@ -494,6 +506,9 @@ public class LoginActivity extends BaseFragment {
marginLayoutParams = (MarginLayoutParams) backButtonView.getLayoutParams();
marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight;
marginLayoutParams = (MarginLayoutParams) proxyButtonView.getLayoutParams();
marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight;
marginLayoutParams = (MarginLayoutParams) radialProgressView.getLayoutParams();
marginLayoutParams.topMargin = AndroidUtilities.dp(16) + statusBarHeight;
@ -657,6 +672,14 @@ public class LoginActivity extends BaseFragment {
backButtonView.setPadding(padding, padding, padding, padding);
sizeNotifierFrameLayout.addView(backButtonView, LayoutHelper.createFrame(32, 32, Gravity.LEFT | Gravity.TOP, 16, 16, 0, 0));
proxyButtonView = new ImageView(context);
proxyButtonView.setImageDrawable(proxyDrawable = new ProxyDrawable(context));
proxyButtonView.setOnClickListener(v -> presentFragment(new ProxyListActivity()));
proxyButtonView.setAlpha(0f);
proxyButtonView.setVisibility(View.GONE);
sizeNotifierFrameLayout.addView(proxyButtonView, LayoutHelper.createFrame(32, 32, Gravity.RIGHT | Gravity.TOP, 16, 16, 16, 16));
updateProxyButton(false, true);
radialProgressView = new RadialProgressView(context);
radialProgressView.setSize(AndroidUtilities.dp(20));
radialProgressView.setAlpha(0);
@ -7881,6 +7904,10 @@ public class LoginActivity extends BaseFragment {
backButtonView.setColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
backButtonView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
proxyDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.SRC_IN));
proxyDrawable.setColorKey(Theme.key_windowBackgroundWhiteBlackText);
proxyButtonView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
radialProgressView.setProgressColor(Theme.getColor(Theme.key_chats_actionBackground));
floatingButtonIcon.setColor(Theme.getColor(Theme.key_chats_actionIcon));
@ -8212,4 +8239,77 @@ public class LoginActivity extends BaseFragment {
int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true);
return ColorUtils.calculateLuminance(color) > 0.7f;
}
private int currentConnectionState;
private void updateProxyButton(boolean animated, boolean force) {
if (proxyDrawable == null) {
return;
}
int state = getConnectionsManager().getConnectionState();
if (currentConnectionState == state && !force) {
return;
}
currentConnectionState = state;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
String proxyAddress = preferences.getString("proxy_ip", "");
final boolean proxyEnabled = preferences.getBoolean("proxy_enabled", false);
final boolean connected = currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating;
final boolean connecting = currentConnectionState == ConnectionsManager.ConnectionStateConnecting || currentConnectionState == ConnectionsManager.ConnectionStateWaitingForNetwork || currentConnectionState == ConnectionsManager.ConnectionStateConnectingToProxy;
final boolean show = (proxyEnabled && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty() || connecting;
if (show) {
showProxyButtonDelayed();
} else {
showProxyButton(show, animated);
}
if (show) {
proxyDrawable.setConnected(true, connected, animated);
}
}
private boolean proxyButtonVisible;
private Runnable showProxyButtonDelayed;
private void showProxyButtonDelayed() {
if (proxyButtonVisible) {
return;
}
if (showProxyButtonDelayed != null) {
AndroidUtilities.cancelRunOnUIThread(showProxyButtonDelayed);
}
proxyButtonVisible = true;
AndroidUtilities.runOnUIThread(showProxyButtonDelayed = () -> {
proxyButtonVisible = false;
showProxyButton(true, true);
}, 5000);
}
private void showProxyButton(boolean show, boolean animated) {
if (show == proxyButtonVisible) {
return;
}
if (showProxyButtonDelayed != null) {
AndroidUtilities.cancelRunOnUIThread(showProxyButtonDelayed);
showProxyButtonDelayed = null;
}
proxyButtonVisible = show;
proxyButtonView.clearAnimation();
if (animated) {
proxyButtonView.setVisibility(View.VISIBLE);
proxyButtonView.animate().alpha(show ? 1 : 0).withEndAction(() -> {
if (!show) {
proxyButtonView.setVisibility(View.GONE);
}
}).start();
} else {
proxyButtonView.setVisibility(show ? View.VISIBLE : View.GONE);
proxyButtonView.setAlpha(show ? 1f : 0f);
}
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.didUpdateConnectionState) {
updateProxyButton(true, false);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 887 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

View file

@ -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_CODE=3344
APP_VERSION_NAME=9.6.3
APP_VERSION_CODE=3356
APP_VERSION_NAME=9.6.5
APP_PACKAGE=org.telegram.messenger
RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey
@ -25,4 +25,4 @@ org.gradle.parallel=true
org.gradle.configureondemand=false
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.defaults.buildfeatures.buildconfig=true