Commit 0f4b8901 authored by DrKLO's avatar DrKLO

Update to 2.5.2

parent 85bc7046
......@@ -82,7 +82,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 454
versionName "2.5.1"
versionCode 458
versionName "2.5.2"
}
}
......@@ -24,7 +24,7 @@
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:largeHeap="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCTNmNqbWovP9ETcAob98YlrfOQEAC0CJ4" />
......
......@@ -9,7 +9,7 @@
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:largeHeap="true">
</application>
......
......@@ -24,7 +24,7 @@
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:largeHeap="true">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k" />
......
......@@ -43,7 +43,7 @@
<application
android:name=".ApplicationLoader"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:largeHeap="true"
......@@ -52,7 +52,7 @@
<activity
android:name="org.telegram.ui.LaunchActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"
android:hardwareAccelerated="@bool/useHardwareAcceleration"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan">
<intent-filter>
......
......@@ -28,7 +28,7 @@ public class ByteStream {
private final ArrayList<ByteBufferDesc> queue;
public ByteStream() {
this.queue = new ArrayList<ByteBufferDesc>();
this.queue = new ArrayList<>();
}
public void append(ByteBufferDesc buf) {
......
......@@ -25,6 +25,7 @@
package org.telegram.PhoneFormat;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
......@@ -97,9 +98,11 @@ public class PhoneFormat {
}
public void init(String countryCode) {
InputStream stream = null;
ByteArrayOutputStream bos = null;
try {
InputStream stream = ApplicationLoader.applicationContext.getAssets().open("PhoneFormats.dat");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
stream = ApplicationLoader.applicationContext.getAssets().open("PhoneFormats.dat");
bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len;
while ((len = stream.read(buf, 0, 1024)) != -1) {
......@@ -111,6 +114,21 @@ public class PhoneFormat {
} catch (Exception e) {
e.printStackTrace();
return;
} finally {
try {
if (bos != null) {
bos.close();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (stream != null) {
stream.close();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
if (countryCode != null && countryCode.length() != 0) {
......@@ -119,10 +137,10 @@ public class PhoneFormat {
Locale loc = Locale.getDefault();
defaultCountry = loc.getCountry().toLowerCase();
}
callingCodeOffsets = new HashMap<String, Integer>(255);
callingCodeCountries = new HashMap<String, ArrayList<String>>(255);
callingCodeData = new HashMap<String, CallingCodeInfo>(10);
countryCallingCode = new HashMap<String, String>(255);
callingCodeOffsets = new HashMap<>(255);
callingCodeCountries = new HashMap<>(255);
callingCodeData = new HashMap<>(10);
countryCallingCode = new HashMap<>(255);
parseDataHeader();
initialzed = true;
......@@ -293,7 +311,7 @@ public class PhoneFormat {
offset += 2;
ArrayList<String> strs = new ArrayList<String>(5);
ArrayList<String> strs = new ArrayList<>(5);
String str;
while ((str = valueString(offset)).length() != 0) {
strs.add(str);
......@@ -302,14 +320,14 @@ public class PhoneFormat {
res.trunkPrefixes = strs;
offset++;
strs = new ArrayList<String>(5);
strs = new ArrayList<>(5);
while ((str = valueString(offset)).length() != 0) {
strs.add(str);
offset += str.length() + 1;
}
res.intlPrefixes = strs;
ArrayList<RuleSet> ruleSets = new ArrayList<RuleSet>(setCnt);
ArrayList<RuleSet> ruleSets = new ArrayList<>(setCnt);
offset = start + block1Len;
for (int s = 0; s < setCnt; s++) {
RuleSet ruleSet = new RuleSet();
......@@ -317,7 +335,7 @@ public class PhoneFormat {
offset += 2;
int ruleCnt = value16(offset);
offset += 2;
ArrayList<PhoneRule> rules = new ArrayList<PhoneRule>(ruleCnt);
ArrayList<PhoneRule> rules = new ArrayList<>(ruleCnt);
for (int r = 0; r < ruleCnt; r++) {
PhoneRule rule = new PhoneRule();
rule.minVal = value32(offset);
......@@ -380,7 +398,7 @@ public class PhoneFormat {
callingCodeOffsets.put(callingCode, offset);
ArrayList<String> countries = callingCodeCountries.get(callingCode);
if (countries == null) {
countries = new ArrayList<String>();
countries = new ArrayList<>();
callingCodeCountries.put(callingCode, countries);
}
countries.add(country);
......
......@@ -568,4 +568,18 @@ public class AndroidUtilities {
return UserConfig.passcodeHash.length() > 0 && wasInBackground &&
(UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= ConnectionsManager.getInstance().getCurrentTime());
}
/*public static void turnOffHardwareAcceleration(Window window) {
if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) {
return;
}
if (Build.MODEL.contains("GT-S5301") ||
Build.MODEL.contains("GT-S5303") ||
Build.MODEL.contains("GT-B5330") ||
Build.MODEL.contains("GT-S5302") ||
Build.MODEL.contains("GT-S6012B") ||
Build.MODEL.contains("MegaFon_SP-AI")) {
window.clearFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
}
}*/
}
......@@ -449,6 +449,11 @@ public class ImageLoader {
originalBitmap = scaledBitmap;
FileOutputStream stream = new FileOutputStream(thumbFile);
originalBitmap.compress(Bitmap.CompressFormat.JPEG, 60, stream);
try {
stream.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
final BitmapDrawable bitmapDrawable = new BitmapDrawable(originalBitmap);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
......@@ -615,7 +620,9 @@ public class ImageLoader {
if (mediaId != null) {
MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
} else {
BitmapFactory.decodeFile(cacheImage.finalFilePath.getAbsolutePath(), opts);
FileInputStream is = new FileInputStream(cacheFileFinal);
image = BitmapFactory.decodeStream(is, null, opts);
is.close();
}
float photoW = opts.outWidth;
......
......@@ -444,10 +444,12 @@ public class LocaleController {
}
private HashMap<String, String> getLocaleFileStrings(File file) {
FileInputStream stream = null;
try {
HashMap<String, String> stringMap = new HashMap<>();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(new FileInputStream(file), "UTF-8");
stream = new FileInputStream(file);
parser.setInput(stream, "UTF-8");
int eventType = parser.getEventType();
String name = null;
String value = null;
......@@ -484,6 +486,15 @@ public class LocaleController {
return stringMap;
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
try {
if (stream != null) {
stream.close();
stream = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
return null;
}
......
......@@ -1698,10 +1698,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
FileLog.e("tmessages", e);
result = false;
} finally {
if(source != null) {
if (source != null) {
source.close();
}
if(destination != null) {
if (destination != null) {
destination.close();
}
}
......
......@@ -9,10 +9,12 @@
package org.telegram.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.text.Html;
import android.util.Base64;
import android.util.SparseArray;
import org.telegram.messenger.ConnectionsManager;
......@@ -20,11 +22,14 @@ import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.SerializedData;
import org.telegram.messenger.TLClassStore;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.ActionBar.BaseFragment;
import java.util.ArrayList;
import java.util.Collections;
......@@ -86,6 +91,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public int fontSize = AndroidUtilities.dp(16);
public int maxGroupCount = 200;
public int maxBroadcastCount = 100;
public int groupBigSize;
private ArrayList<TLRPC.TL_disabledFeature> disabledFeatures = new ArrayList<>();
private class UserActionUpdates extends TLRPC.Updates {
......@@ -140,7 +147,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter
preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
maxGroupCount = preferences.getInt("maxGroupCount", 200);
maxBroadcastCount = preferences.getInt("maxBroadcastCount", 100);
groupBigSize = preferences.getInt("groupBigSize", 10);
fontSize = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16);
String disabledFeaturesString = preferences.getString("disabledFeatures", null);
if (disabledFeaturesString != null && disabledFeaturesString.length() != 0) {
try {
byte[] bytes = Base64.decode(disabledFeaturesString, Base64.DEFAULT);
if (bytes != null) {
SerializedData data = new SerializedData(bytes);
int count = data.readInt32();
for (int a = 0; a < count; a++) {
TLRPC.TL_disabledFeature feature = (TLRPC.TL_disabledFeature) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (feature != null && feature.feature != null && feature.description != null) {
disabledFeatures.add(feature);
}
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
public void updateConfig(final TLRPC.TL_config config) {
......@@ -149,15 +175,52 @@ public class MessagesController implements NotificationCenter.NotificationCenter
public void run() {
maxBroadcastCount = config.broadcast_size_max;
maxGroupCount = config.chat_size_max;
groupBigSize = config.chat_big_size;
disabledFeatures = config.disabled_features;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("maxGroupCount", maxGroupCount);
editor.putInt("maxBroadcastCount", maxBroadcastCount);
editor.putInt("groupBigSize", groupBigSize);
try {
SerializedData data = new SerializedData();
data.writeInt32(disabledFeatures.size());
for (TLRPC.TL_disabledFeature disabledFeature : disabledFeatures) {
disabledFeature.serializeToStream(data);
}
String string = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT);
if (string != null && string.length() != 0) {
editor.putString("disabledFeatures", string);
}
} catch (Exception e) {
editor.remove("disabledFeatures");
FileLog.e("tmessages", e);
}
editor.commit();
}
});
}
public static boolean isFeatureEnabled(String feature, BaseFragment fragment) {
if (feature == null || feature.length() == 0 || getInstance().disabledFeatures.isEmpty() || fragment == null) {
return true;
}
for (TLRPC.TL_disabledFeature disabledFeature : getInstance().disabledFeatures) {
if (disabledFeature.feature.equals(feature)) {
if (fragment.getParentActivity() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
builder.setTitle("Oops!");
builder.setPositiveButton(R.string.OK, null);
builder.setMessage(disabledFeature.description);
fragment.showAlertDialog(builder);
}
return false;
}
}
return true;
}
public void addSupportUser() {
TLRPC.TL_userForeign user = new TLRPC.TL_userForeign();
user.phone = "333";
......@@ -3582,4 +3645,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
}
}
......@@ -841,7 +841,7 @@ public class NotificationsController {
notifyCheck = isLast;
}
if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false)) {
if (!popupMessages.isEmpty() && oldCount != popupMessages.size() && !AndroidUtilities.needShowPasscode(false) && !UserConfig.isWaitingForPasscodeEnter) {
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) {
MessageObject messageObject = messageObjects.get(0);
if (popup == 3 || popup == 1 && ApplicationLoader.isScreenOn || popup == 2 && !ApplicationLoader.isScreenOn) {
......
......@@ -366,6 +366,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenters.put(datacenter.datacenterId, datacenter);
}
currentDatacenterId = data.readInt32();
data.cleanup();
} catch (Exception e) {
UserConfig.clearConfig();
}
......@@ -388,6 +389,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for (int a = 0; a < count; a++) {
sessionsToDestroy.add(data.readInt64());
}
data.cleanup();
}
}
} catch (Exception e) {
......@@ -405,6 +407,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
Datacenter datacenter = new Datacenter(data, 1);
datacenters.put(datacenter.datacenterId, datacenter);
}
data.cleanup();
}
}
} catch (Exception e) {
......@@ -528,6 +531,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
data.writeInt64(session);
}
editor.putString("sessionsToDestroy", Base64.encodeToString(data.toByteArray(), Base64.DEFAULT));
data.cleanup();
} else {
editor.remove("sessionsToDestroy");
}
......@@ -539,6 +543,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter.SerializeToStream(data);
}
editor.putString("datacenters", Base64.encodeToString(data.toByteArray(), Base64.DEFAULT));
data.cleanup();
} else {
editor.remove("datacenters");
}
......@@ -763,8 +768,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
return;
}
if (error == null) {
lastDcUpdateTime = (int)(System.currentTimeMillis() / 1000);
TLRPC.TL_config config = (TLRPC.TL_config)response;
int updateIn = config.expires - getCurrentTime();
if (updateIn <= 0) {
updateIn = 120;
}
lastDcUpdateTime = (int)(System.currentTimeMillis() / 1000) - DC_UPDATE_TIME + updateIn;
ArrayList<Datacenter> datacentersArr = new ArrayList<>();
HashMap<Integer, Datacenter> datacenterMap = new HashMap<>();
for (TLRPC.TL_dcOption datacenterDesc : config.dc_options) {
......@@ -1338,6 +1347,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (canCompress) {
try {
byte[] data = Utilities.compress(os.toByteArray());
os.cleanup();
if (data.length < requestLength) {
TLRPC.TL_gzip_packed packed = new TLRPC.TL_gzip_packed();
packed.packed_data = data;
......@@ -1345,6 +1355,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
os = new SerializedData(true);
packed.serializeToStream(os);
requestLength = os.length();
os.cleanup();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......@@ -1723,6 +1734,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (quickAckId != null) {
SerializedData data = new SerializedData(messageKeyFull);
quickAckId.add(data.readInt32() & 0x7fffffff);
data.cleanup();
}
MessageKeyData keyData = Utilities.generateMessageKeyData(datacenter.authKey, messageKey, false);
......
......@@ -91,6 +91,14 @@ public class FileUploadOperation {
remove(fileKey + "_iv").
remove(fileKey + "_key").
remove(fileKey + "_ivc").commit();
try {
if (stream != null) {
stream.close();
stream = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
protected void checkNewDataAvailable(final long finalSize) {
......
......@@ -49,6 +49,41 @@ public class SerializedData extends AbsSerializedData {
in = new DataInputStream(inbuf);
}
public void cleanup() {
try {
if (inbuf != null) {
inbuf.close();
inbuf = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (in != null) {
in.close();
in = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (outbuf != null) {
outbuf.close();
outbuf = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (out != null) {
out.close();
out = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
public SerializedData(File file) throws Exception {
FileInputStream is = new FileInputStream(file);
byte[] data = new byte[(int)file.length()];
......
......@@ -216,6 +216,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_userStatusRecently.constructor, TLRPC.TL_userStatusRecently.class);
classStore.put(TLRPC.TL_msg_copy.constructor, TLRPC.TL_msg_copy.class);
classStore.put(TLRPC.TL_contacts_importedContacts.constructor, TLRPC.TL_contacts_importedContacts.class);
classStore.put(TLRPC.TL_disabledFeature.constructor, TLRPC.TL_disabledFeature.class);
classStore.put(TLRPC.TL_futureSalt.constructor, TLRPC.TL_futureSalt.class);
classStore.put(TLRPC.TL_updateEncryptedMessagesRead.constructor, TLRPC.TL_updateEncryptedMessagesRead.class);
classStore.put(TLRPC.TL_updateContactLink.constructor, TLRPC.TL_updateContactLink.class);
......@@ -413,6 +414,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_decryptedMessageHolder.constructor, TLRPC.TL_decryptedMessageHolder.class);
classStore.put(TLRPC.TL_documentEncrypted_old.constructor, TLRPC.TL_documentEncrypted_old.class);
classStore.put(TLRPC.TL_document_old.constructor, TLRPC.TL_document_old.class);
classStore.put(TLRPC.TL_config_old.constructor, TLRPC.TL_config_old.class);
}
static TLClassStore store = null;
......
......@@ -16,7 +16,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_UNREAD = 1;
public static final int MESSAGE_FLAG_OUT = 2;
public static final int LAYER = 22;
public static final int LAYER = 23;
public static class ChatPhoto extends TLObject {
public FileLocation photo_small;
......@@ -3743,6 +3743,24 @@ public class TLRPC {
}
}
public static class TL_disabledFeature extends TLObject {
public static int constructor = 0xae636f24;
public String feature;
public String description;
public void readParams(AbsSerializedData stream) {
feature = stream.readString();
description = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(feature);
stream.writeString(description);
}
}
public static class TL_futureSalt extends TLObject {
public static int constructor = 0x0949d9dc;
......@@ -5023,17 +5041,21 @@ public class TLRPC {
}
public static class TL_config extends TLObject {
public static int constructor = 0x2e54dd74;
public static int constructor = 0x7dae33e0;
public int date;
public int expires;
public boolean test_mode;
public int this_dc;
public ArrayList<TL_dcOption> dc_options = new ArrayList<>();
public int chat_big_size;
public int chat_size_max;
public int broadcast_size_max;
public ArrayList<TL_disabledFeature> disabled_features = new ArrayList<>();
public void readParams(AbsSerializedData stream) {
date = stream.readInt32();
expires = stream.readInt32();
test_mode = stream.readBool();
this_dc = stream.readInt32();
stream.readInt32();
......@@ -5041,23 +5063,37 @@ public class TLRPC {
for (int a = 0; a < count; a++) {
dc_options.add((TL_dcOption)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
}
chat_big_size = stream.readInt32();
chat_size_max = stream.readInt32();
broadcast_size_max = stream.readInt32();
stream.readInt32();
count = stream.readInt32();
for (int a = 0; a < count; a++) {
disabled_features.add((TL_disabledFeature)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(date);
stream.writeInt32(expires);
stream.writeBool(test_mode);
stream.writeInt32(this_dc);
stream.writeInt32(0x1cb5c415);
int count = dc_options.size();
stream.writeInt32(count);
for (TL_dcOption dc_option : dc_options) {
dc_option.serializeToStream(stream);
for (int a = 0; a < count; a++) {
dc_options.get(a).serializeToStream(stream);
}
stream.writeInt32(chat_big_size);
stream.writeInt32(chat_size_max);
stream.writeInt32(broadcast_size_max);
stream.writeInt32(0x1cb5c415);
count = disabled_features.size();
stream.writeInt32(count);
for (int a = 0; a < count; a++) {
disabled_features.get(a).serializeToStream(stream);
}
}
}
......@@ -9298,6 +9334,40 @@ public class TLRPC {
//manually created
public static class TL_config_old extends TL_config {
public static int constructor = 0x2e54dd74;
public void readParams(AbsSerializedData stream) {
date = stream.readInt32();
test_mode = stream.readBool();
this_dc = stream.readInt32();
stream.readInt32();
int count = stream.readInt32();
for (int a = 0; a < count; a++) {
dc_options.add((TL_dcOption) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
}
chat_size_max = stream.readInt32();
broadcast_size_max = stream.readInt32();
expires = (int) (System.currentTimeMillis() / 1000) + 3600;
chat_big_size = 10;
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(date);
stream.writeBool(test_mode);
stream.writeInt32(this_dc);
stream.writeInt32(0x1cb5c415);
int count = dc_options.size();
stream.writeInt32(count);
for (TL_dcOption dc_option : dc_options) {
dc_option.serializeToStream(stream);
}
stream.writeInt32(chat_size_max);
stream.writeInt32(broadcast_size_max);
}
}
public static class TL_document_old extends TL_document {
public static int constructor = 0x9efc6326;
......
......@@ -80,6 +80,7 @@ public class UserConfig {
currentUser.serializeToStream(data);
String userString = Base64.encodeToString(data.toByteArray(), Base64.DEFAULT);
editor.putString("user", userString);
data.cleanup();
}
} else {
editor.remove("user");
......@@ -184,6 +185,7 @@ public class UserConfig {
if (lastSendMessageId > -210000) {
lastSendMessageId = -210000;
}
data.cleanup();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
......@@ -218,6 +220,7 @@ public class UserConfig {
if (userBytes != null) {
SerializedData data = new SerializedData(userBytes);
currentUser = (TLRPC.TL_userSelf)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
data.cleanup();
}
}
}
......
......@@ -39,7 +39,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.security.KeyFactory;
import java.security.MessageDigest;
import java.security.PublicKey;
......@@ -97,6 +96,7 @@ public class Utilities {
for (int a = 0; a < count; a++) {
goodPrimes.add(data.readString());
}
data.cleanup();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......@@ -229,6 +229,7 @@ public class Utilities {
data.writeString(pr);
}
byte[] bytes = data.toByteArray();
data.cleanup();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("primes", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("primes", Base64.encodeToString(bytes, Base64.DEFAULT));
......@@ -364,35 +365,41 @@ public class Utilities {
data.writeRaw(messageKey);
data.writeRaw(authKey, x, 32);
byte[] sha1_a = Utilities.computeSHA1(data.toByteArray());
data.cleanup();
data = new SerializedData();
data.writeRaw(authKey, 32 + x, 16);
data.writeRaw(messageKey);
data.writeRaw(authKey, 48 + x, 16);
byte[] sha1_b = Utilities.computeSHA1(data.toByteArray());
data.cleanup();
data = new SerializedData();
data.writeRaw(authKey, 64 + x, 32);
data.writeRaw(messageKey);
byte[] sha1_c = Utilities.computeSHA1(data.toByteArray());
data.cleanup();
data = new SerializedData();
data.writeRaw(messageKey);
data.writeRaw(authKey, 96 + x, 32);
byte[] sha1_d = Utilities.computeSHA1(data.toByteArray());
data.cleanup();
SerializedData aesKey = new SerializedData();
aesKey.writeRaw(sha1_a, 0, 8);
aesKey.writeRaw(sha1_b, 8, 12);
aesKey.writeRaw(sha1_c, 4, 12);
keyData.aesKey = aesKey.toByteArray();
data = new SerializedData();
data.writeRaw(sha1_a, 0, 8);
data.writeRaw(sha1_b, 8, 12);
data.writeRaw(sha1_c, 4, 12);
keyData.aesKey = data.toByteArray();
data.cleanup();
SerializedData aesIv = new SerializedData();
aesIv.writeRaw(sha1_a, 8, 12);
aesIv.writeRaw(sha1_b, 0, 8);
aesIv.writeRaw(sha1_c, 16, 4);
aesIv.writeRaw(sha1_d, 0, 8);
keyData.aesIv = aesIv.toByteArray();
data = new SerializedData();
data.writeRaw(sha1_a, 8, 12);
data.writeRaw(sha1_b, 0, 8);
data.writeRaw(sha1_c, 16, 4);
data.writeRaw(sha1_d, 0, 8);
keyData.aesIv = data.toByteArray();
data.cleanup();
return keyData;
}
......@@ -409,10 +416,25 @@ public class Utilities {
while ((bytesRead = gis.read(data)) != -1) {
bytesOutput.write(data, 0, bytesRead);
}
gis.close();
is.close();
try {
gis.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
is.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
SerializedData stream = new SerializedData(bytesOutput.toByteArray());
return TLClassStore.Instance().TLdeserialize(stream, stream.readInt32(), parentObject);
try {
bytesOutput.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
TLObject object = TLClassStore.Instance().TLdeserialize(stream, stream.readInt32(), parentObject);
stream.cleanup();
return object;
} catch (IOException e) {
FileLog.e("tmessages", e);
}
......@@ -433,6 +455,12 @@ public class Utilities {
packedData = bytesStream.toByteArray();
} catch (IOException e) {
FileLog.e("tmessages", e);
} finally {
try {
bytesStream.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
return packedData;
}
......@@ -450,23 +478,23 @@ public class Utilities {
}
public static boolean copyFile(File sourceFile, File destFile) throws IOException {
if(!destFile.exists()) {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
FileInputStream source = null;
FileOutputStream destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
destination = new FileOutputStream(destFile).getChannel();
destination.transferFrom(source, 0, source.size());
source = new FileInputStream(sourceFile);
destination = new FileOutputStream(destFile);
destination.getChannel().transferFrom(source.getChannel(), 0, source.getChannel().size());
} catch (Exception e) {
FileLog.e("tmessages", e);
return false;
} finally {
if(source != null) {
if (source != null) {
source.close();
}
if(destination != null) {
if (destination != null) {
destination.close();
}
}
......@@ -712,7 +740,13 @@ public class Utilities {
buffer.write(b);
}
}
return buffer.toByteArray();
byte[] array = buffer.toByteArray();
try {
buffer.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return array;
}
public static void checkForCrashes(Activity context) {
......
......@@ -201,7 +201,7 @@ public class BaseFragment {
return true;
}
protected void showAlertDialog(AlertDialog.Builder builder) {
public void showAlertDialog(AlertDialog.Builder builder) {
if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) {
return;
}
......
......@@ -544,6 +544,7 @@ public class ChangePhoneActivity extends BaseFragment {
codesMap.put(args[0], args[2]);
languageMap.put(args[1], args[2]);
}
reader.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
......
......@@ -481,6 +481,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(final int id) {
if (id == attach_photo || id == attach_gallery || id == attach_document || id == attach_video) {
String action = null;
if (currentChat != null) {
if (currentChat.participants_count > MessagesController.getInstance().groupBigSize) {
if (id == attach_photo || id == attach_gallery) {
action = "bigchat_upload_photo";
} else {
action = "bigchat_upload_document";
}
} else {
if (id == attach_photo || id == attach_gallery) {
action = "chat_upload_photo";
} else {
action = "chat_upload_document";
}
}
} else {
if (id == attach_photo || id == attach_gallery) {
action = "pm_upload_photo";
} else {
action = "pm_upload_document";
}
}
if (action != null && !MessagesController.isFeatureEnabled(action, ChatActivity.this)) {
return;
}
}
if (id == -1) {
finishFragment();
} else if (id == -2) {
......@@ -1001,7 +1028,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentEncryptedChat == null) {
TextView emptyView = new TextView(getParentActivity());
if (currentUser != null && (currentUser.id / 1000 == 333 || currentUser.id % 1000 == 0)) {
if (currentUser != null && currentUser.id != 777000 && (currentUser.id / 1000 == 333 || currentUser.id % 1000 == 0)) {
emptyView.setText(LocaleController.getString("GotAQuestion", R.string.GotAQuestion));
} else {
emptyView.setText(LocaleController.getString("NoMessages", R.string.NoMessages));
......@@ -1324,7 +1351,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
}
chatActivityEnterView = new ChatActivityEnterView(getParentActivity(), contentView, true);
chatActivityEnterView = new ChatActivityEnterView(getParentActivity(), contentView, this, true);
chatActivityEnterView.setDialogId(dialog_id);
chatActivityEnterView.addToAttachLayout(menuItem);
chatActivityEnterView.setId(id_chat_compose_panel);
......
......@@ -182,7 +182,7 @@ public class AvatarDrawable extends Drawable {
}
lastch = lastName.substring(a, a + 1);
}
if (Build.VERSION.SDK_INT >= 14) {
if (Build.VERSION.SDK_INT >= 16) {
text += "\u200C" + lastch;
} else {
text += lastch;
......@@ -191,7 +191,7 @@ public class AvatarDrawable extends Drawable {
for (int a = firstName.length() - 1; a >= 0; a--) {
if (firstName.charAt(a) == ' ') {
if (a != firstName.length() - 1 && firstName.charAt(a + 1) != ' ') {
if (Build.VERSION.SDK_INT >= 14) {
if (Build.VERSION.SDK_INT >= 16) {
text += "\u200C" + firstName.substring(a + 1, a + 2);
} else {
text += firstName.substring(a + 1, a + 2);
......
......@@ -47,6 +47,7 @@ import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
......@@ -96,11 +97,12 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
private boolean recordingAudio;
private Activity parentActivity;
private BaseFragment parentFragment;
private long dialog_id;
private boolean ignoreTextChange;
private ChatActivityEnterViewDelegate delegate;
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, boolean isChat) {
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
super(context);
setOrientation(HORIZONTAL);
setBackgroundResource(R.drawable.compose_panel);
......@@ -117,6 +119,7 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
NotificationCenter.getInstance().addObserver(this, NotificationCenter.hideEmojiKeyboard);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioRouteChanged);
parentActivity = context;
parentFragment = fragment;
sizeNotifierRelativeLayout = parent;
sizeNotifierRelativeLayout.setDelegate(this);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
......@@ -148,20 +151,6 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
}
});
/*
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="@+id/chat_text_edit"
android:maxLines="4"
android:textSize="18dp"
android:textColorHint="#b2b2b2"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textMultiLine"
/>
*/
messsageEditText = new EditText(context);
messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage));
messsageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
......@@ -383,6 +372,23 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
if (parentFragment != null) {
String action = null;
TLRPC.Chat currentChat = null;
if ((int) dialog_id < 0) {
currentChat = MessagesController.getInstance().getChat(-(int) dialog_id);
if (currentChat != null && currentChat.participants_count > MessagesController.getInstance().groupBigSize) {
action = "bigchat_upload_audio";
} else {
action = "chat_upload_audio";
}
} else {
action = "pm_upload_audio";
}
if (!MessagesController.isFeatureEnabled(action, parentFragment)) {
return false;
}
}
startedDraggingX = -1;
MediaController.getInstance().startRecording(dialog_id);
updateAudioRecordIntefrace();
......@@ -488,6 +494,23 @@ public class ChatActivityEnterView extends LinearLayout implements NotificationC
}
private void sendMessage() {
if (parentFragment != null) {
String action = null;
TLRPC.Chat currentChat = null;
if ((int) dialog_id < 0) {
currentChat = MessagesController.getInstance().getChat(-(int) dialog_id);
if (currentChat != null && currentChat.participants_count > MessagesController.getInstance().groupBigSize) {
action = "bigchat_message";
} else {
action = "chat_message";
}
} else {
action = "pm_message";
}
if (!MessagesController.isFeatureEnabled(action, parentFragment)) {
return;
}
}
if (processSendingText(messsageEditText.getText().toString())) {
messsageEditText.setText("");
lastTypingTimeSend = 0;
......
/*
* This is the source code of Telegram for Android v. 2.x
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2015.
*/
package org.telegram.ui.Components;
public class PhotoFilterRadialBlurControl {
}
......@@ -71,6 +71,7 @@ public class PhotoFilterView extends FrameLayout {
private int shadowsTool = 6;
private int vignetteTool = 7;
private int grainTool = 8;
private int blurTool = -1;
private int sharpenTool = 9;
private float highlightsValue = 0; //0 100
......@@ -1028,6 +1029,10 @@ public class PhotoFilterView extends FrameLayout {
orientation = rotation;
textureView = new TextureView(context);
if (Build.VERSION.SDK_INT == 14 || Build.VERSION.SDK_INT == 15) {
//setLayerType(LAYER_TYPE_HARDWARE, null);
//textureView.setLayerType(LAYER_TYPE_HARDWARE, null);
}
addView(textureView);
textureView.setVisibility(INVISIBLE);
LayoutParams layoutParams = (LayoutParams) textureView.getLayoutParams();
......@@ -1176,10 +1181,12 @@ public class PhotoFilterView extends FrameLayout {
previousValue = grainValue;
valueSeekBar.setMinMax(0, 100);
paramTextView.setText(LocaleController.getString("Grain", R.string.Grain));
} else if (i == sharpenTool) {
} else if (i == sharpenTool) {
previousValue = sharpenValue;
valueSeekBar.setMinMax(0, 100);
paramTextView.setText(LocaleController.getString("Sharpen", R.string.Sharpen));
} else if (i == blurTool) {
}
valueSeekBar.setProgress((int) previousValue, false);
updateValueTextView();
......@@ -1239,7 +1246,9 @@ public class PhotoFilterView extends FrameLayout {
} else if (selectedTool == sharpenTool) {
sharpenValue = previousValue;
}
eglThread.requestRender();
if (eglThread != null) {
eglThread.requestRender();
}
switchToOrFromEditMode();
}
});
......@@ -1641,6 +1650,8 @@ public class PhotoFilterView extends FrameLayout {
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_grain, LocaleController.getString("Grain", R.string.Grain), grainValue);
} else if (i == sharpenTool) {
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Sharpen", R.string.Sharpen), sharpenValue);
} else if (i == blurTool) {
((PhotoEditToolCell) holder.itemView).setIconAndTextAndValue(R.drawable.tool_details, LocaleController.getString("Blur", R.string.Blur), 0); //TODO add value
}
}
}
......
......@@ -302,6 +302,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
} else {
if (row == 0) {
if (!MessagesController.isFeatureEnabled("chat_create", ContactsActivity.this)) {
return;
}
presentFragment(new GroupCreateActivity(), false);
} else if (row == 1) {
Bundle args = new Bundle();
......@@ -310,6 +313,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
args.putBoolean("createSecretChat", true);
presentFragment(new ContactsActivity(args), false);
} else if (row == 2) {
if (!MessagesController.isFeatureEnabled("broadcast_create", ContactsActivity.this)) {
return;
}
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args), false);
......
......@@ -266,6 +266,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 2) {
if (!MessagesController.isFeatureEnabled("chat_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
return;
}
presentFragment(new GroupCreateActivity());
drawerLayoutContainer.closeDrawer(false);
} else if (position == 3) {
......@@ -276,6 +279,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
presentFragment(new ContactsActivity(args));
drawerLayoutContainer.closeDrawer(false);
} else if (position == 4) {
if (!MessagesController.isFeatureEnabled("broadcast_create", actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1))) {
return;
}
Bundle args = new Bundle();
args.putBoolean("broadcast", true);
presentFragment(new GroupCreateActivity(args));
......@@ -546,6 +552,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
}
try {
bufferedReader.close();
stream.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (name != null && !phones.isEmpty()) {
contactsToSend = new ArrayList<>();
for (String phone : phones) {
......
......@@ -58,6 +58,7 @@ import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
......@@ -685,6 +686,7 @@ public class LoginActivity extends BaseFragment {
codesMap.put(args[0], args[2]);
languageMap.put(args[1], args[2]);
}
reader.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
......@@ -1233,6 +1235,12 @@ public class LoginActivity extends BaseFragment {
MessagesController.getInstance().getBlockedUsers(true);
needFinishActivity();
ConnectionsManager.getInstance().initPushConnection();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
ConnectionsManager.getInstance().updateDcSettings(0);
}
});
} else {
lastError = error.text;
......@@ -1536,6 +1544,12 @@ public class LoginActivity extends BaseFragment {
MessagesController.getInstance().getBlockedUsers(true);
needFinishActivity();
ConnectionsManager.getInstance().initPushConnection();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
ConnectionsManager.getInstance().updateDcSettings(0);
}
});
} else {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
......
......@@ -793,7 +793,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
emptyImageView.setVisibility(View.VISIBLE);
if (selectedMode == 0) {
listView.setAdapter(photoVideoAdapter);
dropDown.setText(LocaleController.getString("SharedMedia", R.string.SharedMedia));
dropDown.setText(LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle));
emptyImageView.setImageResource(R.drawable.tip1);
emptyTextView.setText(LocaleController.getString("NoMedia", R.string.NoMedia));
searchItem.setVisibility(View.GONE);
......
......@@ -753,7 +753,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (value == 1) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Short", R.string.Short), true);
} else if (value == 2) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Disabled", R.string.Disabled), true);
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), true);
} else if (value == 3) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true);
}
......
......@@ -1875,7 +1875,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
canShowBottom = false;
Object obj = imagesArrLocals.get(index);
cropItem.setVisibility(obj instanceof MediaController.PhotoEntry || obj instanceof MediaController.SearchImage && ((MediaController.SearchImage) obj).type == 0 ? View.VISIBLE : View.GONE);
if (Build.VERSION.SDK_INT >= 14) {
if (Build.VERSION.SDK_INT >= 16) {
tuneItem.setVisibility(cropItem.getVisibility());
}
updateSelectedCount();
......@@ -2313,12 +2313,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
try {
if (windowView.getParent() != null) {
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(windowView);
}
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.removeView(windowView);
} catch (Exception e) {
FileLog.e("tmessages", e);
//don't promt
}
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
......
......@@ -185,7 +185,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
}
chatActivityEnterView = new ChatActivityEnterView(this, contentView, true);
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, true);
popupContainer.addView(chatActivityEnterView);
layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT;
......
......@@ -800,11 +800,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
updateProfileData();
}
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof UserCell) {
((UserCell) child).update(mask);
}
}
}
}
......
......@@ -120,7 +120,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
builder.setItems(new CharSequence[] {
LocaleController.getString("Disabled", R.string.Disabled),
LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
LocaleController.getString("SettingsDefault", R.string.SettingsDefault),
LocaleController.getString("SystemDefault", R.string.SystemDefault),
LocaleController.getString("Short", R.string.Short),
......@@ -158,7 +158,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
builder.setItems(new CharSequence[] {
LocaleController.getString("Default", R.string.Default),
LocaleController.getString("Enabled", R.string.Enabled),
LocaleController.getString("Disabled", R.string.Disabled)
LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled)
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface d, int which) {
......@@ -402,7 +402,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} else if (value == 1) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Short", R.string.Short), true);
} else if (value == 2) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Disabled", R.string.Disabled), true);
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), true);
} else if (value == 3) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true);
} else if (value == 4) {
......@@ -415,7 +415,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} else if (value == 1) {
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("Enabled", R.string.Enabled), true);
} else if (value == 2) {
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("Disabled", R.string.Disabled), true);
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled), true);
} else if (value == 3) {
int delta = preferences.getInt("notifyuntil_" + dialog_id, 0) - ConnectionsManager.getInstance().getCurrentTime();
String val;
......@@ -433,7 +433,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
if (val != null) {
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), val, true);
} else {
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("Disabled", R.string.Disabled), true);
textCell.setTextAndValue(LocaleController.getString("Notifications", R.string.Notifications), LocaleController.getString("NotificationsDisabled", R.string.NotificationsDisabled), true);
}
}
} else if (i == settingsSoundRow) {
......
......@@ -782,6 +782,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
if (supportUser != null && supportUser.id == 333000) {
supportUser = null;
}
data.cleanup();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......@@ -812,6 +813,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
res.user.serializeToStream(data);
editor.putString("support_user", Base64.encodeToString(data.toByteArray(), Base64.DEFAULT));
editor.commit();
data.cleanup();
try {
progressDialog.dismiss();
} catch (Exception e) {
......
......@@ -223,17 +223,26 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent
if (resultCode == Activity.RESULT_OK) {
if (requestCode == 10) {
Utilities.addMediaToGallery(currentPicturePath);
FileOutputStream stream = null;
try {
Point screenSize = AndroidUtilities.getRealScreenSize();
Bitmap bitmap = ImageLoader.loadBitmap(currentPicturePath, null, screenSize.x, screenSize.y, true);
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
FileOutputStream stream = new FileOutputStream(toFile);
stream = new FileOutputStream(toFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
selectedBackground = -1;
selectedColor = 0;
backgroundImage.setImageBitmap(bitmap);
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
currentPicturePath = null;
} else if (requestCode == 11) {
......
......@@ -16,7 +16,7 @@
<string name="YourCode">رمز التفعيل</string>
<string name="SentSmsCode">تم إرسال رسالة قصيرة تحتوي على رمز التفعيل الخاص بك</string>
<string name="CallText">%1$d:%2$02d سنتصل بك خلال</string>
<string name="Calling">جاري الاتصال بك ...</string>
<string name="Calling">جارٍ الاتصال بك ...</string>
<string name="Code">رمز التفعيل</string>
<string name="WrongNumber">الرقم خاطئ؟</string>
<string name="DidNotGetTheCode">هل استقبلت الرمز؟</string>
......@@ -36,12 +36,12 @@
<string name="NoChats">...لا توجد محادثات بعد</string>
<string name="NoChatsHelp">إبدأ المراسلة بالضغط على\nأيقونة النقاط في أعلى يمين الشاشة\nأو اذهب لقسم جهات الاتصال.</string>
<string name="WaitingForNetwork">في إنتظار الشبكة...</string>
<string name="Connecting">جاري الاتصال...</string>
<string name="Updating">جاري التحديث...</string>
<string name="Connecting">جارٍ الاتصال...</string>
<string name="Updating">جارٍ التحديث...</string>
<string name="NewSecretChat">محادثة سرية جديدة</string>
<string name="AwaitingEncryption">في إنتظار اتصال %s … </string>
<string name="EncryptionRejected">تم إلغاء المحادثة السرية</string>
<string name="EncryptionProcessing">جاري إرسال المفاتيح المشفرة...</string>
<string name="EncryptionProcessing">جارٍ إرسال المفاتيح المشفرة...</string>
<string name="EncryptedChatStartedOutgoing">%s قام بالدخول للمحادثة السرية.</string>
<string name="EncryptedChatStartedIncoming">لقد قمت بالدخول للمحادثة السرية.</string>
<string name="ClearHistory">مسح سجل المحادثات</string>
......@@ -81,7 +81,7 @@
<string name="GalleryInfo">أرسل الصورة بدون ضغطها</string>
<!--chat view-->
<string name="Invisible">مخفي</string>
<string name="Typing">جاري الكتابة… </string>
<string name="Typing">جارٍ الكتابة… </string>
<string name="IsTyping">يكتب… </string>
<string name="AreTyping">يكتبون… </string>
<string name="GotAQuestion">هل يوجد لديك سؤال\nحول تيليجرام؟</string>
......@@ -108,7 +108,7 @@
<string name="YouWereKicked">لقد تم إخراجك من هذه المجموعة</string>
<string name="YouLeft">لقد قمت بمغادرة المجموعة</string>
<string name="DeleteThisGroup">حذف هذه المجموعة</string>
<string name="DeleteThisChat">حذف هذه الدردشة</string>
<string name="DeleteThisChat">حذف هذه المحادثة</string>
<string name="SlideToCancel">قم بالسحب للإلغاء</string>
<string name="SaveToDownloads">حفظ في الجهاز</string>
<string name="ShareFile">مشاركة</string>
......@@ -244,7 +244,7 @@
<string name="NoSound">لا يوجد صوت</string>
<string name="Default">افتراضي</string>
<string name="Support">الدعم</string>
<string name="ChatBackground">خلفية الدردشة</string>
<string name="ChatBackground">خلفية المحادثة</string>
<string name="MessagesSettings">الرسائل</string>
<string name="SendByEnter">أرسل بزر الإدخال</string>
<string name="TerminateAllSessions">سجل الخروج من كافة الأجهزة الأخرى</string>
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">سيتم إرسال رسالة قصيرة تحتوي على رمز التفعيل الخاص إلى رقمك الجديد.</string>
<string name="ChangePhoneNumberOccupied">الرقم %1$s لديه حساب تيليجرام مسبقًا. يرجى حذف هذا الحساب قبل محاولة تغيير رقمك.</string>
<string name="NotificationsOther">آخر</string>
<string name="NotificationsDisabled">تعطيل</string>
<string name="VibrationDisabled">تعطيل</string>
<!--passcode view-->
<string name="Passcode">رمز المرور</string>
<string name="ChangePasscode">غيًر رمز المرور</string>
......@@ -477,14 +479,14 @@
<string name="InvalidCode">الرمز غير صحيح</string>
<string name="InvalidFirstName">الاسم الأول غير صحيح</string>
<string name="InvalidLastName">اسم العائلة غير صحيح</string>
<string name="Loading">جاري التحميل ...</string>
<string name="Loading">جارٍ التحميل ...</string>
<string name="NoPlayerInstalled">ليس لديك أي مشغل مقاطع مرئية، يرجى تنزيل أية مشغل</string>
<string name="NoMailInstalled">يرجى إرسال رسالة بواسطة البريد الإلكتروني إلى sms@telegram.org لتخبرنا عن مشكلتك.</string>
<string name="NoHandleAppInstalled">لا يوجد لديك تطبيق يمكنه فتح \'%1$s\'، يرجى تنزيل تطبيق مناسب للإستمرار</string>
<string name="InviteUser">هذا المستخدم ليس لديه تيليجرام بعد ، هل ترغب في دعوته الآن؟</string>
<string name="AreYouSure">هل أنت متأكد؟</string>
<string name="AddToTheGroup">هل ترغب في إضافة %1$s للمجموعة؟\n\nعدد الرسائل الحديثة المراد إعادة تحويلها:</string>
<string name="ForwardMessagesTo">؟%1$s هل تريد إعادة توجيه الرسائل إلى</string>
<string name="ForwardMessagesTo">هل تريد إعادة توجيه الرسائل إلى %1$s؟</string>
<string name="SendMessagesTo">هل ترغب في إرسال رسالة إلى %1$s؟</string>
<string name="AreYouSureLogout">نرجو الأخذ بالعلم أنه يمكنك استخدام تيليجرام على أجهزتك المتعددة بسهولة تامة وفي وقت واحد.\n\nوتذكر، تسجيل الخروج يحذف كافة محادثاتك السرية.</string>
<string name="AreYouSureSessions">هل أنت متأكد من تسجيل الخروج من جميع الأجهزة الأخرى باستثناء هذا الجهاز؟</string>
......@@ -499,7 +501,7 @@
<string name="AreYouSureClearHistory">هل أنت متأكد من رغبتك في حذف سجل المحادثات؟</string>
<string name="AreYouSureDeleteMessages">هل أنت متأكد من رغبتك في حذف %1$s؟</string>
<string name="SendMessagesToGroup">هل ترغب في إرسال رسالة إلى %1$s؟</string>
<string name="ForwardMessagesToGroup">؟%1$s هل تريد إعادة توجيه الرسائل إلى</string>
<string name="ForwardMessagesToGroup">هل تريد إعادة توجيه الرسائل إلى %1$s؟</string>
<string name="FeatureUnavailable">.Sorry, this feature is currently not available in your country</string>
<!--Intro view-->
<string name="Page1Title">تيليجرام</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">Der Bestätigungscode kommt per SMS an deine neue Nummer.</string>
<string name="ChangePhoneNumberOccupied">Die Telefonnummer %1$s ist bereits ein Telegram Konto. Bitte lösche es, bevor du mit der Übertragung auf das neue Konto startest.</string>
<string name="NotificationsOther">Sonstige</string>
<string name="NotificationsDisabled">Deaktiviert</string>
<string name="VibrationDisabled">Deaktiviert</string>
<!--passcode view-->
<string name="Passcode">Pincode</string>
<string name="ChangePasscode">Pincode ändern</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">Enviaremos un SMS con el código de confirmación a tu nuevo número.</string>
<string name="ChangePhoneNumberOccupied">El número %1$s ya está vinculado a una cuenta de Telegram. Por favor, elimina esa cuenta antes de migrar al nuevo número.</string>
<string name="NotificationsOther">Otras</string>
<string name="NotificationsDisabled">Desactivadas</string>
<string name="VibrationDisabled">Desactivadas</string>
<!--passcode view-->
<string name="Passcode">Código de acceso</string>
<string name="ChangePasscode">Cambiar código de acceso</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">Invieremo un SMS con un codice di conferma al tuo nuovo numero.</string>
<string name="ChangePhoneNumberOccupied">Il numero %1$s è già connesso a un account Telegram. Per favore elimina quell\'account prima di migrare ad un nuovo numero.</string>
<string name="NotificationsOther">Altro</string>
<string name="NotificationsDisabled">Disabilitate</string>
<string name="VibrationDisabled">Disabilitata</string>
<!--passcode view-->
<string name="Passcode">Codice</string>
<string name="ChangePasscode">Cambia codice</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">인증코드 메시지를 새 번호로 전송하겠습니다.</string>
<string name="ChangePhoneNumberOccupied">그 번호는 이미 텔레그램 계정에 연결되어 있습니다. 새 번호로 이동하기 전에 %1$s 계정에서 탈퇴해 주세요.</string>
<string name="NotificationsOther">기타</string>
<string name="NotificationsDisabled">끄기</string>
<string name="VibrationDisabled">끄기</string>
<!--passcode view-->
<string name="Passcode">잠금번호</string>
<string name="ChangePasscode">잠금번호 변경</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">We sturen een sms-bericht met verificatiecode naar je nieuwe nummer.</string>
<string name="ChangePhoneNumberOccupied">Aan telefoonnummer %1$s is al een Telegram-account gekoppeld. Verwijder het account om te kunnen migreren naar het nieuwe nummer.</string>
<string name="NotificationsOther">Overig</string>
<string name="NotificationsDisabled">Uitgeschakeld</string>
<string name="VibrationDisabled">Uitgeschakeld</string>
<!--passcode view-->
<string name="Passcode">Toegangscode</string>
<string name="ChangePasscode">Toegangscode wijzigen</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">Vamos enviar uma SMS com um código de confirmação para o seu novo número.</string>
<string name="ChangePhoneNumberOccupied">O número %1$s já possui uma conta do Telegram. Por favor, exclua esta conta antes de migrar para o novo número.</string>
<string name="NotificationsOther">Outro</string>
<string name="NotificationsDisabled">Desativado</string>
<string name="VibrationDisabled">Desativado</string>
<!--passcode view-->
<string name="Passcode">Senha</string>
<string name="ChangePasscode">Alterar Senha</string>
......
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">Vamos enviar uma SMS com um código de confirmação para o seu novo número.</string>
<string name="ChangePhoneNumberOccupied">O número %1$s já possui uma conta do Telegram. Por favor, exclua esta conta antes de migrar para o novo número.</string>
<string name="NotificationsOther">Outro</string>
<string name="NotificationsDisabled">Desativado</string>
<string name="VibrationDisabled">Desativado</string>
<!--passcode view-->
<string name="Passcode">Senha</string>
<string name="ChangePasscode">Alterar Senha</string>
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="useHardwareAcceleration">false</bool>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="useHardwareAcceleration">false</bool>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="useHardwareAcceleration">true</bool>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="useHardwareAcceleration">true</bool>
</resources>
\ No newline at end of file
......@@ -298,6 +298,8 @@
<string name="ChangePhoneHelp">We will send an SMS with a confirmation code to your new number.</string>
<string name="ChangePhoneNumberOccupied">The number %1$s is already connected to a Telegram account. Please delete that account before migrating to the new number.</string>
<string name="NotificationsOther">Other</string>
<string name="NotificationsDisabled">Disabled</string>
<string name="VibrationDisabled">Disabled</string>
<!--passcode view-->
<string name="Passcode">Passcode</string>
<string name="ChangePasscode">Change Passcode</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment