update to 9.5.2

This commit is contained in:
xaxtix 2023-03-11 00:20:59 +04:00
parent 1a48adbec4
commit 1dcd153fe2
43 changed files with 587 additions and 142 deletions

View file

@ -136,7 +136,7 @@ NativeRegistration::NativeRegistration(JNIEnv* jni, jclass clazz)
NativeRegistration::~NativeRegistration() {
RTC_LOG(LS_INFO) << "NativeRegistration::dtor";
jni_->UnregisterNatives(j_class_);
//jni_->UnregisterNatives(j_class_);
CHECK_EXCEPTION(jni_) << "Error during UnregisterNatives";
}

View file

@ -1878,6 +1878,7 @@ public class AndroidUtilities {
}
public static ArrayList<File> getRootDirs() {
HashSet<String> pathes = new HashSet<>();
ArrayList<File> result = null;
if (Build.VERSION.SDK_INT >= 19) {
File[] dirs = ApplicationLoader.applicationContext.getExternalFilesDirs(null);
@ -1898,7 +1899,10 @@ public class AndroidUtilities {
continue;
}
}
result.add(file);
if (file != null && !pathes.contains(file.getAbsolutePath())) {
pathes.add(file.getAbsolutePath());
result.add(file);
}
}
}
}
@ -1907,7 +1911,10 @@ public class AndroidUtilities {
result = new ArrayList<>();
}
if (result.isEmpty()) {
result.add(Environment.getExternalStorageDirectory());
File dir = Environment.getExternalStorageDirectory();
if (dir != null && !pathes.contains(dir.getAbsolutePath())) {
result.add(dir);
}
}
return result;
}
@ -1919,7 +1926,9 @@ public class AndroidUtilities {
} catch (Exception e) {
FileLog.e(e);
}
if (state == null || state.startsWith(Environment.MEDIA_MOUNTED)) {
FileLog.d("external dir mounted");
try {
File file;
if (Build.VERSION.SDK_INT >= 19) {
@ -1936,16 +1945,20 @@ public class AndroidUtilities {
} else {
file = ApplicationLoader.applicationContext.getExternalCacheDir();
}
FileLog.d("check dir " + (file == null ? null : file.getPath()) + " ");
if (file != null && (file.exists() || file.mkdirs()) && file.canWrite()) {
boolean canWrite = true;
try {
AndroidUtilities.createEmptyFile(new File(file, ".nomedia"));
} catch (Exception e) {
canWrite = false;
}
if (canWrite) {
return file;
}
// boolean canWrite = true;
// try {
// AndroidUtilities.createEmptyFile(new File(file, ".nomedia"));
// } catch (Exception e) {
// canWrite = false;
// }
// if (canWrite) {
// return file;
// }
return file;
} else if (file != null) {
FileLog.d("check dir file exist " + file.exists() + " can write " + file.canWrite());
}
} catch (Exception e) {
FileLog.e(e);

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 = 3199;
public static String BUILD_VERSION_STRING = "9.5.1";
public static int BUILD_VERSION = 3208;
public static String BUILD_VERSION_STRING = "9.5.2";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -41,7 +41,7 @@ public class CacheByChatsController {
} else if (type == KEEP_MEDIA_TYPE_GROUP) {
return KEEP_MEDIA_ONE_MONTH;
} else if (type == KEEP_MEDIA_TYPE_CHANNEL) {
return KEEP_MEDIA_ONE_MONTH;
return KEEP_MEDIA_ONE_WEEK;
}
return SharedConfig.keepMedia;
}

View file

@ -1234,6 +1234,13 @@ public class DatabaseMigrationHelper {
version = 113;
}
if (version == 113) {
//fix issue when database file was deleted
//just reload dialogs
messagesStorage.reset();
database.executeFast("PRAGMA user_version = 114").stepThis().dispose();
version = 114;
}
return version;
}

View file

@ -545,10 +545,9 @@ public class FileLoadOperation {
filePartsStream.write(filesQueueByteBuffer.buf, 0, bufferSize);
}
} catch (Exception e) {
FileLog.e(e, false);
if (AndroidUtilities.isENOSPC(e)) {
LaunchActivity.checkFreeDiscSpaceStatic(1);
} else {
FileLog.e(e);
}
}
totalTime += System.currentTimeMillis() - time;
@ -881,6 +880,7 @@ public class FileLoadOperation {
} catch (Exception e) {
if (AndroidUtilities.isENOSPC(e)) {
LaunchActivity.checkFreeDiscSpaceStatic(1);
FileLog.e(e, false);
} else {
FileLog.e(e);
}
@ -1044,6 +1044,7 @@ public class FileLoadOperation {
requestedBytesCount = downloadedBytes = 0;
if (AndroidUtilities.isENOSPC(e)) {
LaunchActivity.checkFreeDiscSpaceStatic(1);
FileLog.e(e, false);
} else {
FileLog.e(e);
}
@ -1059,12 +1060,11 @@ public class FileLoadOperation {
fileOutputStream.seek(downloadedBytes);
}
} catch (Exception e) {
FileLog.e(e, false);
if (AndroidUtilities.isENOSPC(e)) {
LaunchActivity.checkFreeDiscSpaceStatic(1);
onFail(true, -1);
return false;
} else {
FileLog.e(e, false);
}
}
if (fileOutputStream == null) {
@ -1091,11 +1091,11 @@ public class FileLoadOperation {
delegate.saveFilePath(pathSaveData, null);
}
} catch (Exception e) {
FileLog.e(e, false);
if (AndroidUtilities.isENOSPC(e)) {
LaunchActivity.checkFreeDiscSpaceStatic(1);
onFail(true, -1);
} else {
FileLog.e(e, false);
onFail(true, 0);
}
}
@ -1772,10 +1772,10 @@ public class FileLoadOperation {
startDownloadRequest();
}
} catch (Exception e) {
FileLog.e(e, !AndroidUtilities.isFilNotFoundException(e) && !AndroidUtilities.isENOSPC(e));
if (AndroidUtilities.isENOSPC(e)) {
onFail(false, -1);
} else {
FileLog.e(e, !AndroidUtilities.isFilNotFoundException(e));
onFail(false, 0);
}
}
@ -1835,6 +1835,9 @@ public class FileLoadOperation {
cleanup();
state = reason == 1 ? stateCanceled : stateFailed;
if (delegate != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("failed downloading file to " + cacheFileFinal + " reason = " + reason + " time = " + (System.currentTimeMillis() - startTime) + " dc = " + datacenterId + " size = " + AndroidUtilities.formatFileSize(totalBytesCount));
}
if (thread) {
Utilities.stageQueue.postRunnable(() -> delegate.didFailedLoadingFile(FileLoadOperation.this, reason));
} else {

View file

@ -1679,7 +1679,9 @@ public class FileLoader extends BaseController {
Runnable dumpFilesQueueRunnable = () -> {
for (int i = 0; i < smallFilesQueue.length; i++) {
FileLog.d("download queue: dc" + (i + 1) + " account=" + currentAccount + " small_operations=" + smallFilesQueue[i].allOperations.size() + " large_operations=" + largeFilesQueue[i].allOperations.size());
if (smallFilesQueue[i].allOperations.size() > 0 || largeFilesQueue[i].allOperations.size() > 0) {
FileLog.d("download queue: dc" + (i + 1) + " account=" + currentAccount + " small_operations=" + smallFilesQueue[i].allOperations.size() + " large_operations=" + largeFilesQueue[i].allOperations.size());
}
}
dumpFilesQueue();
};

View file

@ -2176,9 +2176,18 @@ public class ImageLoader {
}
public void checkMediaPaths() {
checkMediaPaths(null);
}
public void checkMediaPaths(Runnable after) {
cacheOutQueue.postRunnable(() -> {
final SparseArray<File> paths = createMediaPaths();
AndroidUtilities.runOnUIThread(() -> FileLoader.setMediaDirs(paths));
AndroidUtilities.runOnUIThread(() -> {
FileLoader.setMediaDirs(paths);
if (after != null) {
after.run();
}
});
});
}

View file

@ -61,11 +61,10 @@ public class LiteMode {
FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM |
FLAG_ANIMATED_EMOJI_CHAT |
FLAG_CHAT_FORUM_TWOCOLUMN |
FLAG_CHAT_BLUR |
FLAG_CALLS_ANIMATIONS |
FLAG_AUTOPLAY_VIDEOS |
FLAG_AUTOPLAY_GIFS
); // 8031
); // 7775
public static int PRESET_HIGH = (
FLAGS_ANIMATED_STICKERS |
FLAGS_ANIMATED_EMOJI |
@ -255,7 +254,7 @@ public class LiteMode {
}
public static void savePreference() {
MessagesController.getGlobalMainSettings().edit().putInt("lite_mode", value).putInt("lite_mode_battery_level", powerSaverLevel).apply();
MessagesController.getGlobalMainSettings().edit().putInt("lite_mode2", value).putInt("lite_mode_battery_level", powerSaverLevel).apply();
}
public static int getPowerSaverLevel() {

View file

@ -18,6 +18,7 @@ import android.content.res.Configuration;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Log;
import android.util.Xml;
import androidx.annotation.StringRes;
@ -39,7 +40,9 @@ import java.util.Collection;
import java.util.Currency;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
public class LocaleController {
@ -487,17 +490,65 @@ public class LocaleController {
}
}
private boolean checkingUpdateForCurrentRemoteLocale;
public void checkUpdateForCurrentRemoteLocale(int currentAccount, int version, int baseVersion) {
if (currentLocaleInfo == null || !currentLocaleInfo.isRemote() && !currentLocaleInfo.isUnofficial()) {
return;
}
if (currentLocaleInfo.hasBaseLang()) {
if (currentLocaleInfo.baseVersion < baseVersion) {
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, currentAccount, null);
checkingUpdateForCurrentRemoteLocale = true;
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, currentAccount, () -> {
checkingUpdateForCurrentRemoteLocale = false;
checkPatchLangpack(currentAccount);
});
}
}
if (currentLocaleInfo.version < version) {
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, currentAccount, null);
checkingUpdateForCurrentRemoteLocale = true;
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, currentAccount, () -> {
checkingUpdateForCurrentRemoteLocale = false;
checkPatchLangpack(currentAccount);
});
}
}
public int calculateTranslatedCount(HashMap<String, String> map) {
int count = 0;
HashSet<String> added = new HashSet<>();
for (String k : map.keySet()) {
if (k == null) {
continue;
}
String real = null;
if (k.endsWith("_other")) {
real = k.substring(0, k.length() - 6);
} else if (k.endsWith("_zero") || k.endsWith("_many")) {
real = k.substring(0, k.length() - 5);
} else if (k.endsWith("_one") || k.endsWith("_two") || k.endsWith("_few")) {
real = k.substring(0, k.length() - 4);
}
if (real == null) {
count++;
} else if (!added.contains(real)) {
added.add(real);
count++;
}
}
added.clear();
return count;
}
public void checkPatchLangpack(int currentAccount) {
if (currentLocaleInfo == null || checkingUpdateForCurrentRemoteLocale) {
return;
}
if (shouldReinstallLangpack(currentLocaleInfo.shortName)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("reload locale because locale file is not enough");
}
AndroidUtilities.runOnUIThread(() -> reloadCurrentRemoteLocale(currentAccount, null, true, null));
}
}
@ -943,7 +994,7 @@ public class LocaleController {
config.locale = currentLocale;
ApplicationLoader.applicationContext.getResources().updateConfiguration(config, ApplicationLoader.applicationContext.getResources().getDisplayMetrics());
changingConfiguration = false;
if (reloadLastFile) {
if (reloadLastFile || !isLoadingRemote && !force && shouldReinstallLangpack(localeInfo.shortName)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("reload locale because one of file is corrupted " + pathToFile + " " + pathToBaseFile);
}
@ -2316,6 +2367,7 @@ public class LocaleController {
onDone.run();
}
};
patched(localeInfo.shortName);
if (localeInfo.hasBaseLang() && (langCode == null || langCode.equals(localeInfo.baseLangCode))) {
if (localeInfo.baseVersion != 0 && !force) {
if (localeInfo.hasBaseLang()) {
@ -3261,6 +3313,25 @@ public class LocaleController {
return formatDistance(distance, type, null);
}
// patch to force reinstalling of langpack in case some strings are missing after 9.0
private boolean shouldReinstallLangpack(String lng) {
int mustBeCount = MessagesController.getInstance(UserConfig.selectedAccount).checkResetLangpack;
if (mustBeCount <= 0) {
return false;
}
boolean alreadyPatched = MessagesController.getGlobalMainSettings().getBoolean("lngpack_patched_" + lng, false);
if (alreadyPatched) {
return false;
}
int count = calculateTranslatedCount(localeValues);
if (count >= mustBeCount) {
return false;
}
FileLog.e("reinstalling " + lng + " langpack because of patch (" + count + " keys, must be at least " + mustBeCount + ")");
patched(lng);
return true;
}
public static String formatDistance(float distance, int type, Boolean useImperial) {
ensureImperialSystemInit();
boolean imperial = useImperial != null && useImperial || useImperial == null && useImperialSystemType;
@ -3324,4 +3395,11 @@ public class LocaleController {
}
}
}
private void patched(String lng) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("set as patched " + lng + " langpack");
}
MessagesController.getGlobalMainSettings().edit().putBoolean("lngpack_patched_" + lng, true).apply();
}
}

View file

@ -1665,7 +1665,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
raisedToTop = 0;
raisedToTopSign = 0;
countLess = 0;
} else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null) && !VoIPService.isAnyKindOfCallActive()) {
} else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null || ignoreAccelerometerGestures()) && !VoIPService.isAnyKindOfCallActive()) {
if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) {
if (!useFrontSpeaker && !NotificationsController.audioManager.isWiredHeadsetOn() && !NotificationsController.audioManager.isBluetoothA2dpOn()) {
if (BuildVars.LOGS_ENABLED) {
@ -3325,7 +3325,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
startRaiseToEarSensors(raiseChat);
}
if (!ApplicationLoader.mainInterfacePaused && proximityWakeLock != null && !proximityWakeLock.isHeld() && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) {
// proximityWakeLock.acquire();
if (ignoreAccelerometerGestures()) {
proximityWakeLock.acquire();
}
}
startProgressTimer(playingMessageObject);
NotificationCenter.getInstance(messageObject.currentAccount).postNotificationName(NotificationCenter.messagePlayingDidStart, messageObject, oldMessageObject);
@ -3386,6 +3388,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return true;
}
private boolean ignoreAccelerometerGestures() {
return Build.MANUFACTURER.equalsIgnoreCase("samsung");
}
public void updateSilent(boolean value) {
isSilent = value;

View file

@ -27,7 +27,6 @@ import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
@ -495,6 +494,8 @@ public class MessagesController extends BaseController implements NotificationCe
public boolean giftAttachMenuIcon;
public boolean giftTextFieldIcon;
public int checkResetLangpack;
public void getNextReactionMention(long dialogId, int topicId, int count, Consumer<Integer> callback) {
final MessagesStorage messagesStorage = getMessagesStorage();
messagesStorage.getStorageQueue().postRunnable(() -> {
@ -1200,8 +1201,6 @@ public class MessagesController extends BaseController implements NotificationCe
gifSearchBot = mainPreferences.getString("gifSearchBot", "gif");
imageSearchBot = mainPreferences.getString("imageSearchBot", "pic");
blockedCountry = mainPreferences.getBoolean("blockedCountry", false);
dcDomainName = mainPreferences.getString("dcDomainName2", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com");
webFileDatacenterId = mainPreferences.getInt("webFileDatacenterId", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? 2 : 4);
suggestedLangCode = mainPreferences.getString("suggestedLangCode", "en");
animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", false);
@ -1260,8 +1259,12 @@ public class MessagesController extends BaseController implements NotificationCe
uploadMarkupVideo = mainPreferences.getBoolean("uploadMarkupVideo", true);
giftAttachMenuIcon = mainPreferences.getBoolean("giftAttachMenuIcon", false);
giftTextFieldIcon = mainPreferences.getBoolean("giftTextFieldIcon", false);
checkResetLangpack = mainPreferences.getInt("checkResetLangpack", 0);
BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID);
dcDomainName = mainPreferences.getString("dcDomainName2", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com");
webFileDatacenterId = mainPreferences.getInt("webFileDatacenterId", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? 2 : 4);
Set<String> currencySet = mainPreferences.getStringSet("directPaymentsCurrency", null);
if (currencySet != null) {
directPaymentsCurrency.clear();
@ -2964,6 +2967,18 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
case "android_check_reset_langpack": {
if (value.value instanceof TLRPC.TL_jsonNumber) {
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
if (num.value != checkResetLangpack) {
checkResetLangpack = (int) num.value;
editor.putInt("checkResetLangpack", checkResetLangpack);
LocaleController.getInstance().checkPatchLangpack(currentAccount);
changed = true;
}
}
break;
}
}
}
if (changed) {

View file

@ -94,7 +94,7 @@ public class MessagesStorage extends BaseController {
}
}
public final static int LAST_DB_VERSION = 113;
public final static int LAST_DB_VERSION = 114;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
@ -354,9 +354,6 @@ public class MessagesStorage extends BaseController {
}
} catch (Exception e) {
FileLog.e(e);
// if (BuildVars.DEBUG_PRIVATE_VERSION) {
// throw new RuntimeException(e);
// }
if (openTries < 3 && e.getMessage() != null && e.getMessage().contains("malformed")) {
if (openTries == 2) {
cleanupInternal(true);
@ -696,7 +693,11 @@ public class MessagesStorage extends BaseController {
}
private void cleanupInternal(boolean deleteFiles) {
clearDatabaseValues();
if (deleteFiles) {
reset();
} else {
clearDatabaseValues();
}
if (database != null) {
database.close();
database = null;
@ -714,10 +715,11 @@ public class MessagesStorage extends BaseController {
shmCacheFile.delete();
shmCacheFile = null;
}
}
}
private void clearDatabaseValues() {
public void clearDatabaseValues() {
lastDateValue = 0;
lastSeqValue = 0;
lastPtsValue = 0;
@ -1334,10 +1336,7 @@ public class MessagesStorage extends BaseController {
if (cursor != null) {
cursor.dispose();
}
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didClearDatabase);
getMediaDataController().loadAttachMenuBots(false, true);
});
reset();
}
});
}
@ -1828,6 +1827,23 @@ public class MessagesStorage extends BaseController {
return files;
}
public void reset() {
clearDatabaseValues();
AndroidUtilities.runOnUIThread(() -> {
for (int a = 0; a < 2; a++) {
getUserConfig().setDialogsLoadOffset(a, 0, 0, 0, 0, 0, 0);
getUserConfig().setTotalDialogsCount(a, 0);
}
getUserConfig().clearFilters();
getUserConfig().clearPinnedDialogsLoaded();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didClearDatabase);
getMediaDataController().loadAttachMenuBots(false, true);
getNotificationCenter().postNotificationName(NotificationCenter.onDatabaseReset);
});
}
private static class ReadDialog {
public int lastMid;
public int date;

View file

@ -51,6 +51,7 @@ public class SharedConfig {
public final static int PASSCODE_TYPE_PIN = 0,
PASSCODE_TYPE_PASSWORD = 1;
private static int legacyDevicePerformanceClass = -1;
public static boolean loopStickers() {
return LiteMode.isEnabled(LiteMode.FLAG_ANIMATED_STICKERS_CHAT);
@ -1473,4 +1474,36 @@ public class SharedConfig {
public static boolean deviceIsAverage() {
return getDevicePerformanceClass() <= PERFORMANCE_CLASS_AVERAGE;
}
@Deprecated
public static int getLegacyDevicePerformanceClass() {
if (legacyDevicePerformanceClass == -1) {
int androidVersion = Build.VERSION.SDK_INT;
int cpuCount = ConnectionsManager.CPU_COUNT;
int memoryClass = ((ActivityManager) ApplicationLoader.applicationContext.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
int totalCpuFreq = 0;
int freqResolved = 0;
for (int i = 0; i < cpuCount; i++) {
try {
RandomAccessFile reader = new RandomAccessFile(String.format(Locale.ENGLISH, "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", i), "r");
String line = reader.readLine();
if (line != null) {
totalCpuFreq += Utilities.parseInt(line) / 1000;
freqResolved++;
}
reader.close();
} catch (Throwable ignore) {}
}
int maxCpuFreq = freqResolved == 0 ? -1 : (int) Math.ceil(totalCpuFreq / (float) freqResolved);
if (androidVersion < 21 || cpuCount <= 2 || memoryClass <= 100 || cpuCount <= 4 && maxCpuFreq != -1 && maxCpuFreq <= 1250 || cpuCount <= 4 && maxCpuFreq <= 1600 && memoryClass <= 128 && androidVersion <= 21 || cpuCount <= 4 && maxCpuFreq <= 1300 && memoryClass <= 128 && androidVersion <= 24) {
legacyDevicePerformanceClass = PERFORMANCE_CLASS_LOW;
} else if (cpuCount < 8 || memoryClass <= 160 || maxCpuFreq != -1 && maxCpuFreq <= 2050 || maxCpuFreq == -1 && cpuCount == 8 && androidVersion <= 23) {
legacyDevicePerformanceClass = PERFORMANCE_CLASS_AVERAGE;
} else {
legacyDevicePerformanceClass = PERFORMANCE_CLASS_HIGH;
}
}
return legacyDevicePerformanceClass;
}
}

View file

@ -13,8 +13,6 @@ import android.content.SharedPreferences;
import android.os.SystemClock;
import android.util.Base64;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseLongArray;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLRPC;
@ -32,7 +30,7 @@ public class UserConfig extends BaseController {
public final static int MAX_ACCOUNT_COUNT = 4;
private final Object sync = new Object();
private boolean configLoaded;
private volatile boolean configLoaded;
private TLRPC.User currentUser;
public boolean registeredForPush;
public int lastSendMessageId = -210000;
@ -138,6 +136,9 @@ public class UserConfig extends BaseController {
public void saveConfig(boolean withFile) {
NotificationCenter.getInstance(currentAccount).doOnIdle(() -> {
if (!configLoaded) {
return;
}
synchronized (sync) {
try {
SharedPreferences.Editor editor = getPreferences().edit();
@ -285,7 +286,8 @@ public class UserConfig extends BaseController {
}
}
public void loadConfig() {
public void
loadConfig() {
synchronized (sync) {
if (configLoaded) {
return;
@ -519,6 +521,16 @@ public class UserConfig extends BaseController {
getPreferences().edit().putBoolean("2pinnedDialogsLoaded" + folderId, loaded).commit();
}
public void clearPinnedDialogsLoaded() {
SharedPreferences.Editor editor = getPreferences().edit();
for (String key : getPreferences().getAll().keySet()) {
if (key.startsWith("2pinnedDialogsLoaded")) {
editor.remove(key);
}
}
editor.apply();
}
public static final int i_dialogsLoadOffsetId = 0;
public static final int i_dialogsLoadOffsetDate = 1;
public static final int i_dialogsLoadOffsetUserId = 2;
@ -597,4 +609,9 @@ public class UserConfig extends BaseController {
public void setGlobalTtl(int ttl) {
globalTtl = ttl;
}
public void clearFilters() {
getPreferences().edit().remove("filtersLoaded").apply();
filtersLoaded = false;
}
}

View file

@ -3826,6 +3826,8 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa
} else {
bluetoothScoActive = false;
bluetoothScoConnecting = false;
am.setBluetoothScoOn(false);
}
for (StateListener l : stateListeners) {
l.onAudioSettingsChanged();

View file

@ -66,6 +66,7 @@ import java.util.List;
public class ActionBarLayout extends FrameLayout implements INavigationLayout, FloatingDebugProvider {
public boolean highlightActionButtons = false;
private boolean attached;
@Override
public void setHighlightActionButtons(boolean highlightActionButtons) {
@ -2439,7 +2440,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
ArrayList<String> lastActions = new ArrayList<>();
Runnable debugBlackScreenRunnable = () -> {
if (getLastFragment() != null && containerView.getChildCount() == 0) {
if (attached && getLastFragment() != null && containerView.getChildCount() == 0) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e(new RuntimeException(TextUtils.join(", ", lastActions)));
}
@ -2447,7 +2448,6 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
}
};
public void checkBlackScreen(String action) {
// if (!BuildVars.DEBUG_VERSION) {
// return;
@ -2465,5 +2465,15 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
AndroidUtilities.cancelRunOnUIThread(debugBlackScreenRunnable);
AndroidUtilities.runOnUIThread(debugBlackScreenRunnable, 500);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
attached = true;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
attached = false;
}
}

View file

@ -2116,8 +2116,15 @@ public class ActionBarMenuItem extends FrameLayout {
}
public ActionBarPopupWindow.GapView addColoredGap() {
return addColoredGap(-1);
}
public ActionBarPopupWindow.GapView addColoredGap(int id) {
createPopupLayout();
ActionBarPopupWindow.GapView gap = new ActionBarPopupWindow.GapView(getContext(), resourcesProvider, Theme.key_actionBarDefaultSubmenuSeparator);
if (id != -1) {
gap.setTag(id);
}
gap.setTag(R.id.fit_width_tag, 1);
popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
return gap;

View file

@ -302,12 +302,13 @@ public abstract class BaseFragment {
this.finishing = finishing;
}
public void finishFragment(boolean animated) {
public boolean finishFragment(boolean animated) {
if (isFinished || parentLayout == null) {
return;
return false;
}
finishing = true;
parentLayout.closeLastFragment(animated);
return true;
}
public void removeSelfFromStack() {

View file

@ -247,6 +247,10 @@ public class CacheControlActivity extends BaseFragment implements NotificationCe
});
}
public static void resetCalculatedTotalSIze() {
lastTotalSizeCalculated = null;
}
public static void getDeviceTotalSize(Utilities.Callback2<Long, Long> onDone) {
if (lastDeviceTotalSize != null && lastDeviceTotalFreeSize != null) {
if (onDone != null) {

View file

@ -319,8 +319,7 @@ public class CalendarActivity extends BaseFragment {
@Override
public void run(boolean forAll) {
finishFragment();
if (parentLayout.getFragmentStack().size() >= 2) {
if (parentLayout != null && parentLayout.getFragmentStack().size() >= 2) {
BaseFragment fragment = parentLayout.getFragmentStack().get(parentLayout.getFragmentStack().size() - 2);
if (fragment instanceof ChatActivity) {
((ChatActivity) fragment).deleteHistory(dateSelectedStart, dateSelectedEnd + 86400, forAll);

View file

@ -53,7 +53,6 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.Property;
import android.util.SparseArray;
import android.util.StateSet;
@ -83,7 +82,6 @@ import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.DialogObject;
@ -18046,7 +18044,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
sb.append(LocaleController.getString("AccDescrMsgSending", R.string.AccDescrMsgSending));
final float sendingProgress = radialProgress.getProgress();
if (sendingProgress > 0f) {
sb.append(", ").append(Integer.toString(Math.round(sendingProgress * 100))).append("%");
sb.append(Integer.toString(Math.round(sendingProgress * 100))).append("%");
}
} else if (currentMessageObject.isSendError()) {
sb.append("\n");

View file

@ -79,7 +79,7 @@ public class ShareTopicCell extends FrameLayout {
}
if (topic.icon_emoji_id != 0) {
imageView.setImageDrawable(null);
imageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, UserConfig.selectedAccount, topic.icon_emoji_id));
imageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW_STATIC, UserConfig.selectedAccount, topic.icon_emoji_id));
} else {
imageView.setAnimatedEmojiDrawable(null);
ForumBubbleDrawable forumBubbleDrawable = new ForumBubbleDrawable(topic.icon_color);

View file

@ -7354,7 +7354,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (getUserConfig().isPremium()) {
getMessagesController().getTranslateController().toggleTranslatingDialog(getDialogId());
} else {
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), 10).commit();
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), 14).commit();
showDialog(new PremiumFeatureBottomSheet(ChatActivity.this, PremiumPreviewFragment.PREMIUM_FEATURE_TRANSLATIONS, false));
}
updateTopPanel(true);
@ -8586,7 +8586,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (progressView == null) {
return;
}
if (DISABLE_PROGRESS_VIEW && !AndroidUtilities.isTablet() && !isComments && currentUser == null && LiteMode.isEnabled(LiteMode.FLAG_CHAT_BACKGROUND)) {
if (DISABLE_PROGRESS_VIEW && !AndroidUtilities.isTablet() && !isComments && currentUser == null && LiteMode.isEnabled(LiteMode.FLAGS_CHAT)) {
animateProgressViewTo = show;
return;
}
@ -9815,7 +9815,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (userInfo != null && userInfo.voice_messages_forbidden) {
mediaBanTooltip.setText(AndroidUtilities.replaceTags(LocaleController.formatString(chatActivityEnterView.isInVideoMode() ? R.string.VideoMessagesRestrictedByPrivacy : R.string.VoiceMessagesRestrictedByPrivacy, currentUser.first_name)));
} else if (!ChatObject.canSendVoice(currentChat) && !ChatObject.canSendVoice(currentChat)) {
} else if (!ChatObject.canSendVoice(currentChat) && !ChatObject.canSendRoundVideo(currentChat)) {
if (chatActivityEnterView.isInVideoMode()) {
mediaBanTooltip.setText(ChatObject.getRestrictedErrorText(currentChat, ChatObject.ACTION_SEND_ROUND));
} else {
@ -16940,6 +16940,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
builder.setTopAnimationIsNew(true);
if (reason == 0) {
if (currentChat instanceof TLRPC.TL_channelForbidden) {
builder.setTitle(LocaleController.getString("ChannelCantOpenBannedByAdminTitle", R.string.ChannelCantOpenBannedByAdminTitle));
builder.setMessage(LocaleController.getString("ChannelCantOpenBannedByAdmin", R.string.ChannelCantOpenBannedByAdmin));
} else {
builder.setTitle(LocaleController.getString(R.string.ChannelPrivate));
@ -21835,7 +21836,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean showTranslate = (
getUserConfig().isPremium() ?
getMessagesController().getTranslateController().isDialogTranslatable(getDialogId()) && !getMessagesController().getTranslateController().isTranslateDialogHidden(getDialogId()) :
!getMessagesController().premiumLocked && preferences.getInt("dialog_show_translate_count" + did, 3) <= 0
!getMessagesController().premiumLocked && preferences.getInt("dialog_show_translate_count" + did, 5) <= 0
);
if (showRestartTopic) {
shownRestartTopic = true;
@ -24145,6 +24146,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon), PorterDuff.Mode.SRC_IN));
drawable = new CrossfadeDrawable(drawable, new CircularProgressDrawable(AndroidUtilities.dp(12f), AndroidUtilities.dp(1.5f), getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon)));
rateUp.setImageDrawable(drawable);
rateUp.setContentDescription(LocaleController.getString(R.string.AccDescrRateTranscriptionUp));
rateTranscription.addView(rateUp, LayoutHelper.createFrame(33, 33, Gravity.CENTER_HORIZONTAL | Gravity.TOP, -42, 39, 0, 0));
ImageView rateDown = new ImageView(contentView.getContext());
@ -24153,6 +24155,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
drawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon), PorterDuff.Mode.SRC_IN));
drawable = new CrossfadeDrawable(drawable, new CircularProgressDrawable(AndroidUtilities.dp(12f), AndroidUtilities.dp(1.5f), getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon)));
rateDown.setImageDrawable(drawable);
rateDown.setContentDescription(LocaleController.getString(R.string.AccDescrRateTranscriptionDown));
rateTranscription.addView(rateDown, LayoutHelper.createFrame(33, 33, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 42, 39, 0, 0));
Runnable rate = () -> {
@ -24394,7 +24397,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
alert.setDimBehind(false);
closeMenu(false);
int hintCount = MessagesController.getNotificationsSettings(currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 3);
int hintCount = MessagesController.getNotificationsSettings(currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
if (hintCount > 0) {
hintCount--;
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), hintCount).apply();
@ -24415,7 +24418,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
alert.setDimBehind(false);
closeMenu(false);
int hintCount = MessagesController.getNotificationsSettings(currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 3);
int hintCount = MessagesController.getNotificationsSettings(currentAccount).getInt("dialog_show_translate_count" + getDialogId(), 5);
if (hintCount > 0) {
hintCount--;
MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), hintCount).apply();

View file

@ -2060,7 +2060,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
if (hasRecordVideo) {
calledRecordRunnable = false;
recordAudioVideoRunnableStarted = true;
AndroidUtilities.runOnUIThread(recordAudioVideoRunnable, Math.max(150, ViewConfiguration.getLongPressTimeout()));
AndroidUtilities.runOnUIThread(recordAudioVideoRunnable, 150);
} else {
recordAudioVideoRunnable.run();
}

View file

@ -37,6 +37,7 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.Property;
import android.util.TypedValue;
@ -679,6 +680,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
private FrameLayout frameLayout2;
protected EditTextEmoji commentTextView;
private int[] commentTextViewLocation = new int[2];
private FrameLayout writeButtonContainer;
private ImageView writeButton;
private Drawable writeButtonDrawable;
@ -1228,6 +1230,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
invalidate();
frameLayout2.invalidate();
updateCommentTextViewPosition();
if (currentAttachLayout != null) {
currentAttachLayout.onContainerTranslationUpdated(currentPanTranslationY);
}
@ -2226,7 +2230,13 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
float dy = (messageEditTextPredrawHeigth - editText.getMeasuredHeight()) + (messageEditTextPredrawScrollY - editText.getScrollY());
editText.setOffsetY(editText.getOffsetY() - dy);
ValueAnimator a = ValueAnimator.ofFloat(editText.getOffsetY(), 0);
a.addUpdateListener(animation -> editText.setOffsetY((float) animation.getAnimatedValue()));
a.addUpdateListener(animation -> {
editText.setOffsetY((float) animation.getAnimatedValue());
updateCommentTextViewPosition();
if (currentAttachLayout == photoLayout) {
photoLayout.onContainerTranslationUpdated(currentPanTranslationY);
}
});
if (messageEditTextAnimator != null) {
messageEditTextAnimator.cancel();
}
@ -2253,6 +2263,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
}
chatActivityEnterViewAnimateFromTop = frameLayout2.getTop() + captionEditTextTopOffset;
frameLayout2.invalidate();
updateCommentTextViewPosition();
}
@Override
@ -2270,6 +2281,12 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
protected void closeParent() {
ChatAttachAlert.super.dismiss();
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
updateCommentTextViewPosition();
}
};
commentTextView.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
commentTextView.onResume();
@ -2608,6 +2625,14 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
}
}
public void updateCommentTextViewPosition() {
commentTextView.getLocationOnScreen(commentTextViewLocation);
}
public int getCommentTextViewTop() {
return commentTextViewLocation[1];
}
private void showCaptionLimitBulletin(BaseFragment parentFragment) {
if (!(parentFragment instanceof ChatActivity) || !ChatObject.isChannelAndNotMegaGroup(((ChatActivity) parentFragment).getCurrentChat())) {
return;

View file

@ -597,7 +597,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
parentAlert.selectedMenuItem.addSubItem(group, R.drawable.msg_ungroup, LocaleController.getString("SendWithoutGrouping", R.string.SendWithoutGrouping));
spoilerItem = parentAlert.selectedMenuItem.addSubItem(spoiler, R.drawable.msg_spoiler, LocaleController.getString("EnablePhotoSpoiler", R.string.EnablePhotoSpoiler));
parentAlert.selectedMenuItem.addSubItem(open_in, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
parentAlert.selectedMenuItem.addGap(preview_gap);
parentAlert.selectedMenuItem.addColoredGap(preview_gap);
previewItem = parentAlert.selectedMenuItem.addSubItem(preview, R.drawable.msg_view_file, LocaleController.getString("AttachMediaPreviewButton", R.string.AttachMediaPreviewButton));
parentAlert.selectedMenuItem.setFitSubItems(true);
@ -2117,12 +2117,13 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
if (Build.VERSION.SDK_INT >= 21) {
super.dispatchDraw(canvas);
} else {
int maxY = (int) Math.min(parentAlert.getCommentTextViewTop() + currentPanTranslationY + parentAlert.getContainerView().getTranslationY() - cameraView.getTranslationY(), getMeasuredHeight());
if (cameraAnimationInProgress) {
AndroidUtilities.rectTmp.set(animationClipLeft + cameraViewOffsetX * (1f - cameraOpenProgress), animationClipTop + cameraViewOffsetY * (1f - cameraOpenProgress), animationClipRight, animationClipBottom);
AndroidUtilities.rectTmp.set(animationClipLeft + cameraViewOffsetX * (1f - cameraOpenProgress), animationClipTop + cameraViewOffsetY * (1f - cameraOpenProgress), animationClipRight, Math.min(maxY, animationClipBottom));
} else if (!cameraAnimationInProgress && !cameraOpened) {
AndroidUtilities.rectTmp.set(cameraViewOffsetX, cameraViewOffsetY, getMeasuredWidth(), getMeasuredHeight());
AndroidUtilities.rectTmp.set(cameraViewOffsetX, cameraViewOffsetY, getMeasuredWidth(), Math.min(maxY, getMeasuredHeight()));
} else {
AndroidUtilities.rectTmp.set(0 , 0, getMeasuredWidth(), getMeasuredHeight());
AndroidUtilities.rectTmp.set(0 , 0, getMeasuredWidth(), Math.min(maxY, getMeasuredHeight()));
}
canvas.save();
canvas.clipRect(AndroidUtilities.rectTmp);
@ -2153,14 +2154,20 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
cameraView.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
int maxY = (int) Math.min(parentAlert.getCommentTextViewTop() + currentPanTranslationY + parentAlert.getContainerView().getTranslationY() - cameraView.getTranslationY(), view.getMeasuredHeight());
if (cameraOpened) {
maxY = view.getMeasuredHeight();
} else if (cameraAnimationInProgress) {
maxY = AndroidUtilities.lerp(maxY, view.getMeasuredHeight(), cameraOpenProgress);
}
if (cameraAnimationInProgress) {
AndroidUtilities.rectTmp.set(animationClipLeft + cameraViewOffsetX * (1f - cameraOpenProgress), animationClipTop + cameraViewOffsetY * (1f - cameraOpenProgress), animationClipRight, animationClipBottom);
outline.setRect((int) AndroidUtilities.rectTmp.left,(int) AndroidUtilities.rectTmp.top, (int) AndroidUtilities.rectTmp.right, (int) AndroidUtilities.rectTmp.bottom);
outline.setRect((int) AndroidUtilities.rectTmp.left,(int) AndroidUtilities.rectTmp.top, (int) AndroidUtilities.rectTmp.right, Math.min(maxY, (int) AndroidUtilities.rectTmp.bottom));
} else if (!cameraAnimationInProgress && !cameraOpened) {
int rad = AndroidUtilities.dp(8 * parentAlert.cornerRadius);
outline.setRoundRect((int) cameraViewOffsetX, (int) cameraViewOffsetY, view.getMeasuredWidth() + rad, view.getMeasuredHeight() + rad, rad);
outline.setRoundRect((int) cameraViewOffsetX, (int) cameraViewOffsetY, view.getMeasuredWidth() + rad, Math.min(maxY, view.getMeasuredHeight()) + rad, rad);
} else {
outline.setRect(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
outline.setRect(0, 0, view.getMeasuredWidth(), Math.min(maxY, view.getMeasuredHeight()));
}
}
});
@ -2228,6 +2235,12 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
cameraIcon = new FrameLayout(parentAlert.baseFragment.getParentActivity()) {
@Override
protected void onDraw(Canvas canvas) {
int maxY = (int) Math.min(parentAlert.getCommentTextViewTop() + currentPanTranslationY + parentAlert.getContainerView().getTranslationY() - cameraView.getTranslationY(), getMeasuredHeight());
if (cameraOpened) {
maxY = getMeasuredHeight();
} else if (cameraAnimationInProgress) {
maxY = AndroidUtilities.lerp(maxY, getMeasuredHeight(), cameraOpenProgress);
}
int w = cameraDrawable.getIntrinsicWidth();
int h = cameraDrawable.getIntrinsicHeight();
int x = (itemSize - w) / 2;
@ -2235,8 +2248,16 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
if (cameraViewOffsetY != 0) {
y -= cameraViewOffsetY;
}
boolean clip = maxY < getMeasuredHeight();
if (clip) {
canvas.save();
canvas.clipRect(0, 0, getMeasuredWidth(), maxY);
}
cameraDrawable.setBounds(x, y, x + w, y + h);
cameraDrawable.draw(canvas);
if (clip) {
canvas.restore();
}
}
};
cameraIcon.setWillNotDraw(false);
@ -2758,16 +2779,16 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
int finalWidth = itemSize;
int finalHeight = itemSize;
FrameLayout.LayoutParams layoutParams;
LayoutParams layoutParams;
if (!cameraOpened) {
cameraView.setClipTop((int) cameraViewOffsetY);
cameraView.setClipBottom((int) cameraViewOffsetBottomY);
layoutParams = (FrameLayout.LayoutParams) cameraView.getLayoutParams();
layoutParams = (LayoutParams) cameraView.getLayoutParams();
if (layoutParams.height != finalHeight || layoutParams.width != finalWidth) {
layoutParams.width = finalWidth;
layoutParams.height = finalHeight;
cameraView.setLayoutParams(layoutParams);
final FrameLayout.LayoutParams layoutParamsFinal = layoutParams;
final LayoutParams layoutParamsFinal = layoutParams;
AndroidUtilities.runOnUIThread(() -> {
if (cameraView != null) {
cameraView.setLayoutParams(layoutParamsFinal);
@ -2779,12 +2800,12 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
finalWidth = (int) (itemSize - cameraViewOffsetX);
finalHeight = (int) (itemSize - cameraViewOffsetY - cameraViewOffsetBottomY);
layoutParams = (FrameLayout.LayoutParams) cameraIcon.getLayoutParams();
layoutParams = (LayoutParams) cameraIcon.getLayoutParams();
if (layoutParams.height != finalHeight || layoutParams.width != finalWidth) {
layoutParams.width = finalWidth;
layoutParams.height = finalHeight;
cameraIcon.setLayoutParams(layoutParams);
final FrameLayout.LayoutParams layoutParamsFinal = layoutParams;
final LayoutParams layoutParamsFinal = layoutParams;
AndroidUtilities.runOnUIThread(() -> {
if (cameraIcon != null) {
cameraIcon.setLayoutParams(layoutParamsFinal);
@ -3484,10 +3505,36 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
return !cameraOpened;
}
@Override
public void onPanTransitionStart(boolean keyboardVisible, int contentHeight) {
super.onPanTransitionStart(keyboardVisible, contentHeight);
checkCameraViewPosition();
if (cameraView != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cameraView.invalidateOutline();
} else {
cameraView.invalidate();
}
}
if (cameraIcon != null) {
cameraIcon.invalidate();
}
}
@Override
void onContainerTranslationUpdated(float currentPanTranslationY) {
this.currentPanTranslationY = currentPanTranslationY;
checkCameraViewPosition();
if (cameraView != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cameraView.invalidateOutline();
} else {
cameraView.invalidate();
}
}
if (cameraIcon != null) {
cameraIcon.invalidate();
}
invalidate();
}

View file

@ -1005,7 +1005,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
sortedSizes.add(previewSizes.get(i));
}
}
if (sortedSizes.isEmpty() || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
int devicePerformanceClass = SharedConfig.getLegacyDevicePerformanceClass();
if (sortedSizes.isEmpty() || devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_LOW || devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
ArrayList<Size> sizes = sortedSizes;
if (!sortedSizes.isEmpty()) {
sizes = sortedSizes;
@ -2691,7 +2692,8 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter
}
private String createFragmentShader(Size previewSize) {
if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_AVERAGE || Math.max(previewSize.getHeight(), previewSize.getWidth()) * 0.7f < MessagesController.getInstance(currentAccount).roundVideoSize) {
int devicePerformanceClass = SharedConfig.getLegacyDevicePerformanceClass();
if (devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_LOW || devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_AVERAGE || 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" +

View file

@ -14,6 +14,7 @@ import android.os.Build;
import android.text.Layout;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LiteMode;
public class LinkPath extends Path {
@ -137,7 +138,7 @@ public class LinkPath extends Path {
}
centerX = (right + left) / 2;
centerY = (y2 + y) / 2;
if (useRoundRect) {
if (useRoundRect && LiteMode.isEnabled(LiteMode.FLAGS_CHAT)) {
// final CharSequence text = currentLayout.getText();
// int startOffset = currentLayout.getOffsetForHorizontal(currentLine, left), endOffset = currentLayout.getOffsetForHorizontal(currentLine, right) + 1;
boolean startsWithWhitespace = false; // startOffset >= 0 && startOffset < text.length() && text.charAt(startOffset) == ' ';

View file

@ -3837,7 +3837,11 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
photoVideoAdapter.notifyDataSetChanged();
}
} else {
adapter.notifyDataSetChanged();
try {
adapter.notifyDataSetChanged();
} catch (Throwable e) {
}
}
if (sharedMediaData[type].messages.isEmpty() && !sharedMediaData[type].loading) {
if (listView != null) {

View file

@ -454,20 +454,35 @@ public class DataSettingsActivity extends BaseFragment {
}
}
boolean fullString = true;
try {
fullString = storageDirs.size() != 2 || storageDirs.get(0).getAbsolutePath().contains("/storage/emulated/") == storageDirs.get(1).getAbsolutePath().contains("/storage/emulated/");
} catch (Exception ignore) {}
for (int a = 0, N = storageDirs.size(); a < N; a++) {
String storageDir = storageDirs.get(a).getAbsolutePath();
File file = storageDirs.get(a);
String storageDir = file.getAbsolutePath();
LanguageCell cell = new LanguageCell(context);
cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
cell.setTag(a);
cell.setValue(storageDir.contains("/storage/emulated/") ? LocaleController.getString("InternalStorage", R.string.InternalStorage) : LocaleController.getString("SdCard", R.string.SdCard), storageDir);
cell.setValue(
storageDir.contains("/storage/emulated/") ? LocaleController.getString("InternalStorage", R.string.InternalStorage) : LocaleController.getString("SdCard", R.string.SdCard),
fullString ?
LocaleController.formatString("StoragePathFreeValue", R.string.StoragePathFreeValue, AndroidUtilities.formatFileSize(file.getFreeSpace()), storageDir) :
LocaleController.formatString("StoragePathFree", R.string.StoragePathFree, AndroidUtilities.formatFileSize(file.getFreeSpace()))
);
cell.setLanguageSelected(storageDir.startsWith(dir), false);
cell.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 2));
linearLayout.addView(cell);
cell.setOnClickListener(v -> {
SharedConfig.storageCacheDir = storageDir;
SharedConfig.saveConfig();
ImageLoader.getInstance().checkMediaPaths();
builder.getDismissRunnable().run();
listAdapter.notifyItemChanged(storageNumRow);
rebind(storageNumRow);
ImageLoader.getInstance().checkMediaPaths(() -> {
CacheControlActivity.resetCalculatedTotalSIze();
loadCacheSize();
});
});
}
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
@ -582,7 +597,18 @@ public class DataSettingsActivity extends BaseFragment {
);
textCell.setTextAndValueAndColorfulIcon(LocaleController.getString("NetworkUsage", R.string.NetworkUsage), AndroidUtilities.formatFileSize(size), true, R.drawable.msg_filled_datausage, getThemedColor(Theme.key_color_green), storageNumRow != -1);
} else if (position == storageNumRow) {
textCell.setTextAndColorfulIcon(LocaleController.getString("StoragePath", R.string.StoragePath), R.drawable.msg_filled_sdcard, getThemedColor(Theme.key_color_yellow), false);
String dir = storageDirs.get(0).getAbsolutePath();
if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
for (int a = 0, N = storageDirs.size(); a < N; a++) {
String path = storageDirs.get(a).getAbsolutePath();
if (path.startsWith(SharedConfig.storageCacheDir)) {
dir = path;
break;
}
}
}
final String value = dir == null || dir.contains("/storage/emulated/") ? LocaleController.getString("InternalStorage", R.string.InternalStorage) : LocaleController.getString("SdCard", R.string.SdCard);
textCell.setTextAndValueAndColorfulIcon(LocaleController.getString("StoragePath", R.string.StoragePath), value, true, R.drawable.msg_filled_sdcard, getThemedColor(Theme.key_color_yellow), false);
}
break;
}

View file

@ -43,6 +43,7 @@ import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MemberRequestsController;
import org.telegram.messenger.MessagesController;
@ -777,8 +778,19 @@ public class MemberRequestsDelegate implements MemberRequestCell.OnClickListener
public void setImporter(TLRPC.TL_chatInviteImporter importer, BackupImageView imageView) {
this.importer = importer;
this.imageView = imageView;
final ImageLocation imageLocation;
final ImageLocation thumbLocation;
TLRPC.User currentUser = MessagesController.getInstance(currentAccount).getUser(importer.user_id);
imageLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_BIG);
thumbLocation = ImageLocation.getForUserOrChat(currentUser, ImageLocation.TYPE_SMALL);
final TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(importer.user_id);
if (userFull == null) {
MessagesController.getInstance(currentAccount).loadUserInfo(currentUser, false, 0);
}
viewPager.setParentAvatarImage(imageView);
viewPager.setData(importer.user_id, true);
viewPager.initIfEmpty(null, imageLocation, thumbLocation, true);
TLRPC.User user = users.get(importer.user_id);
nameText.setText(UserObject.getUserName(user));
bioText.setText(importer.about);

View file

@ -8824,6 +8824,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} else if (id == NotificationCenter.onDatabaseReset) {
dialogsLoaded[currentAccount] = false;
loadDialogs(getAccountInstance());
getMessagesController().loadPinnedDialogs(folderId, 0, null);
}
}

View file

@ -742,7 +742,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.requestPermissions);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.currentUserPremiumStatusChanged);
LiteMode.addOnPowerSaverAppliedListener(this::onPowerSaver);
if (actionBarLayout.getFragmentStack().isEmpty()) {
if (actionBarLayout.getFragmentStack().isEmpty() && (layersActionBarLayout == null || layersActionBarLayout.getFragmentStack().isEmpty())) {
if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
actionBarLayout.addFragmentToStack(getClientNotActivatedFragment());
drawerLayoutContainer.setAllowOpenDrawer(false, false);
@ -811,7 +811,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
FileLog.e(e);
}
} else {
BaseFragment fragment = actionBarLayout.getFragmentStack().get(0);
BaseFragment fragment = actionBarLayout.getFragmentStack().size() > 0 ? actionBarLayout.getFragmentStack().get(0) : layersActionBarLayout.getFragmentStack().get(0);
if (fragment instanceof DialogsActivity) {
((DialogsActivity) fragment).setSideMenu(sideMenu);
}
@ -1410,14 +1410,17 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
if (!AndroidUtilities.isInMultiwindow && (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)) {
tabletFullSize = false;
if (actionBarLayout.getFragmentStack().size() >= 2) {
for (int a = 1; a < actionBarLayout.getFragmentStack().size(); a++) {
BaseFragment chatFragment = actionBarLayout.getFragmentStack().get(a);
List<BaseFragment> fragmentStack = actionBarLayout.getFragmentStack();
if (fragmentStack.size() >= 2) {
for (int a = 1; a < fragmentStack.size(); a++) {
BaseFragment chatFragment = fragmentStack.get(a);
if (chatFragment instanceof ChatActivity) {
((ChatActivity) chatFragment).setIgnoreAttachOnPause(true);
}
chatFragment.onPause();
actionBarLayout.removeFragmentFromStack(a);
chatFragment.onFragmentDestroy();
chatFragment.setParentLayout(null);
fragmentStack.remove(chatFragment);
rightActionBarLayout.addFragmentToStack(chatFragment);
a--;
}
@ -1431,14 +1434,17 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
shadowTabletSide.setVisibility(!actionBarLayout.getFragmentStack().isEmpty() ? View.VISIBLE : View.GONE);
} else {
tabletFullSize = true;
if (!rightActionBarLayout.getFragmentStack().isEmpty()) {
for (int a = 0; a < rightActionBarLayout.getFragmentStack().size(); a++) {
BaseFragment chatFragment = rightActionBarLayout.getFragmentStack().get(a);
List<BaseFragment> fragmentStack = rightActionBarLayout.getFragmentStack();
if (!fragmentStack.isEmpty()) {
for (int a = 0; a < fragmentStack.size(); a++) {
BaseFragment chatFragment = fragmentStack.get(a);
if (chatFragment instanceof ChatActivity) {
((ChatActivity) chatFragment).setIgnoreAttachOnPause(true);
}
chatFragment.onPause();
rightActionBarLayout.removeFragmentFromStack(a);
chatFragment.onFragmentDestroy();
chatFragment.setParentLayout(null);
fragmentStack.remove(chatFragment);
actionBarLayout.addFragmentToStack(chatFragment);
a--;
}

View file

@ -434,15 +434,7 @@ public class LinkEditActivity extends BaseFragment {
@Override public void onTextChanged(CharSequence s, int start, int before, int count) { }
@Override
public void afterTextChanged(Editable s) {
SpannableStringBuilder builder = new SpannableStringBuilder(s);
Emoji.replaceEmoji(builder, nameEditText.getPaint().getFontMetricsInt(), (int) nameEditText.getPaint().getTextSize(), false);
int selection = nameEditText.getSelectionStart();
nameEditText.removeTextChangedListener(this);
nameEditText.setText(builder);
if (selection >= 0) {
nameEditText.setSelection(selection);
}
nameEditText.addTextChangedListener(this);
Emoji.replaceEmoji(s, nameEditText.getPaint().getFontMetricsInt(), (int) nameEditText.getPaint().getTextSize(), false);
}
});
nameEditText.setCursorVisible(false);

View file

@ -1,7 +1,6 @@
package org.telegram.ui;
import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.AndroidUtilities.dpf2;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@ -10,17 +9,11 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.SpannableString;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
@ -31,6 +24,7 @@ import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import android.widget.ImageView;
@ -44,9 +38,6 @@ import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.zxing.common.detector.MathUtils;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LiteMode;
import org.telegram.messenger.LocaleController;
@ -59,7 +50,6 @@ import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Components.AnimatedEmojiDrawable;
import org.telegram.ui.Components.AnimatedTextView;
@ -68,17 +58,15 @@ import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.CheckBox2;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.IntSeekBarAccessibilityDelegate;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.SeekBarAccessibilityDelegate;
import org.telegram.ui.Components.SeekBarView;
import org.telegram.ui.Components.SlideChooseView;
import org.telegram.ui.Components.SlideView;
import org.telegram.ui.Components.SpannableStringLight;
import org.telegram.ui.Components.Switch;
import java.util.ArrayList;
import java.util.Locale;
public class LiteModeSettingsActivity extends BaseFragment {
@ -223,7 +211,7 @@ public class LiteModeSettingsActivity extends BaseFragment {
items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsBackground"), LiteMode.FLAG_CHAT_BACKGROUND));
items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsTopics"), LiteMode.FLAG_CHAT_FORUM_TWOCOLUMN));
items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsSpoiler"), LiteMode.FLAG_CHAT_SPOILER));
if (SharedConfig.canBlurChat()) {
if (SharedConfig.getDevicePerformanceClass() >= SharedConfig.PERFORMANCE_CLASS_AVERAGE) {
items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsBlur"), LiteMode.FLAG_CHAT_BLUR));
}
items.add(Item.asCheckbox(LocaleController.getString("LiteOptionsScale"), LiteMode.FLAG_CHAT_SCALE));
@ -309,7 +297,22 @@ public class LiteModeSettingsActivity extends BaseFragment {
view = powerSaverSlider;
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
} else if (viewType == VIEW_TYPE_INFO) {
view = new TextInfoPrivacyCell(context);
view = new TextInfoPrivacyCell(context) {
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setEnabled(true);
}
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
event.setContentDescription(getTextView().getText());
setContentDescription(getTextView().getText());
}
};
} else if (viewType == VIEW_TYPE_SWITCH || viewType == VIEW_TYPE_CHECKBOX) {
view = new SwitchCell(context);
} else if (viewType == VIEW_TYPE_SWITCH2) {
@ -342,6 +345,7 @@ public class LiteModeSettingsActivity extends BaseFragment {
textInfoPrivacyCell.setFixedSize(0);
}
textInfoPrivacyCell.setText(item.text);
textInfoPrivacyCell.setContentDescription(item.text);
boolean top = position > 0 && items.get(position - 1).viewType != VIEW_TYPE_INFO;
boolean bottom = position + 1 < items.size() && items.get(position + 1).viewType != VIEW_TYPE_INFO;
if (top && bottom) {
@ -401,6 +405,7 @@ public class LiteModeSettingsActivity extends BaseFragment {
public SwitchCell(Context context) {
super(context);
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
imageView = new ImageView(context);
@ -423,12 +428,14 @@ public class LiteModeSettingsActivity extends BaseFragment {
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
textView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
countTextView = new AnimatedTextView(context, false, true, true);
countTextView.setAnimationProperties(.35f, 0, 200, CubicBezierInterpolator.EASE_OUT_QUINT);
countTextView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
countTextView.setTextSize(dp(14));
countTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
countTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
arrowView = new ImageView(context);
arrowView.setVisibility(GONE);
@ -452,6 +459,7 @@ public class LiteModeSettingsActivity extends BaseFragment {
switchView = new Switch(context);
switchView.setVisibility(GONE);
switchView.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
switchView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
addView(switchView, LayoutHelper.createFrame(37, 50, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT), 19, 0, 19, 0));
checkBoxView = new CheckBox2(context, 21);
@ -460,6 +468,7 @@ public class LiteModeSettingsActivity extends BaseFragment {
checkBoxView.setChecked(true, false);
checkBoxView.setDrawBackgroundAsArc(10);
checkBoxView.setVisibility(GONE);
checkBoxView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
addView(checkBoxView, LayoutHelper.createFrame(21, 21, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 64, 0, LocaleController.isRTL ? 64 : 0, 0));
setFocusable(true);
@ -555,11 +564,24 @@ public class LiteModeSettingsActivity extends BaseFragment {
}
private int preprocessFlagsCount(int flags) {
boolean isPremium = getUserConfig().isPremium();
int count = Integer.bitCount(flags);
count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT) > 0 ? +1 : 0);
count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS) > 0 ? +1 : 0);
count += ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_NOT_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_PREMIUM) > 0 ? -1 : 0) + ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD) > 0 ? +1 : 0);
if (!SharedConfig.canBlurChat() && (flags & LiteMode.FLAG_CHAT_BLUR) > 0) {
if (isPremium) {
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_NOT_PREMIUM) > 0)
count--;
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_NOT_PREMIUM) > 0)
count--;
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_NOT_PREMIUM) > 0)
count--;
} else {
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_CHAT_PREMIUM) > 0)
count--;
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM) > 0)
count--;
if ((flags & LiteMode.FLAG_ANIMATED_EMOJI_KEYBOARD_PREMIUM) > 0)
count--;
}
if (SharedConfig.getDevicePerformanceClass() < SharedConfig.PERFORMANCE_CLASS_AVERAGE && (flags & LiteMode.FLAG_CHAT_BLUR) > 0) {
count--;
}
return count;
@ -590,8 +612,9 @@ public class LiteModeSettingsActivity extends BaseFragment {
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setClassName("android.widget.Switch");
info.setClassName(checkBoxView.getVisibility() == View.VISIBLE ? "android.widget.CheckBox" : "android.widget.Switch");
info.setCheckable(true);
info.setEnabled(true);
if (checkBoxView.getVisibility() == View.VISIBLE) {
info.setChecked(checkBoxView.isChecked());
} else {
@ -621,11 +644,14 @@ public class LiteModeSettingsActivity extends BaseFragment {
TextView rightTextView;
SeekBarView seekBarView;
private SeekBarAccessibilityDelegate seekBarAccessibilityDelegate;
public PowerSaverSlider(Context context) {
super(context);
headerLayout = new LinearLayout(context);
headerLayout.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
headerLayout.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
headerTextView = new TextView(context);
headerTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
@ -680,9 +706,11 @@ public class LiteModeSettingsActivity extends BaseFragment {
}
});
seekBarView.setProgress(LiteMode.getPowerSaverLevel() / 100F);
seekBarView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
addView(seekBarView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38 + 6, Gravity.TOP, 6, 68, 6, 0));
valuesView = new FrameLayout(context);
valuesView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
leftTextView = new TextView(context);
leftTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
@ -725,9 +753,76 @@ public class LiteModeSettingsActivity extends BaseFragment {
addView(valuesView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.FILL_HORIZONTAL, 21, 52, 21, 0));
seekBarAccessibilityDelegate = new IntSeekBarAccessibilityDelegate() {
@Override
protected int getProgress() {
return LiteMode.getPowerSaverLevel();
}
@Override
protected void setProgress(int progress) {
seekBarView.delegate.onSeekBarDrag(true, progress / 100f);
seekBarView.setProgress(progress / 100f);
}
@Override
protected int getMaxValue() {
return 100;
}
@Override
protected int getDelta() {
return 5;
}
@Override
public void onInitializeAccessibilityNodeInfoInternal(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfoInternal(host, info);
info.setEnabled(true);
}
@Override
public void onPopulateAccessibilityEvent(@NonNull View host, @NonNull AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(host, event);
StringBuilder sb = new StringBuilder(LocaleController.getString(R.string.LiteBatteryTitle)).append(", ");
int percent = LiteMode.getPowerSaverLevel();
if (percent <= 0) {
sb.append(LocaleController.getString(R.string.LiteBatteryAlwaysDisabled));
} else if (percent >= 100) {
sb.append(LocaleController.getString(R.string.LiteBatteryAlwaysEnabled));
} else {
sb.append(LocaleController.formatString(R.string.AccDescrLiteBatteryWhenBelow, Math.round(percent)));
}
event.setContentDescription(sb);
setContentDescription(sb);
}
};
update();
}
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
seekBarAccessibilityDelegate.onInitializeAccessibilityNodeInfo(this, info);
}
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
seekBarAccessibilityDelegate.onPopulateAccessibilityEvent(this, event);
}
@Override
public boolean performAccessibilityAction(int action, @Nullable Bundle arguments) {
return seekBarAccessibilityDelegate.performAccessibilityAction(this, action, arguments);
}
public void update() {
final int percent = LiteMode.getPowerSaverLevel();

View file

@ -2565,12 +2565,11 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
}
@Override
public void finishFragment(boolean animated) {
public boolean finishFragment(boolean animated) {
if (onCheckGlScreenshot()) {
return;
return false;
}
super.finishFragment(animated);
return super.finishFragment(animated);
}
private boolean onCheckGlScreenshot() {

View file

@ -201,6 +201,7 @@ import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.FadingTextViewLayout;
import org.telegram.ui.Components.FilterShaders;
import org.telegram.ui.Components.FloatSeekBarAccessibilityDelegate;
import org.telegram.ui.Components.Forum.ForumUtilities;
import org.telegram.ui.Components.GestureDetector2;
import org.telegram.ui.Components.GroupedPhotosListView;
import org.telegram.ui.Components.HideViewAfterAnimation;
@ -4368,6 +4369,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
Bundle args = new Bundle();
args.putBoolean("onlySelect", true);
args.putBoolean("canSelectTopics", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD);
DialogsActivity fragment = new DialogsActivity(args);
final ArrayList<MessageObject> fmessages = new ArrayList<>();
@ -4394,7 +4396,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
}
} else {
long did = dids.get(0).dialogId;
MessagesStorage.TopicKey topicKey = dids.get(0);
long did = topicKey.dialogId;
Bundle args1 = new Bundle();
args1.putBoolean("scrollToTopOnResume", true);
if (DialogObject.isEncryptedDialog(did)) {
@ -4404,8 +4407,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} else {
args1.putLong("chat_id", -did);
}
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
ChatActivity chatActivity = new ChatActivity(args1);
if (topicKey.topicId != 0) {
ForumUtilities.applyTopic(chatActivity, topicKey);
}
if (((LaunchActivity) parentActivity).presentFragment(chatActivity, true, false)) {
chatActivity.showFieldPanelForForward(true, fmessages);
} else {
@ -16666,7 +16671,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (animationStartTime != 0 || animationInProgress != 0) {
return false;
}
if (Math.sqrt(Math.pow(AndroidUtilities.displaySize.x / 2f - e.getX(), 2) + Math.pow((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / 2f - e.getY(), 2)) < AndroidUtilities.dp(40)) {
if (photoProgressViews[0] != null && photoProgressViews[0].isVisible() && photoProgressViews[0].backgroundState != PROGRESS_NONE && Math.sqrt(Math.pow(AndroidUtilities.displaySize.x / 2f - e.getX(), 2) + Math.pow((AndroidUtilities.displaySize.y + AndroidUtilities.statusBarHeight) / 2f - e.getY(), 2)) < AndroidUtilities.dp(40)) {
return false; // play button
}
if (scale == 1.0f) {

View file

@ -3558,7 +3558,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
showDialog(builder.create());
} else {
try {
Toast.makeText(getParentActivity(), "¯\\_(ツ)_/¯", Toast.LENGTH_SHORT).show();
Toast.makeText(getParentActivity(), LocaleController.getString("DebugMenuLongPress", R.string.DebugMenuLongPress), Toast.LENGTH_SHORT).show();
} catch (Exception e) {
FileLog.e(e);
}

View file

@ -2970,7 +2970,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N
} else if (topic != null && topic.icon_emoji_id != 0) {
setForumIcon(null);
if (animatedEmojiDrawable == null || animatedEmojiDrawable.getDocumentId() != topic.icon_emoji_id) {
setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, currentAccount, topic.icon_emoji_id));
setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(openedForForward ? AnimatedEmojiDrawable.CACHE_TYPE_ALERT_PREVIEW_STATIC : AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, currentAccount, topic.icon_emoji_id));
}
} else {
setAnimatedEmojiDrawable(null);

View file

@ -2154,14 +2154,14 @@ public class TwoStepVerificationSetupActivity extends BaseFragment {
}
@Override
public void finishFragment(boolean animated) {
public boolean finishFragment(boolean animated) {
for (BaseFragment fragment : getParentLayout().getFragmentStack()) {
if (fragment != this && fragment instanceof TwoStepVerificationSetupActivity) {
((TwoStepVerificationSetupActivity) fragment).floatingAutoAnimator.ignoreNextLayout();
}
}
super.finishFragment(animated);
return super.finishFragment(animated);
}
private void showSetForcePasswordAlert() {

View file

@ -542,6 +542,7 @@
<string name="ChannelJoinTo">Do you want to join the channel \'%1$s\'?</string>
<string name="ChannelCantOpenPrivate">Sorry, this channel is private, so you cant view its content.</string>
<string name="ChannelCantOpenPrivate2">Sorry, this channel is private.</string>
<string name="ChannelCantOpenBannedByAdminTitle">Can\'t access the chat</string>
<string name="ChannelCantOpenBannedByAdmin">Sorry, you can\'t access this chat because you were banned by an admin.</string>
<string name="ChannelCantOpenBanned">Unfortunately, you were banned from participating in public groups.</string>
<string name="ChannelCantOpenNa">Sorry, this chat is no longer accessible.</string>
@ -2346,6 +2347,7 @@
<string name="EmojiUseDefault">Use system default emoji</string>
<string name="TelegramVersion">Telegram for Android %1$s</string>
<string name="DebugMenu">Debug Menu</string>
<string name="DebugMenuLongPress">Long press again for debug menu</string>
<string name="DebugSendLogs">Send Logs</string>
<string name="DebugSendLastLogs">Send Last Logs</string>
<string name="DebugClearLogs">Clear Logs</string>
@ -6350,4 +6352,10 @@
<string name="ChannelInviteViaLinkRestricted">You can\'t create a link</string>
<string name="ChannelInviteViaLinkRestricted2">This user can\'t be invited</string>
<string name="ChannelInviteViaLinkRestricted3">This users can\'t be invited</string>
<string name="StoragePathFree">%1$s free</string>
<string name="StoragePathFreeValue">%1$s free, %2$s</string>
<string name="AccDescrLiteBatteryWhenBelow">enabled when below %s%%</string>
<string name="AccDescrLiteBatteryLevelAnnounce">%s%%</string>
<string name="AccDescrRateTranscriptionUp">Rate up</string>
<string name="AccDescrRateTranscriptionDown">Rate down</string>
</resources>

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=3199
APP_VERSION_NAME=9.5.1
APP_VERSION_CODE=3208
APP_VERSION_NAME=9.5.2
APP_PACKAGE=org.telegram.messenger
RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey