DrKLO 2016-01-11 20:19:48 +03:00
parent 9b16959cab
commit 2114024ab1
558 changed files with 46349 additions and 22716 deletions

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.SQLite;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.SQLite;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.SQLite;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.SQLite;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.SQLite;
@ -135,6 +135,10 @@ public class SQLitePreparedStatement {
bindLong(sqliteStatementHandle, index, value);
}
public void bindNull(int index) throws SQLiteException {
bindNull(sqliteStatementHandle, index);
}
native void bindByteBuffer(int statementHandle, int index, ByteBuffer value, int length) throws SQLiteException;
native void bindString(int statementHandle, int index, String value) throws SQLiteException;
native void bindInt(int statementHandle, int index, int value) throws SQLiteException;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.AnimationCompat;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.AnimationCompat;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.AnimationCompat;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.AnimationCompat;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -22,7 +22,6 @@ import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
@ -30,7 +29,6 @@ import android.util.Base64;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.SerializedData;
@ -39,17 +37,9 @@ import org.telegram.ui.Components.ForegroundDetector;
import java.io.File;
import java.io.RandomAccessFile;
import java.util.concurrent.atomic.AtomicInteger;
public class ApplicationLoader extends Application {
private GoogleCloudMessaging gcm;
private AtomicInteger msgId = new AtomicInteger();
private String regid;
public static final String EXTRA_MESSAGE = "message";
public static final String PROPERTY_REG_ID = "registration_id";
private static final String PROPERTY_APP_VERSION = "appVersion";
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private static Drawable cachedWallpaper;
private static int selectedColor;
private static boolean isCustomTheme;
@ -331,13 +321,10 @@ public class ApplicationLoader extends Application {
@Override
public void run() {
if (checkPlayServices()) {
gcm = GoogleCloudMessaging.getInstance(ApplicationLoader.this);
regid = getRegistrationId();
if (regid.length() == 0) {
registerInBackground();
} else {
sendRegistrationIdToBackend(false);
if (UserConfig.pushString == null || UserConfig.pushString.length() == 0) {
FileLog.d("tmessages", "GCM Registration not found.");
Intent intent = new Intent(applicationContext, GcmRegistrationIntentService.class);
startService(intent);
}
} else {
FileLog.d("tmessages", "No valid Google Play Services APK found.");
@ -359,91 +346,4 @@ public class ApplicationLoader extends Application {
}
return true;*/
}
private String getRegistrationId() {
final SharedPreferences prefs = getGCMPreferences(applicationContext);
String registrationId = prefs.getString(PROPERTY_REG_ID, "");
if (registrationId.length() == 0) {
FileLog.d("tmessages", "Registration not found.");
return "";
}
int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
if (registeredVersion != BuildVars.BUILD_VERSION) {
FileLog.d("tmessages", "App version changed.");
return "";
}
return registrationId;
}
private SharedPreferences getGCMPreferences(Context context) {
return getSharedPreferences(ApplicationLoader.class.getSimpleName(), Context.MODE_PRIVATE);
}
private void registerInBackground() {
AsyncTask<String, String, Boolean> task = new AsyncTask<String, String, Boolean>() {
@Override
protected Boolean doInBackground(String... objects) {
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(applicationContext);
}
int count = 0;
while (count < 1000) {
try {
count++;
regid = gcm.register(BuildVars.GCM_SENDER_ID);
sendRegistrationIdToBackend(true);
storeRegistrationId(applicationContext, regid);
return true;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
try {
if (count % 20 == 0) {
Thread.sleep(60000 * 30);
} else {
Thread.sleep(5000);
}
} catch (InterruptedException e) {
FileLog.e("tmessages", e);
}
}
return false;
}
};
if (android.os.Build.VERSION.SDK_INT >= 11) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);
} else {
task.execute(null, null, null);
}
}
private void sendRegistrationIdToBackend(final boolean isNew) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
UserConfig.pushString = regid;
UserConfig.registeredForPush = !isNew;
UserConfig.saveConfig(false);
if (UserConfig.getClientUserId() != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().registerForPush(regid);
}
});
}
}
});
}
private void storeRegistrationId(Context context, String regId) {
final SharedPreferences prefs = getGCMPreferences(context);
int appVersion = BuildVars.BUILD_VERSION;
FileLog.e("tmessages", "Saving regId on app version " + appVersion);
SharedPreferences.Editor editor = prefs.edit();
editor.putString(PROPERTY_REG_ID, regId);
editor.putInt(PROPERTY_APP_VERSION, appVersion);
editor.commit();
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -31,7 +31,7 @@ public class AutoMessageReplyReceiver extends BroadcastReceiver {
if (dialog_id == 0 || max_id == 0) {
return;
}
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false);
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -10,7 +10,7 @@ package org.telegram.messenger;
public class BuildVars {
public static boolean DEBUG_VERSION = false;
public static int BUILD_VERSION = 695;
public static int BUILD_VERSION = 719;
public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id
public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -22,9 +22,9 @@ import java.util.Scanner;
public class FileLoadOperation {
private static class RequestInfo {
private int requestToken = 0;
private int offset = 0;
private TLRPC.TL_upload_file response = null;
private int requestToken;
private int offset;
private TLRPC.TL_upload_file response;
}
private final static int stateIdle = 0;
@ -51,7 +51,7 @@ public class FileLoadOperation {
private int requestsCount;
private int renameRetryCount;
private int nextDownloadOffset = 0;
private int nextDownloadOffset;
private ArrayList<RequestInfo> requestInfos;
private ArrayList<RequestInfo> delayedRequestInfos;
@ -62,9 +62,9 @@ public class FileLoadOperation {
private String ext;
private RandomAccessFile fileOutputStream;
private RandomAccessFile fiv;
private File storePath = null;
private File tempPath = null;
private boolean isForceRequest = false;
private File storePath;
private File tempPath;
private boolean isForceRequest;
public interface FileLoadOperationDelegate {
void didFinishLoadingFile(FileLoadOperation operation, File finalFile);
@ -143,19 +143,23 @@ public class FileLoadOperation {
key = documentLocation.key;
} else if (documentLocation instanceof TLRPC.TL_document) {
location = new TLRPC.TL_inputDocumentFileLocation();
datacenter_id = documentLocation.dc_id;
location.id = documentLocation.id;
location.access_hash = documentLocation.access_hash;
datacenter_id = documentLocation.dc_id;
}
totalBytesCount = documentLocation.size;
ext = FileLoader.getDocumentFileName(documentLocation);
int idx;
if (ext == null || (idx = ext.lastIndexOf(".")) == -1) {
ext = "";
} else {
ext = ext.substring(idx);
if (ext.length() <= 1) {
if (totalBytesCount <= 0) {
totalBytesCount = documentLocation.size;
}
if (ext == null) {
ext = FileLoader.getDocumentFileName(documentLocation);
int idx;
if (ext == null || (idx = ext.lastIndexOf(".")) == -1) {
ext = "";
} else {
ext = ext.substring(idx);
if (ext.length() <= 1) {
ext = "";
}
}
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -592,16 +592,6 @@ public class FileLoader {
return new File("");
}
public static File getExistPathToAttach(TLObject attach) {
File path = getInstance().getDirectory(MEDIA_DIR_CACHE);
String fileName = getAttachFileName(attach);
File attachPath = new File(path, fileName);
if (attachPath.exists()) {
return attachPath;
}
return getPathToAttach(attach);
}
public static File getPathToAttach(TLObject attach) {
return getPathToAttach(attach, null, false);
}
@ -703,7 +693,8 @@ public class FileLoader {
if (document.file_name != null) {
return document.file_name;
}
for (TLRPC.DocumentAttribute documentAttribute : document.attributes) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a);
if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename) {
return documentAttribute.file_name;
}
@ -722,12 +713,15 @@ public class FileLoader {
return video.dc_id + "_" + video.id + "." + (ext != null ? ext : "mp4");
} else if (attach instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document) attach;
String docExt = getDocumentFileName(document);
int idx;
if (docExt == null || (idx = docExt.lastIndexOf(".")) == -1) {
docExt = "";
} else {
docExt = docExt.substring(idx);
String docExt = null;
if (docExt == null) {
docExt = getDocumentFileName(document);
int idx;
if (docExt == null || (idx = docExt.lastIndexOf(".")) == -1) {
docExt = "";
} else {
docExt = docExt.substring(idx);
}
}
if (docExt.length() > 1) {
return document.dc_id + "_" + document.id + docExt;
@ -736,7 +730,7 @@ public class FileLoader {
}
} else if (attach instanceof TLRPC.PhotoSize) {
TLRPC.PhotoSize photo = (TLRPC.PhotoSize) attach;
if (photo.location == null) {
if (photo.location == null || photo.location instanceof TLRPC.TL_fileLocationUnavailable) {
return "";
}
return photo.location.volume_id + "_" + photo.location.local_id + "." + (ext != null ? ext : "jpg");
@ -744,6 +738,9 @@ public class FileLoader {
TLRPC.Audio audio = (TLRPC.Audio) attach;
return audio.dc_id + "_" + audio.id + "." + (ext != null ? ext : "ogg");
} else if (attach instanceof TLRPC.FileLocation) {
if (attach instanceof TLRPC.TL_fileLocationUnavailable) {
return "";
}
TLRPC.FileLocation location = (TLRPC.FileLocation) attach;
return location.volume_id + "_" + location.local_id + "." + (ext != null ? ext : "jpg");
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -1,68 +0,0 @@
/*
* This is the source code of Telegram for Android v. 3.x.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.messenger;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.json.JSONObject;
import org.telegram.tgnet.ConnectionsManager;
public class GcmBroadcastReceiver extends BroadcastReceiver {
public static final int NOTIFICATION_ID = 1;
@Override
public void onReceive(final Context context, final Intent intent) {
FileLog.d("tmessages", "GCM received intent: " + intent);
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.postInitApplication();
try {
String key = intent.getStringExtra("loc_key");
if ("DC_UPDATE".equals(key)) {
String data = intent.getStringExtra("custom");
JSONObject object = new JSONObject(data);
int dc = object.getInt("dc");
String addr = object.getString("addr");
String[] parts = addr.split(":");
if (parts.length != 2) {
return;
}
String ip = parts[0];
int port = Integer.parseInt(parts[1]);
ConnectionsManager.getInstance().applyDatacenterAddress(dc, ip, port);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ConnectionsManager.getInstance().resumeNetworkMaybe();
}
});
} else if (intent.getAction().equals("com.google.android.c2dm.intent.REGISTRATION")) {
String registration = intent.getStringExtra("registration_id");
if (intent.getStringExtra("error") != null) {
FileLog.e("tmessages", "Registration failed, should try again later.");
} else if (intent.getStringExtra("unregistered") != null) {
FileLog.e("tmessages", "unregistration done, new messages from the authorized sender will be rejected");
} else if (registration != null) {
FileLog.e("tmessages", "registration id = " + registration);
}
}
setResultCode(Activity.RESULT_OK);
}
}

View file

@ -0,0 +1,28 @@
/*
* This is the source code of Telegram for Android v. 3.x.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-2016.
*/
package org.telegram.messenger;
import android.content.Intent;
import com.google.android.gms.iid.InstanceIDListenerService;
public class GcmInstanceIDListenerService extends InstanceIDListenerService {
@Override
public void onTokenRefresh() {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.postInitApplication();
Intent intent = new Intent(ApplicationLoader.applicationContext, GcmRegistrationIntentService.class);
startService(intent);
}
});
}
}

View file

@ -0,0 +1,53 @@
/*
* This is the source code of Telegram for Android v. 3.x.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-2016.
*/
package org.telegram.messenger;
import android.os.Bundle;
import com.google.android.gms.gcm.GcmListenerService;
import org.json.JSONObject;
import org.telegram.tgnet.ConnectionsManager;
public class GcmPushListenerService extends GcmListenerService {
public static final int NOTIFICATION_ID = 1;
@Override
public void onMessageReceived(String from, final Bundle bundle) {
FileLog.d("tmessages", "GCM received bundle: " + bundle + " from: " + from);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.postInitApplication();
try {
String key = bundle.getString("loc_key");
if ("DC_UPDATE".equals(key)) {
String data = bundle.getString("custom");
JSONObject object = new JSONObject(data);
int dc = object.getInt("dc");
String addr = object.getString("addr");
String[] parts = addr.split(":");
if (parts.length != 2) {
return;
}
String ip = parts[0];
int port = Integer.parseInt(parts[1]);
ConnectionsManager.getInstance().applyDatacenterAddress(dc, ip, port);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
ConnectionsManager.getInstance().resumeNetworkMaybe();
}
});
}
}

View file

@ -0,0 +1,68 @@
/*
* This is the source code of Telegram for Android v. 3.x.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-2016.
*/
package org.telegram.messenger;
import android.app.IntentService;
import android.content.Intent;
import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
public class GcmRegistrationIntentService extends IntentService {
public GcmRegistrationIntentService() {
super("GcmRegistrationIntentService");
}
@Override
protected void onHandleIntent(Intent intent) {
try {
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(BuildVars.GCM_SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
FileLog.d("tmessages", "GCM Registration Token: " + token);
sendRegistrationToServer(token);
} catch (Exception e) {
FileLog.e("tmessages", e);
final int failCount = intent.getIntExtra("failCount", 0);
if (failCount < 60) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
try {
Intent intent = new Intent(ApplicationLoader.applicationContext, GcmRegistrationIntentService.class);
intent.putExtra("failCount", failCount + 1);
startService(intent);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}, failCount < 20 ? 10000 : 60000 * 30);
}
}
}
private void sendRegistrationToServer(final String token) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
UserConfig.pushString = token;
UserConfig.registeredForPush = false;
UserConfig.saveConfig(false);
if (UserConfig.getClientUserId() != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().registerForPush(token);
}
});
}
}
});
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -26,8 +26,10 @@ import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedFileDrawable;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -38,6 +40,8 @@ import java.io.InputStream;
import java.io.RandomAccessFile;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
@ -46,6 +50,8 @@ import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ImageLoader {
@ -266,6 +272,17 @@ public class ImageLoader {
fileOutputStream = new RandomAccessFile(cacheImage.tempFilePath, "rws");
}
} catch (Throwable e) {
if (e instanceof SocketTimeoutException) {
if (ConnectionsManager.isNetworkOnline()) {
canRetry = false;
}
} else if (e instanceof UnknownHostException) {
canRetry = false;
} else if (e instanceof SocketException) {
if (e.getMessage() != null && e.getMessage().contains("ECONNRESET")) {
canRetry = false;
}
}
FileLog.e("tmessages", e);
}
}
@ -281,10 +298,26 @@ public class ImageLoader {
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (imageSize == 0 && httpConnection != null) {
try {
Map<String, List<String>> headerFields = httpConnection.getHeaderFields();
if (headerFields != null) {
List values = headerFields.get("content-Length");
if (values != null && !values.isEmpty()) {
String length = (String) values.get(0);
if (length != null) {
imageSize = Utilities.parseInt(length);
}
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
if (httpConnectionStream != null) {
try {
byte[] data = new byte[1024 * 2];
byte[] data = new byte[1024 * 8];
int totalLoaded = 0;
while (true) {
if (isCancelled()) {
@ -530,224 +563,80 @@ public class ImageLoader {
}
}
Long mediaId = null;
boolean mediaIsVideo = false;
Bitmap image = null;
File cacheFileFinal = cacheImage.finalFilePath;
boolean canDeleteFile = true;
boolean useNativeWebpLoaded = false;
if (Build.VERSION.SDK_INT < 19) {
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = new RandomAccessFile(cacheFileFinal, "r");
byte[] bytes;
if (cacheImage.thumb) {
bytes = headerThumb;
} else {
bytes = header;
}
randomAccessFile.readFully(bytes, 0, bytes.length);
String str = new String(bytes).toLowerCase();
str = str.toLowerCase();
if (str.startsWith("riff") && str.endsWith("webp")) {
useNativeWebpLoaded = true;
}
randomAccessFile.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (cacheImage.animatedFile) {
synchronized (sync) {
if (isCancelled) {
return;
}
}
}
if (cacheImage.thumb) {
int blurType = 0;
if (cacheImage.filter != null) {
if (cacheImage.filter.contains("b2")) {
blurType = 3;
} else if (cacheImage.filter.contains("b1")) {
blurType = 2;
} else if (cacheImage.filter.contains("b")) {
blurType = 1;
}
}
try {
lastCacheOutTime = System.currentTimeMillis();
synchronized (sync) {
if (isCancelled) {
return;
}
}
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) {
opts.inPurgeable = true;
}
if (useNativeWebpLoaded) {
RandomAccessFile file = new RandomAccessFile(cacheFileFinal, "r");
ByteBuffer buffer = file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, cacheFileFinal.length());
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
Utilities.loadWebpImage(null, buffer, buffer.limit(), bmOptions, true);
image = Bitmaps.createBitmap(bmOptions.outWidth, bmOptions.outHeight, Bitmap.Config.ARGB_8888);
Utilities.loadWebpImage(image, buffer, buffer.limit(), null, !opts.inPurgeable);
file.close();
} else {
if (opts.inPurgeable) {
RandomAccessFile f = new RandomAccessFile(cacheFileFinal, "r");
int len = (int) f.length();
byte[] data = bytesThumb != null && bytesThumb.length >= len ? bytesThumb : null;
if (data == null) {
bytesThumb = data = new byte[len];
}
f.readFully(data, 0, len);
image = BitmapFactory.decodeByteArray(data, 0, len, opts);
} else {
FileInputStream is = new FileInputStream(cacheFileFinal);
image = BitmapFactory.decodeStream(is, null, opts);
is.close();
}
}
if (image == null) {
if (cacheFileFinal.length() == 0 || cacheImage.filter == null) {
cacheFileFinal.delete();
}
} else {
if (blurType == 1) {
Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1);
} else if (blurType == 2) {
Utilities.blurBitmap(image, 1, opts.inPurgeable ? 0 : 1);
} else if (blurType == 3) {
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1);
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1);
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1);
} else if (blurType == 0 && opts.inPurgeable) {
Utilities.pinBitmap(image);
}
if (runtimeHack != null) {
runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
}
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
AnimatedFileDrawable fileDrawable = new AnimatedFileDrawable(cacheImage.finalFilePath, cacheImage.filter != null && cacheImage.filter.equals("d"));
Thread.interrupted();
onPostExecute(fileDrawable);
} else {
try {
if (cacheImage.httpUrl != null) {
if (cacheImage.httpUrl.startsWith("thumb://")) {
int idx = cacheImage.httpUrl.indexOf(":", 8);
if (idx >= 0) {
mediaId = Long.parseLong(cacheImage.httpUrl.substring(8, idx));
mediaIsVideo = false;
}
canDeleteFile = false;
} else if (cacheImage.httpUrl.startsWith("vthumb://")) {
int idx = cacheImage.httpUrl.indexOf(":", 9);
if (idx >= 0) {
mediaId = Long.parseLong(cacheImage.httpUrl.substring(9, idx));
mediaIsVideo = true;
}
canDeleteFile = false;
} else if (!cacheImage.httpUrl.startsWith("http")) {
canDeleteFile = false;
}
}
Long mediaId = null;
boolean mediaIsVideo = false;
Bitmap image = null;
File cacheFileFinal = cacheImage.finalFilePath;
boolean canDeleteFile = true;
boolean useNativeWebpLoaded = false;
int delay = 20;
if (runtimeHack != null) {
delay = 60;
}
if (mediaId != null) {
delay = 0;
}
if (delay != 0 && lastCacheOutTime != 0 && lastCacheOutTime > System.currentTimeMillis() - delay && Build.VERSION.SDK_INT < 21) {
Thread.sleep(delay);
}
lastCacheOutTime = System.currentTimeMillis();
synchronized (sync) {
if (isCancelled) {
return;
}
}
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
float w_filter = 0;
float h_filter = 0;
boolean blur = false;
if (cacheImage.filter != null) {
String args[] = cacheImage.filter.split("_");
if (args.length >= 2) {
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
}
if (cacheImage.filter.contains("b")) {
blur = true;
}
if (w_filter != 0 && h_filter != 0) {
opts.inJustDecodeBounds = true;
if (mediaId != null) {
if (mediaIsVideo) {
MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts);
} else {
MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
}
} else {
FileInputStream is = new FileInputStream(cacheFileFinal);
image = BitmapFactory.decodeStream(is, null, opts);
is.close();
}
float photoW = opts.outWidth;
float photoH = opts.outHeight;
float scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
if (scaleFactor < 1) {
scaleFactor = 1;
}
opts.inJustDecodeBounds = false;
opts.inSampleSize = (int) scaleFactor;
}
}
synchronized (sync) {
if (isCancelled) {
return;
}
}
if (cacheImage.filter == null || blur || cacheImage.httpUrl != null) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else {
opts.inPreferredConfig = Bitmap.Config.RGB_565;
}
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) {
opts.inPurgeable = true;
}
opts.inDither = false;
if (mediaId != null) {
if (mediaIsVideo) {
image = MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts);
if (Build.VERSION.SDK_INT < 19) {
RandomAccessFile randomAccessFile = null;
try {
randomAccessFile = new RandomAccessFile(cacheFileFinal, "r");
byte[] bytes;
if (cacheImage.thumb) {
bytes = headerThumb;
} else {
image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
bytes = header;
}
randomAccessFile.readFully(bytes, 0, bytes.length);
String str = new String(bytes).toLowerCase();
str = str.toLowerCase();
if (str.startsWith("riff") && str.endsWith("webp")) {
useNativeWebpLoaded = true;
}
randomAccessFile.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
} finally {
if (randomAccessFile != null) {
try {
randomAccessFile.close();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
if (image == null) {
}
if (cacheImage.thumb) {
int blurType = 0;
if (cacheImage.filter != null) {
if (cacheImage.filter.contains("b2")) {
blurType = 3;
} else if (cacheImage.filter.contains("b1")) {
blurType = 2;
} else if (cacheImage.filter.contains("b")) {
blurType = 1;
}
}
try {
lastCacheOutTime = System.currentTimeMillis();
synchronized (sync) {
if (isCancelled) {
return;
}
}
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) {
opts.inPurgeable = true;
}
if (useNativeWebpLoaded) {
RandomAccessFile file = new RandomAccessFile(cacheFileFinal, "r");
ByteBuffer buffer = file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, cacheFileFinal.length());
@ -763,9 +652,9 @@ public class ImageLoader {
if (opts.inPurgeable) {
RandomAccessFile f = new RandomAccessFile(cacheFileFinal, "r");
int len = (int) f.length();
byte[] data = bytes != null && bytes.length >= len ? bytes : null;
byte[] data = bytesThumb != null && bytesThumb.length >= len ? bytesThumb : null;
if (data == null) {
bytes = data = new byte[len];
bytesThumb = data = new byte[len];
}
f.readFully(data, 0, len);
image = BitmapFactory.decodeByteArray(data, 0, len, opts);
@ -775,42 +664,205 @@ public class ImageLoader {
is.close();
}
}
}
if (image == null) {
if (canDeleteFile && (cacheFileFinal.length() == 0 || cacheImage.filter == null)) {
cacheFileFinal.delete();
if (image == null) {
if (cacheFileFinal.length() == 0 || cacheImage.filter == null) {
cacheFileFinal.delete();
}
} else {
if (blurType == 1) {
if (image.getConfig() == Bitmap.Config.ARGB_8888) {
Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
}
} else if (blurType == 2) {
if (image.getConfig() == Bitmap.Config.ARGB_8888) {
Utilities.blurBitmap(image, 1, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
}
} else if (blurType == 3) {
if (image.getConfig() == Bitmap.Config.ARGB_8888) {
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
Utilities.blurBitmap(image, 7, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
}
} else if (blurType == 0 && opts.inPurgeable) {
Utilities.pinBitmap(image);
}
if (runtimeHack != null) {
runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
}
} else {
boolean blured = false;
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
} else {
try {
if (cacheImage.httpUrl != null) {
if (cacheImage.httpUrl.startsWith("thumb://")) {
int idx = cacheImage.httpUrl.indexOf(":", 8);
if (idx >= 0) {
mediaId = Long.parseLong(cacheImage.httpUrl.substring(8, idx));
mediaIsVideo = false;
}
canDeleteFile = false;
} else if (cacheImage.httpUrl.startsWith("vthumb://")) {
int idx = cacheImage.httpUrl.indexOf(":", 9);
if (idx >= 0) {
mediaId = Long.parseLong(cacheImage.httpUrl.substring(9, idx));
mediaIsVideo = true;
}
canDeleteFile = false;
} else if (!cacheImage.httpUrl.startsWith("http")) {
canDeleteFile = false;
}
}
int delay = 20;
if (runtimeHack != null) {
delay = 60;
}
if (mediaId != null) {
delay = 0;
}
if (delay != 0 && lastCacheOutTime != 0 && lastCacheOutTime > System.currentTimeMillis() - delay && Build.VERSION.SDK_INT < 21) {
Thread.sleep(delay);
}
lastCacheOutTime = System.currentTimeMillis();
synchronized (sync) {
if (isCancelled) {
return;
}
}
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = 1;
float w_filter = 0;
float h_filter = 0;
boolean blur = false;
if (cacheImage.filter != null) {
float bitmapW = image.getWidth();
float bitmapH = image.getHeight();
if (!opts.inPurgeable && w_filter != 0 && bitmapW != w_filter && bitmapW > w_filter + 20) {
float scaleFactor = bitmapW / w_filter;
Bitmap scaledBitmap = Bitmaps.createScaledBitmap(image, (int) w_filter, (int) (bitmapH / scaleFactor), true);
if (image != scaledBitmap) {
image.recycle();
image = scaledBitmap;
String args[] = cacheImage.filter.split("_");
if (args.length >= 2) {
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
}
if (cacheImage.filter.contains("b")) {
blur = true;
}
if (w_filter != 0 && h_filter != 0) {
opts.inJustDecodeBounds = true;
if (mediaId != null) {
if (mediaIsVideo) {
MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts);
} else {
MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
}
} else {
FileInputStream is = new FileInputStream(cacheFileFinal);
image = BitmapFactory.decodeStream(is, null, opts);
is.close();
}
float photoW = opts.outWidth;
float photoH = opts.outHeight;
float scaleFactor = Math.max(photoW / w_filter, photoH / h_filter);
if (scaleFactor < 1) {
scaleFactor = 1;
}
opts.inJustDecodeBounds = false;
opts.inSampleSize = (int) scaleFactor;
}
}
synchronized (sync) {
if (isCancelled) {
return;
}
}
if (cacheImage.filter == null || blur || cacheImage.httpUrl != null) {
opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
} else {
opts.inPreferredConfig = Bitmap.Config.RGB_565;
}
if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) {
opts.inPurgeable = true;
}
opts.inDither = false;
if (mediaId != null) {
if (mediaIsVideo) {
image = MediaStore.Video.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Video.Thumbnails.MINI_KIND, opts);
} else {
image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
}
}
if (image == null) {
if (useNativeWebpLoaded) {
RandomAccessFile file = new RandomAccessFile(cacheFileFinal, "r");
ByteBuffer buffer = file.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, cacheFileFinal.length());
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
Utilities.loadWebpImage(null, buffer, buffer.limit(), bmOptions, true);
image = Bitmaps.createBitmap(bmOptions.outWidth, bmOptions.outHeight, Bitmap.Config.ARGB_8888);
Utilities.loadWebpImage(image, buffer, buffer.limit(), null, !opts.inPurgeable);
file.close();
} else {
if (opts.inPurgeable) {
RandomAccessFile f = new RandomAccessFile(cacheFileFinal, "r");
int len = (int) f.length();
byte[] data = bytes != null && bytes.length >= len ? bytes : null;
if (data == null) {
bytes = data = new byte[len];
}
f.readFully(data, 0, len);
image = BitmapFactory.decodeByteArray(data, 0, len, opts);
} else {
FileInputStream is = new FileInputStream(cacheFileFinal);
image = BitmapFactory.decodeStream(is, null, opts);
is.close();
}
}
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1);
blured = true;
}
if (image == null) {
if (canDeleteFile && (cacheFileFinal.length() == 0 || cacheImage.filter == null)) {
cacheFileFinal.delete();
}
} else {
boolean blured = false;
if (cacheImage.filter != null) {
float bitmapW = image.getWidth();
float bitmapH = image.getHeight();
if (!opts.inPurgeable && w_filter != 0 && bitmapW != w_filter && bitmapW > w_filter + 20) {
float scaleFactor = bitmapW / w_filter;
Bitmap scaledBitmap = Bitmaps.createScaledBitmap(image, (int) w_filter, (int) (bitmapH / scaleFactor), true);
if (image != scaledBitmap) {
image.recycle();
image = scaledBitmap;
}
}
if (image != null && blur && bitmapH < 100 && bitmapW < 100) {
if (image.getConfig() == Bitmap.Config.ARGB_8888) {
Utilities.blurBitmap(image, 3, opts.inPurgeable ? 0 : 1, image.getWidth(), image.getHeight(), image.getRowBytes());
}
blured = true;
}
}
if (!blured && opts.inPurgeable) {
Utilities.pinBitmap(image);
}
if (runtimeHack != null && image != null) {
runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
}
if (!blured && opts.inPurgeable) {
Utilities.pinBitmap(image);
}
if (runtimeHack != null && image != null) {
runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
} catch (Throwable e) {
//don't promt
}
} catch (Throwable e) {
//don't promt
}
Thread.interrupted();
onPostExecute(image != null ? new BitmapDrawable(image) : null);
}
Thread.interrupted();
onPostExecute(image != null ? new BitmapDrawable(image) : null);
}
private void onPostExecute(final BitmapDrawable bitmapDrawable) {
@ -818,7 +870,9 @@ public class ImageLoader {
@Override
public void run() {
BitmapDrawable toSet = null;
if (bitmapDrawable != null) {
if (bitmapDrawable instanceof AnimatedFileDrawable) {
toSet = bitmapDrawable;
} else if (bitmapDrawable != null) {
toSet = memCache.get(cacheImage.key);
if (toSet == null) {
memCache.put(cacheImage.key, bitmapDrawable);
@ -909,6 +963,7 @@ public class ImageLoader {
protected String filter;
protected String ext;
protected TLObject location;
protected boolean animatedFile;
protected File finalFilePath;
protected File tempFilePath;
@ -986,13 +1041,29 @@ public class ImageLoader {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
for (ImageReceiver imgView : finalImageReceiverArray) {
imgView.setImageBitmapByKey(image, key, thumb, false);
if (image instanceof AnimatedFileDrawable) {
boolean imageSet = false;
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) image;
for (int a = 0; a < finalImageReceiverArray.size(); a++) {
ImageReceiver imgView = finalImageReceiverArray.get(a);
if (imgView.setImageBitmapByKey(a == 0 ? fileDrawable : fileDrawable.makeCopy(), key, thumb, false)) {
imageSet = true;
}
}
if (!imageSet) {
((AnimatedFileDrawable) image).recycle();
}
} else {
for (int a = 0; a < finalImageReceiverArray.size(); a++) {
ImageReceiver imgView = finalImageReceiverArray.get(a);
imgView.setImageBitmapByKey(image, key, thumb, false);
}
}
}
});
}
for (ImageReceiver imageReceiver : imageReceiverArray) {
for (int a = 0; a < imageReceiverArray.size(); a++) {
ImageReceiver imageReceiver = imageReceiverArray.get(a);
imageLoadingByTag.remove(imageReceiver.getTag(thumb));
}
imageReceiverArray.clear();
@ -1117,7 +1188,7 @@ public class ImageLoader {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (MediaController.getInstance().canSaveToGallery() && telegramPath != null && finalFile != null && finalFile.exists() && (location.endsWith(".mp4") || location.endsWith(".jpg"))) {
if (MediaController.getInstance().canSaveToGallery() && telegramPath != null && finalFile != null && (location.endsWith(".mp4") || location.endsWith(".jpg"))) {
if (finalFile.toString().startsWith(telegramPath.toString())) {
AndroidUtilities.addMediaToGallery(finalFile.toString());
}
@ -1482,24 +1553,33 @@ public class ImageLoader {
return memCache.get(key);
}
public void replaceImageInCache(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
ArrayList<String> arr = memCache.getFilterKeys(oldKey);
if (arr != null) {
for (String filter : arr) {
String oldK = oldKey + "@" + filter;
String newK = newKey + "@" + filter;
performReplace(oldK, newK);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldK, newK, newLocation);
}
} else {
performReplace(oldKey, newKey);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldKey, newKey, newLocation);
}
private void replaceImageInCacheInternal(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation) {
ArrayList<String> arr = memCache.getFilterKeys(oldKey);
if (arr != null) {
for (int a = 0; a < arr.size(); a++) {
String filter = arr.get(a);
String oldK = oldKey + "@" + filter;
String newK = newKey + "@" + filter;
performReplace(oldK, newK);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldK, newK, newLocation);
}
});
} else {
performReplace(oldKey, newKey);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReplacedPhotoInMemCache, oldKey, newKey, newLocation);
}
}
public void replaceImageInCache(final String oldKey, final String newKey, final TLRPC.FileLocation newLocation, boolean post) {
if (post) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
replaceImageInCacheInternal(oldKey, newKey, newLocation);
}
});
} else {
replaceImageInCacheInternal(oldKey, newKey, newLocation);
}
}
public void putImageToCache(BitmapDrawable bitmap, String key) {
@ -1621,15 +1701,21 @@ public class ImageLoader {
}
if (thumb != 2) {
CacheImage img = new CacheImage();
if (httpLocation != null && (httpLocation.endsWith("mp4") || httpLocation.endsWith("gif")) || imageLocation instanceof TLRPC.Document && MessageObject.isGifDocument((TLRPC.Document) imageLocation)) {
img.animatedFile = true;
}
if (cacheFile == null) {
if (cacheOnly || size == 0 || httpLocation != null) {
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), url);
} else if (imageLocation instanceof TLRPC.Document) {
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_DOCUMENT), url);
} else {
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_IMAGE), url);
}
}
CacheImage img = new CacheImage();
img.thumb = thumb != 0;
img.key = key;
img.filter = filter;
@ -1654,7 +1740,7 @@ public class ImageLoader {
TLRPC.FileLocation location = (TLRPC.FileLocation) imageLocation;
FileLoader.getInstance().loadFile(location, ext, size, size == 0 || location.key != null || cacheOnly);
} else if (imageLocation instanceof TLRPC.Document) {
FileLoader.getInstance().loadFile((TLRPC.Document) imageLocation, true, true);
FileLoader.getInstance().loadFile((TLRPC.Document) imageLocation, true, cacheOnly);
}
} else {
String file = Utilities.MD5(httpLocation);
@ -1725,12 +1811,12 @@ public class ImageLoader {
saveImageToCache = true;
}
} else if (imageLocation instanceof TLRPC.Document) {
TLRPC.Document location = (TLRPC.Document) imageLocation;
if (location.id == 0 || location.dc_id == 0) {
TLRPC.Document document = (TLRPC.Document) imageLocation;
if (document.id == 0 || document.dc_id == 0) {
return;
}
key = location.dc_id + "_" + location.id;
String docExt = FileLoader.getDocumentFileName(location);
key = document.dc_id + "_" + document.id;
String docExt = FileLoader.getDocumentFileName(document);
int idx;
if (docExt == null || (idx = docExt.lastIndexOf(".")) == -1) {
docExt = "";
@ -1744,7 +1830,7 @@ public class ImageLoader {
if (thumbKey != null) {
thumbUrl = thumbKey + "." + ext;
}
saveImageToCache = true;
saveImageToCache = !MessageObject.isGifDocument(document);
}
if (imageLocation == thumbLocation) {
imageLocation = null;
@ -1768,6 +1854,7 @@ public class ImageLoader {
}
if (httpLocation != null) {
createLoadOperationForImageReceiver(imageReceiver, thumbKey, thumbUrl, ext, thumbLocation, null, thumbFilter, 0, true, thumbSet ? 2 : 1);
createLoadOperationForImageReceiver(imageReceiver, key, url, ext, null, httpLocation, filter, 0, true, 0);
} else {
createLoadOperationForImageReceiver(imageReceiver, thumbKey, thumbUrl, ext, thumbLocation, null, thumbFilter, 0, true, thumbSet ? 2 : 1);
@ -1806,7 +1893,8 @@ public class ImageLoader {
}
imageLoadingByUrl.remove(location);
CacheOutTask task = null;
for (ImageReceiver imageReceiver : img.imageReceiverArray) {
for (int a = 0; a < img.imageReceiverArray.size(); a++) {
ImageReceiver imageReceiver = img.imageReceiverArray.get(a);
CacheImage cacheImage = imageLoadingByKeys.get(img.key);
if (cacheImage == null) {
cacheImage = new CacheImage();
@ -1817,6 +1905,7 @@ public class ImageLoader {
cacheImage.ext = img.ext;
cacheImage.cacheTask = task = new CacheOutTask(cacheImage);
cacheImage.filter = img.filter;
cacheImage.animatedFile = img.animatedFile;
imageLoadingByKeys.put(cacheImage.key, cacheImage);
}
cacheImage.addImageReceiver(imageReceiver);
@ -1851,7 +1940,7 @@ public class ImageLoader {
if (complete) {
currentHttpTasksCount--;
}
while (currentHttpTasksCount < 1 && !httpTasks.isEmpty()) {
while (currentHttpTasksCount < 4 && !httpTasks.isEmpty()) {
HttpImageTask task = httpTasks.poll();
if (android.os.Build.VERSION.SDK_INT >= 11) {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null, null);

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -25,6 +25,7 @@ import android.view.View;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedFileDrawable;
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
@ -62,9 +63,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private TLRPC.FileLocation currentThumbLocation;
private int currentSize;
private boolean currentCacheOnly;
private BitmapDrawable currentImage;
private BitmapDrawable currentThumb;
private Drawable currentImage;
private Drawable currentThumb;
private Drawable staticThumb;
private boolean allowStartAnimation = true;
private boolean needsQualityThumb;
private boolean shouldGenerateQualityThumb;
@ -167,8 +169,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return;
}
if (!(thumbLocation instanceof TLRPC.TL_fileLocation)) {
thumbLocation = null;
}
@ -180,7 +180,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
key = location.volume_id + "_" + location.local_id;
} else {
TLRPC.Document location = (TLRPC.Document) fileLocation;
key = location.dc_id + "_" + location.id;
if (location.dc_id != 0) {
key = location.dc_id + "_" + location.id;
} else {
fileLocation = null;
}
}
} else if (httpUrl != null) {
key = Utilities.MD5(httpUrl);
@ -504,12 +508,14 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
}
private void checkAlphaAnimation() {
private void checkAlphaAnimation(boolean skip) {
if (currentAlpha != 1) {
long currentTime = System.currentTimeMillis();
currentAlpha += (currentTime - lastUpdateAlphaTime) / 150.0f;
if (currentAlpha > 1) {
currentAlpha = 1;
if (!skip) {
long currentTime = System.currentTimeMillis();
currentAlpha += (currentTime - lastUpdateAlphaTime) / 150.0f;
if (currentAlpha > 1) {
currentAlpha = 1;
}
}
lastUpdateAlphaTime = System.currentTimeMillis();
if (parentView != null) {
@ -524,44 +530,51 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
public boolean draw(Canvas canvas) {
try {
BitmapDrawable bitmapDrawable = null;
if (!forcePreview && currentImage != null) {
bitmapDrawable = currentImage;
Drawable drawable = null;
boolean animationNotReady = currentImage instanceof AnimatedFileDrawable && !((AnimatedFileDrawable) currentImage).hasBitmap();
if (!forcePreview && currentImage != null && !animationNotReady) {
drawable = currentImage;
} else if (staticThumb instanceof BitmapDrawable) {
bitmapDrawable = (BitmapDrawable) staticThumb;
drawable = staticThumb;
} else if (currentThumb != null) {
bitmapDrawable = currentThumb;
drawable = currentThumb;
}
if (bitmapDrawable != null) {
if (drawable != null) {
if (crossfadeAlpha != 0) {
if (crossfadeWithThumb && currentAlpha != 1.0f) {
Drawable thumbDrawable = null;
if (bitmapDrawable == currentImage) {
if (staticThumb != null) {
thumbDrawable = staticThumb;
} else if (currentThumb != null) {
thumbDrawable = currentThumb;
if (crossfadeWithThumb && animationNotReady) {
drawDrawable(canvas, drawable, (int) (overrideAlpha * 255));
} else {
if (crossfadeWithThumb && currentAlpha != 1.0f) {
Drawable thumbDrawable = null;
if (drawable == currentImage) {
if (staticThumb != null) {
thumbDrawable = staticThumb;
} else if (currentThumb != null) {
thumbDrawable = currentThumb;
}
} else if (drawable == currentThumb) {
if (staticThumb != null) {
thumbDrawable = staticThumb;
}
}
} else if (bitmapDrawable == currentThumb) {
if (staticThumb != null) {
thumbDrawable = staticThumb;
if (thumbDrawable != null) {
drawDrawable(canvas, thumbDrawable, (int) (overrideAlpha * 255));
}
}
if (thumbDrawable != null) {
drawDrawable(canvas, thumbDrawable, (int) (overrideAlpha * 255));
}
drawDrawable(canvas, drawable, (int) (overrideAlpha * currentAlpha * 255));
}
drawDrawable(canvas, bitmapDrawable, (int) (overrideAlpha * currentAlpha * 255));
} else {
drawDrawable(canvas, bitmapDrawable, (int) (overrideAlpha * 255));
drawDrawable(canvas, drawable, (int) (overrideAlpha * 255));
}
checkAlphaAnimation();
checkAlphaAnimation(animationNotReady && crossfadeWithThumb);
return true;
} else if (staticThumb != null) {
drawDrawable(canvas, staticThumb, 255);
checkAlphaAnimation();
checkAlphaAnimation(animationNotReady);
return true;
} else {
checkAlphaAnimation(animationNotReady);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
@ -570,10 +583,12 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
public Bitmap getBitmap() {
if (currentImage != null) {
return currentImage.getBitmap();
} else if (currentThumb != null) {
return currentThumb.getBitmap();
if (currentImage instanceof AnimatedFileDrawable) {
return ((AnimatedFileDrawable) currentImage).getAnimatedBitmap();
} else if (currentImage instanceof BitmapDrawable) {
return ((BitmapDrawable) currentImage).getBitmap();
} else if (currentThumb instanceof BitmapDrawable) {
return ((BitmapDrawable) currentThumb).getBitmap();
} else if (staticThumb instanceof BitmapDrawable) {
return ((BitmapDrawable) staticThumb).getBitmap();
}
@ -581,11 +596,17 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
public int getBitmapWidth() {
if (currentImage instanceof AnimatedFileDrawable) {
return orientation == 0 || orientation == 180 ? currentImage.getIntrinsicWidth() : currentImage.getIntrinsicHeight();
}
Bitmap bitmap = getBitmap();
return orientation == 0 || orientation == 180 ? bitmap.getWidth() : bitmap.getHeight();
}
public int getBitmapHeight() {
if (currentImage instanceof AnimatedFileDrawable) {
return orientation == 0 || orientation == 180 ? currentImage.getIntrinsicHeight() : currentImage.getIntrinsicWidth();
}
Bitmap bitmap = getBitmap();
return orientation == 0 || orientation == 180 ? bitmap.getHeight() : bitmap.getWidth();
}
@ -620,12 +641,20 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return currentImage != null || currentThumb != null || currentKey != null || currentHttpUrl != null || staticThumb != null;
}
public boolean hasBitmapImage() {
return currentImage != null || currentThumb != null || staticThumb != null;
}
public void setAspectFit(boolean value) {
isAspectFit = value;
}
public void setParentView(View view) {
parentView = view;
if (currentImage instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) currentImage;
fileDrawable.setParentView(parentView);
}
}
public void setImageCoords(int x, int y, int width, int height) {
@ -765,6 +794,30 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return shouldGenerateQualityThumb;
}
public void setAllowStartAnimation(boolean value) {
allowStartAnimation = value;
}
public boolean isAllowStartAnimation() {
return allowStartAnimation;
}
public void startAnimation() {
if (currentImage instanceof AnimatedFileDrawable) {
((AnimatedFileDrawable) currentImage).start();
}
}
public void stopAnimation() {
if (currentImage instanceof AnimatedFileDrawable) {
((AnimatedFileDrawable) currentImage).stop();
}
}
public boolean isAnimationRunning() {
return currentImage instanceof AnimatedFileDrawable && ((AnimatedFileDrawable) currentImage).isRunning();
}
protected Integer getTag(boolean thumb) {
if (thumb) {
return thumbTag;
@ -781,15 +834,17 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
}
}
protected void setImageBitmapByKey(BitmapDrawable bitmap, String key, boolean thumb, boolean memCache) {
protected boolean setImageBitmapByKey(BitmapDrawable bitmap, String key, boolean thumb, boolean memCache) {
if (bitmap == null || key == null) {
return;
return false;
}
if (!thumb) {
if (currentKey == null || !key.equals(currentKey)) {
return;
return false;
}
if (!(bitmap instanceof AnimatedFileDrawable)) {
ImageLoader.getInstance().incrementUseCount(currentKey);
}
ImageLoader.getInstance().incrementUseCount(currentKey);
currentImage = bitmap;
if (roundRadius != 0) {
Bitmap object = bitmap.getBitmap();
@ -807,6 +862,13 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} else {
currentAlpha = 1.0f;
}
if (bitmap instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) bitmap;
fileDrawable.setParentView(parentView);
if (allowStartAnimation) {
fileDrawable.start();
}
}
if (parentView != null) {
if (invalidateAll) {
@ -815,9 +877,9 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
parentView.invalidate(imageX, imageY, imageX + imageW, imageY + imageH);
}
}
} else if (currentThumb == null && (currentImage == null || forcePreview)) {
} else if (currentThumb == null && (currentImage == null || (currentImage instanceof AnimatedFileDrawable && !((AnimatedFileDrawable) currentImage).hasBitmap()) || forcePreview)) {
if (currentThumbKey == null || !key.equals(currentThumbKey)) {
return;
return false;
}
ImageLoader.getInstance().incrementUseCount(currentThumbKey);
@ -843,11 +905,12 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (delegate != null) {
delegate.didSetImage(this, currentImage != null || currentThumb != null || staticThumb != null, currentImage == null);
}
return true;
}
private void recycleBitmap(String newKey, boolean thumb) {
String key;
BitmapDrawable image;
Drawable image;
if (thumb) {
key = currentThumbKey;
image = currentThumb;
@ -855,19 +918,21 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
key = currentKey;
image = currentImage;
}
BitmapDrawable newBitmap = null;
if (newKey != null) {
newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey);
}
if (key != null && image != newBitmap && image != null) {
Bitmap bitmap = image.getBitmap();
boolean canDelete = ImageLoader.getInstance().decrementUseCount(key);
if (!ImageLoader.getInstance().isInCache(key)) {
if (ImageLoader.getInstance().runtimeHack != null) {
ImageLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight());
}
if (canDelete) {
bitmap.recycle();
if (key != null && (newKey == null || !newKey.equals(key)) && image != null) {
if (image instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) image;
fileDrawable.stop();
fileDrawable.recycle();
} else if (image instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) image).getBitmap();
boolean canDelete = ImageLoader.getInstance().decrementUseCount(key);
if (!ImageLoader.getInstance().isInCache(key)) {
if (ImageLoader.getInstance().runtimeHack != null) {
ImageLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight());
}
if (canDelete) {
bitmap.recycle();
}
}
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -820,7 +820,11 @@ public class LocaleController {
return String.format(Locale.US, "%d.%d%s", number, lastDec, K);
}
}
return String.format(Locale.US, "%d%s", number, K);
if (K.length() == 2) {
return String.format(Locale.US, "%dM", number);
} else {
return String.format(Locale.US, "%d%s", number, K);
}
}
public static String formatUserStatus(TLRPC.User user) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -46,7 +46,6 @@ import android.os.ParcelFileDescriptor;
import android.os.PowerManager;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.view.View;
import org.telegram.messenger.audioinfo.AudioInfo;
import org.telegram.messenger.query.SharedMediaQuery;
@ -56,8 +55,6 @@ import org.telegram.messenger.video.Mp4Movie;
import org.telegram.messenger.video.OutputSurface;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Components.GifDrawable;
import java.io.File;
import java.io.FileInputStream;
@ -190,7 +187,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
public static class SearchImage {
public int uid;
public String id;
public String imageUrl;
public String thumbUrl;
@ -203,6 +199,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public String thumbPath;
public String imagePath;
public CharSequence caption;
public TLRPC.Document document;
}
public final static String MIME_TYPE = "video/avc";
@ -230,6 +227,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public static final int AUTODOWNLOAD_MASK_AUDIO = 2;
public static final int AUTODOWNLOAD_MASK_VIDEO = 4;
public static final int AUTODOWNLOAD_MASK_DOCUMENT = 8;
public static final int AUTODOWNLOAD_MASK_MUSIC = 16;
public static final int AUTODOWNLOAD_MASK_GIF = 32;
public int mobileDataDownloadMask = 0;
public int wifiDownloadMask = 0;
public int roamingDownloadMask = 0;
@ -237,10 +236,13 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private ArrayList<DownloadObject> photoDownloadQueue = new ArrayList<>();
private ArrayList<DownloadObject> audioDownloadQueue = new ArrayList<>();
private ArrayList<DownloadObject> documentDownloadQueue = new ArrayList<>();
private ArrayList<DownloadObject> musicDownloadQueue = new ArrayList<>();
private ArrayList<DownloadObject> gifDownloadQueue = new ArrayList<>();
private ArrayList<DownloadObject> videoDownloadQueue = new ArrayList<>();
private HashMap<String, DownloadObject> downloadQueueKeys = new HashMap<>();
private boolean saveToGallery = true;
private boolean autoplayGifs = true;
private boolean shuffleMusic;
private int repeatMode;
@ -254,10 +256,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
private ArrayList<FileDownloadProgressListener> deleteLaterArray = new ArrayList<>();
private int lastTag = 0;
private GifDrawable currentGifDrawable;
private MessageObject currentGifMessageObject;
private ChatMediaCell currentMediaCell;
private boolean isPaused = false;
private MediaPlayer audioPlayer = null;
private AudioTrack audioTrackPlayer = null;
@ -535,10 +533,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
fileDecodingQueue = new DispatchQueue("fileDecodingQueue");
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
mobileDataDownloadMask = preferences.getInt("mobileDataDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO);
wifiDownloadMask = preferences.getInt("wifiDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO);
mobileDataDownloadMask = preferences.getInt("mobileDataDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO | AUTODOWNLOAD_MASK_MUSIC | (Build.VERSION.SDK_INT >= 11 ? AUTODOWNLOAD_MASK_GIF : 0));
wifiDownloadMask = preferences.getInt("wifiDownloadMask", AUTODOWNLOAD_MASK_PHOTO | AUTODOWNLOAD_MASK_AUDIO | AUTODOWNLOAD_MASK_MUSIC | (Build.VERSION.SDK_INT >= 11 ? AUTODOWNLOAD_MASK_GIF : 0));
roamingDownloadMask = preferences.getInt("roamingDownloadMask", 0);
saveToGallery = preferences.getBoolean("save_gallery", false);
autoplayGifs = preferences.getBoolean("autoplay_gif", true) && Build.VERSION.SDK_INT >= 11;
shuffleMusic = preferences.getBoolean("shuffleMusic", false);
repeatMode = preferences.getInt("repeatMode", 0);
@ -670,18 +669,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public void cleanup() {
cleanupPlayer(false, true);
if (currentGifDrawable != null) {
currentGifDrawable.recycle();
currentGifDrawable = null;
}
currentMediaCell = null;
audioInfo = null;
playMusicAgain = false;
currentGifMessageObject = null;
photoDownloadQueue.clear();
audioDownloadQueue.clear();
documentDownloadQueue.clear();
videoDownloadQueue.clear();
musicDownloadQueue.clear();
gifDownloadQueue.clear();
downloadQueueKeys.clear();
videoConvertQueue.clear();
playlist.clear();
@ -704,6 +699,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if ((mobileDataDownloadMask & AUTODOWNLOAD_MASK_DOCUMENT) != 0 || (wifiDownloadMask & AUTODOWNLOAD_MASK_DOCUMENT) != 0 || (roamingDownloadMask & AUTODOWNLOAD_MASK_DOCUMENT) != 0) {
mask |= AUTODOWNLOAD_MASK_DOCUMENT;
}
if ((mobileDataDownloadMask & AUTODOWNLOAD_MASK_MUSIC) != 0 || (wifiDownloadMask & AUTODOWNLOAD_MASK_MUSIC) != 0 || (roamingDownloadMask & AUTODOWNLOAD_MASK_MUSIC) != 0) {
mask |= AUTODOWNLOAD_MASK_MUSIC;
}
if ((mobileDataDownloadMask & AUTODOWNLOAD_MASK_GIF) != 0 || (wifiDownloadMask & AUTODOWNLOAD_MASK_GIF) != 0 || (roamingDownloadMask & AUTODOWNLOAD_MASK_GIF) != 0) {
mask |= AUTODOWNLOAD_MASK_GIF;
}
return mask;
}
@ -718,7 +719,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_PHOTO);
}
} else {
for (DownloadObject downloadObject : photoDownloadQueue) {
for (int a = 0; a < photoDownloadQueue.size(); a++) {
DownloadObject downloadObject = photoDownloadQueue.get(a);
FileLoader.getInstance().cancelLoadFile((TLRPC.PhotoSize) downloadObject.object);
}
photoDownloadQueue.clear();
@ -728,7 +730,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_AUDIO);
}
} else {
for (DownloadObject downloadObject : audioDownloadQueue) {
for (int a = 0; a < audioDownloadQueue.size(); a++) {
DownloadObject downloadObject = audioDownloadQueue.get(a);
FileLoader.getInstance().cancelLoadFile((TLRPC.Audio) downloadObject.object);
}
audioDownloadQueue.clear();
@ -738,8 +741,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_DOCUMENT);
}
} else {
for (DownloadObject downloadObject : documentDownloadQueue) {
FileLoader.getInstance().cancelLoadFile((TLRPC.Document) downloadObject.object);
for (int a = 0; a < documentDownloadQueue.size(); a++) {
DownloadObject downloadObject = documentDownloadQueue.get(a);
TLRPC.Document document = (TLRPC.Document) downloadObject.object;
FileLoader.getInstance().cancelLoadFile(document);
}
documentDownloadQueue.clear();
}
@ -748,11 +753,36 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_VIDEO);
}
} else {
for (DownloadObject downloadObject : videoDownloadQueue) {
for (int a = 0; a < videoDownloadQueue.size(); a++) {
DownloadObject downloadObject = videoDownloadQueue.get(a);
FileLoader.getInstance().cancelLoadFile((TLRPC.Video) downloadObject.object);
}
videoDownloadQueue.clear();
}
if ((currentMask & AUTODOWNLOAD_MASK_MUSIC) != 0) {
if (musicDownloadQueue.isEmpty()) {
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_MUSIC);
}
} else {
for (int a = 0; a < musicDownloadQueue.size(); a++) {
DownloadObject downloadObject = musicDownloadQueue.get(a);
TLRPC.Document document = (TLRPC.Document) downloadObject.object;
FileLoader.getInstance().cancelLoadFile(document);
}
musicDownloadQueue.clear();
}
if ((currentMask & AUTODOWNLOAD_MASK_GIF) != 0) {
if (gifDownloadQueue.isEmpty()) {
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_GIF);
}
} else {
for (int a = 0; a < gifDownloadQueue.size(); a++) {
DownloadObject downloadObject = gifDownloadQueue.get(a);
TLRPC.Document document = (TLRPC.Document) downloadObject.object;
FileLoader.getInstance().cancelLoadFile(document);
}
gifDownloadQueue.clear();
}
int mask = getAutodownloadMask();
if (mask == 0) {
@ -770,6 +800,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if ((mask & AUTODOWNLOAD_MASK_DOCUMENT) == 0) {
MessagesStorage.getInstance().clearDownloadQueue(AUTODOWNLOAD_MASK_DOCUMENT);
}
if ((mask & AUTODOWNLOAD_MASK_MUSIC) == 0) {
MessagesStorage.getInstance().clearDownloadQueue(AUTODOWNLOAD_MASK_MUSIC);
}
if ((mask & AUTODOWNLOAD_MASK_GIF) == 0) {
MessagesStorage.getInstance().clearDownloadQueue(AUTODOWNLOAD_MASK_GIF);
}
}
}
@ -800,9 +836,20 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
queue = videoDownloadQueue;
} else if (type == AUTODOWNLOAD_MASK_DOCUMENT) {
queue = documentDownloadQueue;
} else if (type == AUTODOWNLOAD_MASK_MUSIC) {
queue = musicDownloadQueue;
} else if (type == AUTODOWNLOAD_MASK_GIF) {
queue = gifDownloadQueue;
}
for (DownloadObject downloadObject : objects) {
String path = FileLoader.getAttachFileName(downloadObject.object);
for (int a = 0; a < objects.size(); a++) {
DownloadObject downloadObject = objects.get(a);
String path;
if (downloadObject.object instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document) downloadObject.object;
path = FileLoader.getAttachFileName(document);
} else {
path = FileLoader.getAttachFileName(downloadObject.object);
}
if (downloadQueueKeys.containsKey(path)) {
continue;
}
@ -815,7 +862,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} else if (downloadObject.object instanceof TLRPC.Video) {
FileLoader.getInstance().loadFile((TLRPC.Video) downloadObject.object, false);
} else if (downloadObject.object instanceof TLRPC.Document) {
FileLoader.getInstance().loadFile((TLRPC.Document) downloadObject.object, false, false);
TLRPC.Document document = (TLRPC.Document) downloadObject.object;
FileLoader.getInstance().loadFile(document, false, false);
} else {
added = false;
}
@ -840,6 +888,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if ((mask & AUTODOWNLOAD_MASK_DOCUMENT) != 0 && (downloadMask & AUTODOWNLOAD_MASK_DOCUMENT) != 0 && documentDownloadQueue.isEmpty()) {
MessagesStorage.getInstance().getDownloadQueue(AUTODOWNLOAD_MASK_DOCUMENT);
}
if ((mask & AUTODOWNLOAD_MASK_MUSIC) != 0 && (downloadMask & AUTODOWNLOAD_MASK_MUSIC) != 0 && musicDownloadQueue.isEmpty()) {
MessagesStorage.getInstance().getDownloadQueue(AUTODOWNLOAD_MASK_MUSIC);
}
if ((mask & AUTODOWNLOAD_MASK_GIF) != 0 && (downloadMask & AUTODOWNLOAD_MASK_GIF) != 0 && gifDownloadQueue.isEmpty()) {
MessagesStorage.getInstance().getDownloadQueue(AUTODOWNLOAD_MASK_GIF);
}
}
private void checkDownloadFinished(String fileName, int state) {
@ -869,6 +923,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (documentDownloadQueue.isEmpty()) {
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_DOCUMENT);
}
} else if (downloadObject.type == AUTODOWNLOAD_MASK_MUSIC) {
musicDownloadQueue.remove(downloadObject);
if (musicDownloadQueue.isEmpty()) {
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_MUSIC);
}
} else if (downloadObject.type == AUTODOWNLOAD_MASK_GIF) {
gifDownloadQueue.remove(downloadObject);
if (gifDownloadQueue.isEmpty()) {
newDownloadObjectsAvailable(AUTODOWNLOAD_MASK_GIF);
}
}
}
}
@ -1596,6 +1660,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
private void checkIsNextMusicFileDownloaded() {
if ((getCurrentDownloadMask() & AUTODOWNLOAD_MASK_MUSIC) == 0) {
return;
}
ArrayList<MessageObject> currentPlayList = shuffleMusic ? shuffledPlaylist : playlist;
if (currentPlayList == null || currentPlayList.size() < 2) {
return;
@ -1615,7 +1682,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
final File cacheFile = file != null ? file : FileLoader.getPathToMessage(nextAudio.messageOwner);
boolean exist = cacheFile != null && cacheFile.exists();
if (cacheFile != null && cacheFile != file && !cacheFile.exists() && nextAudio.isMusic()) {
FileLoader.getInstance().loadFile(nextAudio.messageOwner.media.document, true, false);
FileLoader.getInstance().loadFile(nextAudio.messageOwner.media.document, false, false);
}
}
@ -1643,7 +1710,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
final File cacheFile = file != null ? file : FileLoader.getPathToMessage(messageObject.messageOwner);
if (cacheFile != null && cacheFile != file && !cacheFile.exists() && messageObject.isMusic()) {
FileLoader.getInstance().loadFile(messageObject.messageOwner.media.document, true, false);
FileLoader.getInstance().loadFile(messageObject.messageOwner.media.document, false, false);
downloadingCurrentMessage = true;
isPaused = false;
lastProgress = 0;
@ -2243,76 +2310,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
}
public GifDrawable getGifDrawable(ChatMediaCell cell, boolean create) {
if (cell == null) {
return null;
}
MessageObject messageObject = cell.getMessageObject();
if (messageObject == null) {
return null;
}
if (currentGifDrawable != null && currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
currentMediaCell = cell;
currentGifDrawable.parentView = new WeakReference<View>(cell);
return currentGifDrawable;
}
if (create) {
if (currentMediaCell != null) {
if (currentGifDrawable != null) {
currentGifDrawable.stop();
currentGifDrawable.recycle();
}
currentMediaCell.clearGifImage();
}
currentGifMessageObject = cell.getMessageObject();
currentMediaCell = cell;
File cacheFile = null;
if (currentGifMessageObject.messageOwner.attachPath != null && currentGifMessageObject.messageOwner.attachPath.length() != 0) {
File f = new File(currentGifMessageObject.messageOwner.attachPath);
if (f.length() > 0) {
cacheFile = f;
}
}
if (cacheFile == null) {
cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
}
try {
currentGifDrawable = new GifDrawable(cacheFile);
currentGifDrawable.parentView = new WeakReference<View>(cell);
return currentGifDrawable;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
return null;
}
public void clearGifDrawable(ChatMediaCell cell) {
if (cell == null) {
return;
}
MessageObject messageObject = cell.getMessageObject();
if (messageObject == null) {
return;
}
if (currentGifMessageObject != null && messageObject.getId() == currentGifMessageObject.getId()) {
if (currentGifDrawable != null) {
currentGifDrawable.stop();
currentGifDrawable.recycle();
currentGifDrawable = null;
}
currentMediaCell = null;
currentGifMessageObject = null;
}
}
public static boolean isWebp(Uri uri) {
ParcelFileDescriptor parcelFD = null;
FileInputStream input = null;
@ -2437,6 +2434,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
checkSaveToGalleryFiles();
}
public void toggleAutoplayGifs() {
autoplayGifs = !autoplayGifs;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("autoplay_gif", autoplayGifs);
editor.commit();
}
public void checkSaveToGalleryFiles() {
try {
File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram");
@ -2469,6 +2474,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
return saveToGallery;
}
public boolean canAutoplayGifs() {
return autoplayGifs;
}
public static void loadGalleryPhotosAlbums(final int guid) {
new Thread(new Runnable() {
@Override

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -375,6 +375,8 @@ public class MessageObject {
}
} else if (isMusic()) {
messageText = LocaleController.getString("AttachMusic", R.string.AttachMusic);
} else if (isGif()) {
messageText = LocaleController.getString("AttachGif", R.string.AttachGif);
} else {
String name = FileLoader.getDocumentFileName(message.media.document);
if (name != null && name.length() > 0) {
@ -418,7 +420,7 @@ public class MessageObject {
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
contentType = 1;
if (message.media.document.mime_type != null) {
if (message.media.document.mime_type.equals("image/gif") && message.media.document.thumb != null && !(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
if (isGifDocument(message.media.document)) {
type = 8;
} else if (message.media.document.mime_type.equals("image/webp") && isSticker()) {
type = 13;
@ -478,14 +480,31 @@ public class MessageObject {
generateThumbs(false);
}
public static boolean isGifDocument(TLRPC.Document document) {
return document != null && document.thumb != null && document.mime_type != null && (document.mime_type.equals("image/gif") || isNewGifDocument(document));
}
public static boolean isNewGifDocument(TLRPC.Document document) {
if (document != null && document.mime_type != null && document.mime_type.equals("video/mp4")) {
for (int a = 0; a < document.attributes.size(); a++) {
if (document.attributes.get(a) instanceof TLRPC.TL_documentAttributeAnimated) {
return true;
}
}
}
return false;
}
public void generateThumbs(boolean update) {
if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) {
if (!update) {
photoThumbs = new ArrayList<>(messageOwner.action.photo.sizes);
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
for (TLRPC.PhotoSize photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.action.photo.sizes) {
for (int a = 0; a < photoThumbs.size(); a++) {
TLRPC.PhotoSize photoObject = photoThumbs.get(a);
for (int b = 0; b < messageOwner.action.photo.sizes.size(); b++) {
TLRPC.PhotoSize size = messageOwner.action.photo.sizes.get(b);
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
@ -499,11 +518,13 @@ public class MessageObject {
}
} else if (messageOwner.media != null && !(messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
if (!update) {
if (!update || photoThumbs != null && photoThumbs.size() != messageOwner.media.photo.sizes.size()) {
photoThumbs = new ArrayList<>(messageOwner.media.photo.sizes);
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
for (TLRPC.PhotoSize photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.media.photo.sizes) {
for (int a = 0; a < photoThumbs.size(); a++) {
TLRPC.PhotoSize photoObject = photoThumbs.get(a);
for (int b = 0; b < messageOwner.media.photo.sizes.size(); b++) {
TLRPC.PhotoSize size = messageOwner.media.photo.sizes.get(b);
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
@ -537,8 +558,10 @@ public class MessageObject {
if (!update || photoThumbs == null) {
photoThumbs = new ArrayList<>(messageOwner.media.webpage.photo.sizes);
} else if (!photoThumbs.isEmpty()) {
for (TLRPC.PhotoSize photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.media.webpage.photo.sizes) {
for (int a = 0; a < photoThumbs.size(); a++) {
TLRPC.PhotoSize photoObject = photoThumbs.get(a);
for (int b = 0; b < messageOwner.media.webpage.photo.sizes.size(); b++) {
TLRPC.PhotoSize size = messageOwner.media.webpage.photo.sizes.get(b);
if (size instanceof TLRPC.TL_photoSizeEmpty) {
continue;
}
@ -749,7 +772,7 @@ public class MessageObject {
private static void addUsernamesAndHashtags(CharSequence charSequence, boolean botCommands) {
try {
if (urlPattern == null) {
urlPattern = Pattern.compile("(^|\\s)/[a-zA-Z@\\d_]{1,255}|(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w\\.]+");
urlPattern = Pattern.compile("(^|\\s)/[a-zA-Z@\\d_]{1,255}|(^|\\s)@[a-zA-Z\\d_]{3,32}|(^|\\s)#[\\w\\.]+");
}
Matcher matcher = urlPattern.matcher(charSequence);
while (matcher.find()) {
@ -815,12 +838,13 @@ public class MessageObject {
messageOwner instanceof TLRPC.TL_messageForwarded_old ||
messageOwner instanceof TLRPC.TL_messageForwarded_old2 ||
messageOwner instanceof TLRPC.TL_message_secret ||
isOut() && messageOwner.send_state != MESSAGE_SEND_STATE_SENT || messageOwner.id < 0);
isOut() && messageOwner.send_state != MESSAGE_SEND_STATE_SENT ||
messageOwner.id < 0 || messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported);
if (useManualParse) {
addLinks(messageText);
} else {
if (messageText instanceof Spannable && messageText.length() < 100) {
if (messageText instanceof Spannable && messageText.length() < 200) {
try {
Linkify.addLinks((Spannable) messageText, Linkify.PHONE_NUMBERS);
} catch (Throwable e) {
@ -844,7 +868,7 @@ public class MessageObject {
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
spannable.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/ritalic.ttf")), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (entity instanceof TLRPC.TL_messageEntityCode || entity instanceof TLRPC.TL_messageEntityPre) {
spannable.setSpan(new TypefaceSpan(Typeface.MONOSPACE), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan(new TypefaceSpan(Typeface.MONOSPACE, AndroidUtilities.dp(MessagesController.getInstance().fontSize - 1)), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
} else if (!useManualParse) {
String url = messageOwner.message.substring(entity.offset, entity.offset + entity.length);
if (entity instanceof TLRPC.TL_messageEntityBotCommand) {
@ -1315,6 +1339,14 @@ public class MessageObject {
return isMusicMessage(messageOwner);
}
public boolean isGif() {
return isGifDocument(messageOwner.media.document);
}
public boolean isNewGif() {
return messageOwner.media != null && isNewGifDocument(messageOwner.media.document);
}
public String getMusicTitle() {
for (TLRPC.DocumentAttribute attribute : messageOwner.media.document.attributes) {
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -471,9 +471,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
onlinePrivacy.clear();
lastPrintingStringCount = 0;
nextDialogsCacheOffset = 0;
updatesQueueSeq.clear();
updatesQueuePts.clear();
updatesQueueQts.clear();
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
updatesQueueSeq.clear();
updatesQueuePts.clear();
updatesQueueQts.clear();
updatesStartWaitTimeSeq = 0;
updatesStartWaitTimePts = 0;
updatesStartWaitTimeQts = 0;
gettingDifference = false;
}
});
blockedUsers.clear();
sendingTypings.clear();
loadingFullUsers.clear();
@ -484,15 +493,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
loadedFullParticipants.clear();
loadedFullChats.clear();
updatesStartWaitTimeSeq = 0;
updatesStartWaitTimePts = 0;
updatesStartWaitTimeQts = 0;
currentDeletingTaskTime = 0;
currentDeletingTaskMids = null;
gettingNewDeleteTask = false;
loadingDialogs = false;
dialogsEndReached = false;
gettingDifference = false;
loadingBlockedUsers = false;
firstGettingTask = false;
updatingState = false;
@ -872,6 +877,23 @@ public class MessagesController implements NotificationCenter.NotificationCenter
reloadingMessages.remove(dialog_id);
}
}
MessageObject dialogObj = dialogMessage.get(dialog_id);
if (dialogObj != null) {
for (int a = 0; a < objects.size(); a++) {
MessageObject obj = objects.get(a);
if (dialogObj != null && dialogObj.getId() == obj.getId()) {
dialogMessage.put(dialog_id, obj);
if (obj.messageOwner.to_id.channel_id == 0) {
obj = dialogMessagesByIds.remove(obj.getId());
if (obj != null) {
dialogMessagesByIds.put(obj.getId(), obj);
}
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
break;
}
}
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.replaceMessagesObjects, dialog_id, objects);
}
});
@ -1999,7 +2021,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
objects.add(new MessageObject(message, usersDict, chatsDict, true));
if (isCache) {
if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
if (message.media.bytes.length == 0 || message.media.bytes.length == 1 && message.media.bytes[0] < TLRPC.LAYER) {
if (message.media.bytes != null && (message.media.bytes.length == 0 || message.media.bytes.length == 1 && message.media.bytes[0] < TLRPC.LAYER)) {
messagesToReload.add(message.id);
}
} else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
@ -2298,7 +2320,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.Message message = dialogsRes.messages.get(a);
if (message.to_id.channel_id != 0) {
TLRPC.Chat chat = chatsDict.get(message.to_id.channel_id);
if (chat != null && chat.left && !chat.megagroup) {
if (chat != null && chat.left/* && !chat.megagroup*/) {
continue;
}
if (chat != null && chat.megagroup) {
@ -2340,7 +2362,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
d.top_message = Math.max(d.top_message, d.top_not_important_message);
d.unread_count = Math.max(d.unread_count, d.unread_not_important_count);
}
if (chat != null && chat.left && !chat.megagroup) {
if (chat != null && chat.left/* && !chat.megagroup*/) {
continue;
}
channelsPts.put(-(int) d.id, d.pts);
@ -2634,7 +2656,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.Message message = dialogsRes.messages.get(a);
if (message.to_id.channel_id != 0) {
TLRPC.Chat chat = chatsDict.get(message.to_id.channel_id);
if (chat != null && chat.left && !chat.megagroup) {
if (chat != null && chat.left/* && !chat.megagroup*/) {
continue;
}
} else if (message.to_id.chat_id != 0) {
@ -2659,7 +2681,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
if (d instanceof TLRPC.TL_dialogChannel) {
TLRPC.Chat chat = chatsDict.get(-(int) d.id);
if (chat != null && chat.left && !chat.megagroup) {
if (chat != null && chat.left/* && !chat.megagroup*/) {
continue;
}
} else if ((int) d.id < 0) {
@ -3607,9 +3629,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public void performLogout(boolean byUser) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
SharedPreferences.Editor editor = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE).edit();
editor.clear().commit();
editor = ApplicationLoader.applicationContext.getSharedPreferences("emoji", Activity.MODE_PRIVATE).edit();
editor.putLong("lastGifLoadTime", 0).commit();
editor = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit();
editor.remove("gifhint").commit();
if (byUser) {
unregistedPush();
TLRPC.TL_auth_logOut req = new TLRPC.TL_auth_logOut();
@ -3707,7 +3733,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
if (response instanceof TLRPC.TL_boolTrue) {
FileLog.e("tmessages", "registered for push");
UserConfig.registeredForPush = true;
UserConfig.pushString = regid;
@ -4607,6 +4633,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
final int user_id = updates instanceof TLRPC.TL_updateShortChatMessage ? updates.from_id : updates.user_id;
TLRPC.User user = getUser(user_id);
TLRPC.User user2 = null;
TLRPC.User user3 = null;
TLRPC.Chat channel = null;
if (user == null) {
@ -4631,16 +4658,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter
needFwdUser = true;
}
boolean needBotUser = false;
if (updates.via_bot_id != 0) {
user3 = getUser(updates.via_bot_id);
if (user3 == null) {
user3 = MessagesStorage.getInstance().getUserSync(updates.via_bot_id);
putUser(user3, true);
}
needBotUser = true;
}
boolean missingData;
if (updates instanceof TLRPC.TL_updateShortMessage) {
missingData = user == null || needFwdUser && user2 == null && channel == null;
missingData = user == null || needFwdUser && user2 == null && channel == null || needBotUser && user3 == null;
} else {
TLRPC.Chat chat = getChat(updates.chat_id);
if (chat == null) {
chat = MessagesStorage.getInstance().getChatSync(updates.chat_id);
putChat(chat, true);
}
missingData = chat == null || user == null || needFwdUser && user2 == null && channel == null;
missingData = chat == null || user == null || needFwdUser && user2 == null && channel == null || needBotUser && user3 == null;
}
if (user != null && user.status != null && user.status.expires <= 0) {
onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime());
@ -4675,6 +4712,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
message.entities = updates.entities;
message.message = updates.message;
message.date = updates.date;
message.via_bot_id = updates.via_bot_id;
message.flags = updates.flags | TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
message.fwd_from_id = updates.fwd_from_id;
message.fwd_date = updates.fwd_date;
@ -5085,9 +5123,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (chat.megagroup) {
message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP;
}
if (chat.left) {
continue;
}
}
if (message.from_id > 0) {
TLRPC.User user = getUser(message.from_id);
@ -5485,6 +5520,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
updatesOnMainThread.add(update);
} else if (update instanceof TLRPC.TL_updateNewStickerSet) {
updatesOnMainThread.add(update);
} else if (update instanceof TLRPC.TL_updateSavedGifs) {
updatesOnMainThread.add(update);
}
}
if (!messages.isEmpty()) {
@ -5672,6 +5709,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
StickersQuery.reorderStickers(update.order);
} else if (update instanceof TLRPC.TL_updateNewStickerSet) {
StickersQuery.addNewStickerSet(update.stickerset);
} else if (update instanceof TLRPC.TL_updateSavedGifs) {
SharedPreferences.Editor editor2 = ApplicationLoader.applicationContext.getSharedPreferences("emoji", Activity.MODE_PRIVATE).edit();
editor2.putLong("lastGifLoadTime", 0).commit();
}
}
if (editor != null) {
@ -5893,6 +5933,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
updateInterfaceWithMessages(uid, messages, false);
}
protected static void addNewGifToRecent(TLRPC.Document document, int date) {
ArrayList<MediaController.SearchImage> arrayList = new ArrayList<>();
MediaController.SearchImage searchImage = new MediaController.SearchImage();
searchImage.type = 2;
searchImage.document = document;
searchImage.date = date;
searchImage.id = "" + searchImage.document.id;
arrayList.add(searchImage);
MessagesStorage.getInstance().putWebRecent(arrayList);
}
protected void updateInterfaceWithMessages(final long uid, final ArrayList<MessageObject> messages, boolean isBroadcast) {
if (messages == null || messages.isEmpty()) {
return;
@ -5911,6 +5962,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
channelId = message.messageOwner.to_id.channel_id;
}
}
if (message.isOut() && message.isNewGif() && !message.isSending()) {
addNewGifToRecent(message.messageOwner.media.document, message.messageOwner.date);
}
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceivedNewMessages, uid, messages);
@ -5941,7 +5995,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (dialog == null) {
if (!isBroadcast) {
TLRPC.Chat chat = getChat(channelId);
if (chat != null && chat.left) {
if (channelId != 0 && chat == null || chat != null && chat.left) {
return;
}
if (!ChatObject.isChannel(chat)) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -153,7 +153,8 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE user_photos(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose();
database.executeFast("CREATE TABLE blocked_users(uid INTEGER PRIMARY KEY)").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE web_recent_v3(id TEXT, type INTEGER, image_url TEXT, thumb_url TEXT, local_url TEXT, width INTEGER, height INTEGER, size INTEGER, date INTEGER, PRIMARY KEY (id, type));").stepThis().dispose();
database.executeFast("CREATE TABLE web_recent_v3(id TEXT, type INTEGER, image_url TEXT, thumb_url TEXT, local_url TEXT, width INTEGER, height INTEGER, size INTEGER, date INTEGER, document BLOB, PRIMARY KEY (id, type));").stepThis().dispose();
database.executeFast("CREATE TABLE bot_recent(id INTEGER PRIMARY KEY, date INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_v2(id INTEGER PRIMARY KEY, data BLOB, date INTEGER, hash TEXT);").stepThis().dispose();
database.executeFast("CREATE TABLE hashtag_recent_v2(id TEXT PRIMARY KEY, date INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE webpage_pending(id INTEGER, mid INTEGER, PRIMARY KEY (id, mid));").stepThis().dispose();
@ -165,7 +166,7 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE bot_info(uid INTEGER PRIMARY KEY, info BLOB)").stepThis().dispose();
//version
database.executeFast("PRAGMA user_version = 27").stepThis().dispose();
database.executeFast("PRAGMA user_version = 29").stepThis().dispose();
//database.executeFast("CREATE TABLE secret_holes(uid INTEGER, seq_in INTEGER, seq_out INTEGER, data BLOB, PRIMARY KEY (uid, seq_in, seq_out));").stepThis().dispose();
//database.executeFast("CREATE TABLE attach_data(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose();
@ -199,7 +200,7 @@ public class MessagesStorage {
}
}
int version = database.executeInt("PRAGMA user_version");
if (version < 27) {
if (version < 29) {
updateDbToLastVersion(version);
}
}
@ -476,7 +477,17 @@ public class MessagesStorage {
if (version == 25 || version == 26) {
database.executeFast("CREATE TABLE IF NOT EXISTS channel_users_v2(did INTEGER, uid INTEGER, date INTEGER, data BLOB, PRIMARY KEY(did, uid))").stepThis().dispose();
database.executeFast("PRAGMA user_version = 27").stepThis().dispose();
//version = 27;
version = 27;
}
if (version == 27) {
database.executeFast("ALTER TABLE web_recent_v3 ADD COLUMN document BLOB default NULL").stepThis().dispose();
database.executeFast("PRAGMA user_version = 28").stepThis().dispose();
version = 28;
}
if (version == 28) {
database.executeFast("CREATE TABLE IF NOT EXISTS bot_recent(id INTEGER PRIMARY KEY, date INTEGER);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 29").stepThis().dispose();
//version = 29;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
@ -752,7 +763,7 @@ public class MessagesStorage {
@Override
public void run() {
try {
SQLiteCursor cursor = database.queryFinalized("SELECT id, image_url, thumb_url, local_url, width, height, size, date FROM web_recent_v3 WHERE type = " + type);
SQLiteCursor cursor = database.queryFinalized("SELECT id, image_url, thumb_url, local_url, width, height, size, date, document FROM web_recent_v3 WHERE type = " + type + " ORDER BY date DESC");
final ArrayList<MediaController.SearchImage> arrayList = new ArrayList<>();
while (cursor.next()) {
MediaController.SearchImage searchImage = new MediaController.SearchImage();
@ -764,28 +775,56 @@ public class MessagesStorage {
searchImage.height = cursor.intValue(5);
searchImage.size = cursor.intValue(6);
searchImage.date = cursor.intValue(7);
if (!cursor.isNull(8)) {
NativeByteBuffer data = new NativeByteBuffer(cursor.byteArrayLength(8));
if (data != null && cursor.byteBufferValue(8, data) != 0) {
searchImage.document = TLRPC.Document.TLdeserialize(data, data.readInt32(false), false);
}
data.reuse();
}
searchImage.type = type;
arrayList.add(searchImage);
}
cursor.dispose();
Collections.sort(arrayList, new Comparator<MediaController.SearchImage>() {
@Override
public int compare(MediaController.SearchImage lhs, MediaController.SearchImage rhs) {
if (lhs.date < rhs.date) {
return 1;
} else if (lhs.date > rhs.date) {
return -1;
} else {
return 0;
}
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.recentImagesDidLoaded, type, arrayList);
}
});
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
}
});
}
public void addRecentLocalFile(final String imageUrl, final String localUrl, final TLRPC.Document document) {
if (imageUrl == null || imageUrl.length() == 0 || ((localUrl == null || localUrl.length() == 0) && document == null)) {
return;
}
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
if (document != null) {
SQLitePreparedStatement state = database.executeFast("UPDATE web_recent_v3 SET document = ? WHERE image_url = ?");
state.requery();
NativeByteBuffer data = new NativeByteBuffer(document.getObjectSize());
document.serializeToStream(data);
state.bindByteBuffer(1, data);
state.bindString(2, imageUrl);
state.step();
state.dispose();
data.reuse();
} else {
SQLitePreparedStatement state = database.executeFast("UPDATE web_recent_v3 SET local_url = ? WHERE image_url = ?");
state.requery();
state.bindString(1, localUrl);
state.bindString(2, imageUrl);
state.step();
state.dispose();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -793,15 +832,15 @@ public class MessagesStorage {
});
}
public void addRecentLocalFile(final String imageUrl, final String localUrl) {
if (imageUrl == null || localUrl == null || imageUrl.length() == 0 || localUrl.length() == 0) {
public void removeWebRecent(final MediaController.SearchImage searchImage) {
if (searchImage == null) {
return;
}
storageQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
database.executeFast("UPDATE web_recent_v3 SET local_url = '" + localUrl + "' WHERE image_url = '" + imageUrl + "'").stepThis().dispose();
database.executeFast("DELETE FROM web_recent_v3 WHERE id = '" + searchImage.id + "'").stepThis().dispose();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@ -828,32 +867,40 @@ public class MessagesStorage {
public void run() {
try {
database.beginTransaction();
SQLitePreparedStatement state = database.executeFast("REPLACE INTO web_recent_v3 VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
SQLitePreparedStatement state = database.executeFast("REPLACE INTO web_recent_v3 VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
for (int a = 0; a < arrayList.size(); a++) {
if (a == 100) {
if (a == 200) {
break;
}
MediaController.SearchImage searchImage = arrayList.get(a);
if (searchImage.localUrl == null) {
searchImage.localUrl = "";
}
state.requery();
state.bindString(1, searchImage.id);
state.bindInteger(2, searchImage.type);
state.bindString(3, searchImage.imageUrl);
state.bindString(4, searchImage.thumbUrl);
state.bindString(5, searchImage.localUrl);
state.bindString(3, searchImage.imageUrl != null ? searchImage.imageUrl : "");
state.bindString(4, searchImage.thumbUrl != null ? searchImage.thumbUrl : "");
state.bindString(5, searchImage.localUrl != null ? searchImage.localUrl : "");
state.bindInteger(6, searchImage.width);
state.bindInteger(7, searchImage.height);
state.bindInteger(8, searchImage.size);
state.bindInteger(9, searchImage.date);
NativeByteBuffer data = null;
if (searchImage.document != null) {
data = new NativeByteBuffer(searchImage.document.getObjectSize());
searchImage.document.serializeToStream(data);
state.bindByteBuffer(10, data);
} else {
state.bindNull(10);
}
state.step();
if (data != null) {
data.reuse();
}
}
state.dispose();
database.commitTransaction();
if (arrayList.size() >= 100) {
if (arrayList.size() >= 200) {
database.beginTransaction();
for (int a = 100; a < arrayList.size(); a++) {
for (int a = 200; a < arrayList.size(); a++) {
database.executeFast("DELETE FROM web_recent_v3 WHERE id = '" + arrayList.get(a).id + "'").stepThis().dispose();
}
database.commitTransaction();
@ -3589,7 +3636,7 @@ public class MessagesStorage {
type = MediaController.AUTODOWNLOAD_MASK_VIDEO;
object = message.media.video;
}
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
} else if (message.media instanceof TLRPC.TL_messageMediaDocument && !MessageObject.isMusicMessage(message) && !MessageObject.isGifDocument(message.media.document)) {
if ((downloadMask & MediaController.AUTODOWNLOAD_MASK_DOCUMENT) != 0) {
id = message.media.document.id;
type = MediaController.AUTODOWNLOAD_MASK_DOCUMENT;
@ -4906,6 +4953,9 @@ public class MessagesStorage {
}
}
}
if (message.via_bot_id != 0 && !usersToLoad.contains(message.via_bot_id)) {
usersToLoad.add(message.via_bot_id);
}
if (message.action != null) {
if (message.action.user_id != 0 && !usersToLoad.contains(message.action.user_id)) {
usersToLoad.add(message.action.user_id);
@ -5353,7 +5403,13 @@ public class MessagesStorage {
cursor.dispose();
}
}
semaphore.release();
try {
if (semaphore != null) {
semaphore.release();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
});
try {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -7,6 +7,7 @@ import android.util.Log;
import net.hockeyapp.android.Constants;
import net.hockeyapp.android.utils.SimpleMultipartEntity;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@ -71,7 +72,7 @@ public class NativeCrashManager {
attachmentUri = Uri.fromFile(new File(Constants.FILES_PATH, logFilename));
input = activity.getContentResolver().openInputStream(attachmentUri);
entity.addPart("log", attachmentUri.getLastPathSegment(), input, false);
entity.addPart("log", attachmentUri.getLastPathSegment(), input, true);
entity.writeLastBoundaryIfNeeds();
@ -80,9 +81,15 @@ public class NativeCrashManager {
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("Content-Type", entity.getContentType());
urlConnection.setRequestProperty("Content-Length", String.valueOf(entity.getContentLength()));
urlConnection.getOutputStream().write(entity.getOutputStream().toByteArray());
BufferedOutputStream outputStream = new BufferedOutputStream(urlConnection.getOutputStream());
outputStream.write(entity.getOutputStream().toByteArray());
outputStream.flush();
outputStream.close();
urlConnection.connect();
FileLog.e("tmessages", "response code = " + urlConnection.getResponseCode() + " message = " + urlConnection.getResponseMessage());
} catch (IOException e) {
e.printStackTrace();
} finally {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private final static int LIB_VERSION = 15;
private final static int LIB_VERSION = 17;
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
@ -220,4 +220,5 @@ public class NativeLoader {
}
private static native void init(String path, boolean enable);
//public static native void crash();
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -66,6 +66,7 @@ public class NotificationCenter {
public static final int needShowAlert = totalEvents++;
public static final int didUpdatedMessagesViews = totalEvents++;
public static final int needReloadRecentDialogsSearch = totalEvents++;
public static final int locationPermissionGranted = totalEvents++;
public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -756,6 +756,8 @@ public class NotificationsController {
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageObject.isSticker()) {
msg = LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, name);
} else if (messageObject.isGif()) {
msg = LocaleController.formatString("NotificationMessageGif", R.string.NotificationMessageGif, name);
} else {
msg = LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, name);
}
@ -864,6 +866,8 @@ public class NotificationsController {
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageObject.isSticker()) {
msg = LocaleController.formatString("ChannelMessageSticker", R.string.ChannelMessageSticker, name, chat.title);
} else if (messageObject.isGif()) {
msg = LocaleController.formatString("ChannelMessageGIF", R.string.ChannelMessageGIF, name, chat.title);
} else {
msg = LocaleController.formatString("ChannelMessageDocument", R.string.ChannelMessageDocument, name, chat.title);
}
@ -888,6 +892,8 @@ public class NotificationsController {
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageObject.isSticker()) {
msg = LocaleController.formatString("ChannelMessageGroupSticker", R.string.ChannelMessageGroupSticker, name, chat.title);
} else if (messageObject.isGif()) {
msg = LocaleController.formatString("ChannelMessageGroupGif", R.string.ChannelMessageGroupGif, name, chat.title);
} else {
msg = LocaleController.formatString("ChannelMessageGroupDocument", R.string.ChannelMessageGroupDocument, name, chat.title);
}
@ -913,6 +919,8 @@ public class NotificationsController {
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageObject.isSticker()) {
msg = LocaleController.formatString("NotificationMessageGroupSticker", R.string.NotificationMessageGroupSticker, name, chat.title);
} else if (messageObject.isGif()) {
msg = LocaleController.formatString("NotificationMessageGroupGif", R.string.NotificationMessageGroupGif, name, chat.title);
} else {
msg = LocaleController.formatString("NotificationMessageGroupDocument", R.string.NotificationMessageGroupDocument, name, chat.title);
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -538,7 +538,7 @@ public class SecretChatHelper {
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
File cacheFile2 = FileLoader.getPathToAttach(size);
cacheFile.renameTo(cacheFile2);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, true);
ArrayList<TLRPC.Message> arr = new ArrayList<>();
arr.add(newMsg);
MessagesStorage.getInstance().putMessages(arr, false, true, false, 0);

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -143,7 +143,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
arr.remove(a);
a--;
} else if (encryptedFile != null && message.sendEncryptedRequest != null) {
if (message.sendEncryptedRequest.media instanceof TLRPC.TL_decryptedMessageMediaVideo) {
if (message.sendEncryptedRequest.media instanceof TLRPC.TL_decryptedMessageMediaVideo || message.sendEncryptedRequest.media instanceof TLRPC.TL_decryptedMessageMediaPhoto) {
long size = (Long) args[5];
message.sendEncryptedRequest.media.size = (int) size;
}
@ -206,7 +206,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (finalSize != 0) {
ArrayList<DelayedMessage> arr = delayedMessages.get(messageObject.messageOwner.attachPath);
if (arr != null) {
for (DelayedMessage message : arr) {
for (int a = 0; a < arr.size(); a++) {
DelayedMessage message = arr.get(a);
if (message.obj == messageObject) {
message.obj.videoEditedInfo = null;
message.obj.messageOwner.message = "-1";
@ -440,14 +441,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage)) {
if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) {
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did, messageObject.replyMessageObject, asAdmin);
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, did, messageObject.replyMessageObject, asAdmin, null);
} else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) {
sendMessage((TLRPC.TL_audio) messageObject.messageOwner.media.audio, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin);
} else if (messageObject.messageOwner.media.video instanceof TLRPC.TL_video) {
TLRPC.TL_video video = (TLRPC.TL_video) messageObject.messageOwner.media.video;
sendMessage(video, messageObject.videoEditedInfo, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin);
sendMessage(video, messageObject.videoEditedInfo, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin, null);
} else if (messageObject.messageOwner.media.document instanceof TLRPC.TL_document) {
sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, null, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin);
sendMessage((TLRPC.TL_document) messageObject.messageOwner.media.document, messageObject.messageOwner.attachPath, did, messageObject.replyMessageObject, asAdmin, null);
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject, asAdmin);
} else if (messageObject.messageOwner.media.phone_number != null) {
@ -467,7 +468,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
webPage = messageObject.messageOwner.media.webpage;
}
sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true, asAdmin);
sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true, asAdmin, messageObject.messageOwner.entities, null);
} else {
ArrayList<MessageObject> arrayList = new ArrayList<>();
arrayList.add(messageObject);
@ -522,11 +523,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
}
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, peer, replyingMessageObject, asAdmin);
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, peer, replyingMessageObject, asAdmin, null);
}
public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, null, null, null, null, user, null, null, null, peer, null, reply_to_msg, null, true, asAdmin, null);
sendMessage(null, null, null, null, null, user, null, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, null);
}
public void sendMessage(ArrayList<MessageObject> messages, final long peer, boolean asAdmin) {
@ -558,6 +559,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (msgObj.getId() <= 0) {
continue;
}
if (BuildVars.DEBUG_VERSION) {
FileLog.d("tmessages", "forward message with id = " + msgObj.getId());
}
final TLRPC.Message newMsg = new TLRPC.TL_message();
if (msgObj.isForwarded()) {
@ -580,6 +584,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (isMegagroup) {
newMsg.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP;
}
if (msgObj.messageOwner.via_bot_id != 0) {
newMsg.via_bot_id = msgObj.messageOwner.via_bot_id;
newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_BOT_ID;
}
newMsg.message = msgObj.messageOwner.message;
newMsg.fwd_msg_id = msgObj.getId();
newMsg.attachPath = msgObj.messageOwner.attachPath;
@ -694,7 +702,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
sentMessages.add(message);
newMsgObj.id = message.id;
processSentMessage(newMsgObj, message, null);
processSentMessage(newMsgObj, message, null, true);
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
@ -727,7 +735,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
});
}
for (final TLRPC.Message newMsgObj : newMsgObjArr) {
for (int a = 0; a < newMsgObjArr.size(); a++) {
final TLRPC.Message newMsgObj = newMsgObjArr.get(a);
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
@ -757,38 +766,43 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
public void sendMessage(MessageObject retryMessageObject, boolean asAdmin) {
sendMessage(null, null, null, null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, true, asAdmin, retryMessageObject);
sendMessage(null, null, null, null, null, null, null, null, retryMessageObject.getDialogId(), retryMessageObject.messageOwner.attachPath, null, null, true, asAdmin, retryMessageObject, null, retryMessageObject.messageOwner.params);
}
public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, null, null, null, null, null, document, null, originalPath, peer, path, reply_to_msg, null, true, asAdmin, null);
public void sendMessage(TLRPC.TL_document document, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap<String, String> params) {
sendMessage(null, null, null, null, null, null, document, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, params);
}
public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin) {
sendMessage(message, null, null, null, null, null, null, null, null, peer, null, reply_to_msg, webPage, searchLinks, asAdmin, null);
public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, ArrayList<TLRPC.MessageEntity> entities, HashMap<String, String> params) {
sendMessage(message, null, null, null, null, null, null, null, peer, null, reply_to_msg, webPage, searchLinks, asAdmin, null, entities, params);
}
public void sendMessage(TLRPC.MessageMedia location, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, location, null, null, null, null, null, null, null, peer, null, reply_to_msg, null, true, asAdmin, null);
sendMessage(null, location, null, null, null, null, null, null, peer, null, reply_to_msg, null, true, asAdmin, null, null, null);
}
public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, null, photo, null, null, null, null, null, originalPath, peer, path, reply_to_msg, null, true, asAdmin, null);
public void sendMessage(TLRPC.TL_photo photo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap<String, String> params) {
sendMessage(null, null, photo, null, null, null, null, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, params);
}
public void sendMessage(TLRPC.TL_video video, VideoEditedInfo videoEditedInfo, String originalPath, String path, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, null, null, video, videoEditedInfo, null, null, null, originalPath, peer, path, reply_to_msg, null, true, asAdmin, null);
public void sendMessage(TLRPC.TL_video video, VideoEditedInfo videoEditedInfo, String path, long peer, MessageObject reply_to_msg, boolean asAdmin, HashMap<String, String> params) {
sendMessage(null, null, null, video, videoEditedInfo, null, null, null, peer, path, reply_to_msg, null, true, asAdmin, null, null, params);
}
public void sendMessage(TLRPC.TL_audio audio, String path, long peer, MessageObject reply_to_msg, boolean asAdmin) {
sendMessage(null, null, null, null, null, null, null, audio, null, peer, path, reply_to_msg, null, true, asAdmin, null);
sendMessage(null, null, null, null, null, null, null, audio, peer, path, reply_to_msg, null, true, asAdmin, null, null, null);
}
private void sendMessage(String message, TLRPC.MessageMedia location, TLRPC.TL_photo photo, TLRPC.TL_video video, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, MessageObject retryMessageObject) {
private void sendMessage(String message, TLRPC.MessageMedia location, TLRPC.TL_photo photo, TLRPC.TL_video video, VideoEditedInfo videoEditedInfo, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, long peer, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks, boolean asAdmin, MessageObject retryMessageObject, ArrayList<TLRPC.MessageEntity> entities, HashMap<String, String> params) {
if (peer == 0) {
return;
}
String originalPath = null;
if (params != null && params.containsKey("originalPath")) {
originalPath = params.get("originalPath");
}
TLRPC.Message newMsg = null;
MessageObject newMsgObj = null;
int type = -1;
@ -824,13 +838,21 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else {
if (retryMessageObject.type == 0) {
message = newMsg.message;
type = 0;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 0;
}
} else if (retryMessageObject.type == 4) {
location = newMsg.media;
type = 1;
} else if (retryMessageObject.type == 1) {
photo = (TLRPC.TL_photo) newMsg.media.photo;
type = 2;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 2;
}
} else if (retryMessageObject.type == 3) {
type = 3;
video = (TLRPC.TL_video) newMsg.media.video;
@ -843,7 +865,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
type = 6;
} else if (retryMessageObject.type == 8 || retryMessageObject.type == 9 || retryMessageObject.type == 13) {
document = (TLRPC.TL_document) newMsg.media.document;
type = 7;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 7;
}
} else if (retryMessageObject.type == 2) {
audio = (TLRPC.TL_audio) newMsg.media.audio;
type = 8;
@ -856,13 +882,20 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else {
newMsg = new TLRPC.TL_message();
}
if (entities != null && !entities.isEmpty()) {
newMsg.entities = entities;
}
if (encryptedChat != null || webPage == null) {
newMsg.media = new TLRPC.TL_messageMediaEmpty();
} else {
newMsg.media = new TLRPC.TL_messageMediaWebPage();
newMsg.media.webpage = webPage;
}
type = 0;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 0;
}
newMsg.message = message;
} else if (location != null) {
if (encryptedChat != null && AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) {
@ -882,7 +915,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg.media = new TLRPC.TL_messageMediaPhoto();
newMsg.media.caption = photo.caption != null ? photo.caption : "";
newMsg.media.photo = photo;
type = 2;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 2;
}
newMsg.message = "-1";
if (path != null && path.length() > 0 && path.startsWith("http")) {
newMsg.attachPath = path;
@ -932,8 +969,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg = new TLRPC.TL_message();
}
newMsg.media = new TLRPC.TL_messageMediaDocument();
newMsg.media.caption = document.caption != null ? document.caption : "";
newMsg.media.document = document;
type = 7;
if (params != null && params.containsKey("query_id")) {
type = 9;
} else {
type = 7;
}
newMsg.message = "-1";
newMsg.attachPath = path;
} else if (audio != null) {
@ -964,6 +1006,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (newMsg.random_id == 0) {
newMsg.random_id = getNextRandomId();
}
if (params != null && params.containsKey("bot")) {
newMsg.via_bot_id = Utilities.parseInt(params.get("bot"));
newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_BOT_ID;
}
newMsg.params = params;
newMsg.date = ConnectionsManager.getInstance().getCurrentTime();
newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA;
if (encryptedChat == null && high_id != 1 && newMsg.media instanceof TLRPC.TL_messageMediaAudio) {
@ -1163,27 +1210,35 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
inputMedia.last_name = user.last_name;
} else if (type == 7) {
if (document.access_hash == 0) {
if (document.thumb.location != null && document.thumb.location instanceof TLRPC.TL_fileLocation) {
inputMedia = new TLRPC.TL_inputMediaUploadedThumbDocument();
if (originalPath != null && originalPath.length() > 0 && originalPath.startsWith("http") && params != null) {
inputMedia = new TLRPC.TL_inputMediaGifExternal();
String args[] = params.get("url").split("\\|");
if (args.length == 2) {
inputMedia.url = args[0];
inputMedia.q = args[1];
}
} else {
inputMedia = new TLRPC.TL_inputMediaUploadedDocument();
if (document.thumb.location != null && document.thumb.location instanceof TLRPC.TL_fileLocation) {
inputMedia = new TLRPC.TL_inputMediaUploadedThumbDocument();
} else {
inputMedia = new TLRPC.TL_inputMediaUploadedDocument();
}
delayedMessage = new DelayedMessage();
delayedMessage.originalPath = originalPath;
delayedMessage.type = 2;
delayedMessage.obj = newMsgObj;
delayedMessage.documentLocation = document;
delayedMessage.location = document.thumb.location;
}
inputMedia.mime_type = document.mime_type;
inputMedia.attributes = document.attributes;
delayedMessage = new DelayedMessage();
delayedMessage.originalPath = originalPath;
delayedMessage.type = 2;
delayedMessage.obj = newMsgObj;
if (path != null && path.length() > 0 && path.startsWith("http")) {
delayedMessage.httpLocation = path;
}
delayedMessage.documentLocation = document;
delayedMessage.location = document.thumb.location;
inputMedia.caption = document.caption != null ? document.caption : "";
} else {
TLRPC.TL_inputMediaDocument media = new TLRPC.TL_inputMediaDocument();
media.id = new TLRPC.TL_inputDocument();
media.id.id = document.id;
media.id.access_hash = document.access_hash;
media.caption = document.caption != null ? document.caption : "";
inputMedia = media;
}
} else if (type == 8) {
@ -1254,7 +1309,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else if (type == 6) {
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
} else if (type == 7) {
if (document.access_hash == 0) {
if (document.access_hash == 0 && delayedMessage != null) {
performSendDelayedMessage(delayedMessage);
} else {
performSendMessageRequest(reqSend, newMsgObj.messageOwner, originalPath);
@ -1464,6 +1519,20 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.broadcast = true;
}
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
} else if (type == 9) {
TLRPC.TL_messages_sendInlineBotResult reqSend = new TLRPC.TL_messages_sendInlineBotResult();
reqSend.peer = sendToPeer;
if (asAdmin && sendToPeer instanceof TLRPC.TL_inputPeerChannel) {
reqSend.broadcast = true;
}
reqSend.random_id = newMsg.random_id;
if (reply_to_msg != null) {
reqSend.flags |= 1;
reqSend.reply_to_msg_id = reply_to_msg.getId();
}
reqSend.query_id = Utilities.parseLong(params.get("query_id"));
reqSend.id = params.get("id");
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
@ -1607,110 +1676,120 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
putToSendingMessages(newMsgObj);
ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, final TLRPC.TL_error error) {
boolean isSentError = false;
if (error == null) {
final int oldId = newMsgObj.id;
final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast;
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
final String attachPath = newMsgObj.attachPath;
if (response instanceof TLRPC.TL_updateShortSentMessage) {
TLRPC.TL_updateShortSentMessage res = (TLRPC.TL_updateShortSentMessage) response;
newMsgObj.local_id = newMsgObj.id = res.id;
newMsgObj.date = res.date;
newMsgObj.entities = res.entities;
newMsgObj.out = res.out;
newMsgObj.unread = res.unread;
if (res.media != null) {
newMsgObj.media = res.media;
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA;
}
if (!newMsgObj.entities.isEmpty()) {
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_ENTITIES;
}
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count);
sentMessages.add(newMsgObj);
} else if (response instanceof TLRPC.Updates) {
boolean ok = false;
for (TLRPC.Update update : ((TLRPC.Updates) response).updates) {
if (update instanceof TLRPC.TL_updateNewMessage) {
TLRPC.TL_updateNewMessage newMessage = (TLRPC.TL_updateNewMessage) update;
sentMessages.add(newMessage.message);
newMsgObj.id = newMessage.message.id;
processSentMessage(newMsgObj, newMessage.message, originalPath);
MessagesController.getInstance().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count);
ok = true;
break;
} else if (update instanceof TLRPC.TL_updateNewChannelMessage) {
TLRPC.TL_updateNewChannelMessage newMessage = (TLRPC.TL_updateNewChannelMessage) update;
sentMessages.add(newMessage.message);
newMsgObj.id = newMessage.message.id;
if ((newMsgObj.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) {
newMessage.message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP;
public void run(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
boolean isSentError = false;
if (error == null) {
final int oldId = newMsgObj.id;
final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast;
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
final String attachPath = newMsgObj.attachPath;
if (response instanceof TLRPC.TL_updateShortSentMessage) {
final TLRPC.TL_updateShortSentMessage res = (TLRPC.TL_updateShortSentMessage) response;
newMsgObj.local_id = newMsgObj.id = res.id;
newMsgObj.date = res.date;
newMsgObj.entities = res.entities;
newMsgObj.out = res.out;
newMsgObj.unread = res.unread;
if (res.media != null) {
newMsgObj.media = res.media;
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA;
}
processSentMessage(newMsgObj, newMessage.message, originalPath);
MessagesController.getInstance().processNewChannelDifferenceParams(newMessage.pts, newMessage.pts_count, newMessage.message.to_id.channel_id);
ok = true;
break;
}
}
if (!ok) {
isSentError = true;
}
}
if (!isSentError) {
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false, newMsgObj.to_id.channel_id);
MessagesStorage.getInstance().putMessages(sentMessages, true, false, isBroadcast, 0);
if (isBroadcast) {
ArrayList<TLRPC.Message> currentMessage = new ArrayList<>();
currentMessage.add(newMsgObj);
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0);
if (!newMsgObj.entities.isEmpty()) {
newMsgObj.flags |= TLRPC.MESSAGE_FLAG_HAS_ENTITIES;
}
AndroidUtilities.runOnUIThread(new Runnable() {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
if (isBroadcast) {
for (TLRPC.Message message : sentMessages) {
ArrayList<MessageObject> arr = new ArrayList<>();
MessageObject messageObject = new MessageObject(message, null, false);
arr.add(messageObject);
MessagesController.getInstance().updateInterfaceWithMessages(messageObject.getDialogId(), arr, true);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, newMsgObj.dialog_id);
processSentMessage(oldId);
removeFromSendingMessages(oldId);
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count);
}
});
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
stopVideoService(attachPath);
sentMessages.add(newMsgObj);
} else if (response instanceof TLRPC.Updates) {
ArrayList<TLRPC.Update> updates = ((TLRPC.Updates) response).updates;
TLRPC.Message message = null;
for (int a = 0; a < updates.size(); a++) {
TLRPC.Update update = updates.get(a);
if (update instanceof TLRPC.TL_updateNewMessage) {
final TLRPC.TL_updateNewMessage newMessage = (TLRPC.TL_updateNewMessage) update;
sentMessages.add(message = newMessage.message);
newMsgObj.id = newMessage.message.id;
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count);
}
});
break;
} else if (update instanceof TLRPC.TL_updateNewChannelMessage) {
final TLRPC.TL_updateNewChannelMessage newMessage = (TLRPC.TL_updateNewChannelMessage) update;
sentMessages.add(message = newMessage.message);
if ((newMsgObj.flags & TLRPC.MESSAGE_FLAG_MEGAGROUP) != 0) {
newMessage.message.flags |= TLRPC.MESSAGE_FLAG_MEGAGROUP;
}
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().processNewChannelDifferenceParams(newMessage.pts, newMessage.pts_count, newMessage.message.to_id.channel_id);
}
});
break;
}
}
if (message != null) {
newMsgObj.id = message.id;
processSentMessage(newMsgObj, message, originalPath, false);
} else {
isSentError = true;
}
}
});
}
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (!isSentError) {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false, newMsgObj.to_id.channel_id);
MessagesStorage.getInstance().putMessages(sentMessages, true, false, isBroadcast, 0);
if (isBroadcast) {
ArrayList<TLRPC.Message> currentMessage = new ArrayList<>();
currentMessage.add(newMsgObj);
MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (isBroadcast) {
for (int a = 0; a < sentMessages.size(); a++) {
TLRPC.Message message = sentMessages.get(a);
ArrayList<MessageObject> arr = new ArrayList<>();
MessageObject messageObject = new MessageObject(message, null, false);
arr.add(messageObject);
MessagesController.getInstance().updateInterfaceWithMessages(messageObject.getDialogId(), arr, true);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, newMsgObj.dialog_id);
processSentMessage(oldId);
removeFromSendingMessages(oldId);
}
});
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
stopVideoService(attachPath);
}
}
});
}
} else {
if (error.text.equals("PEER_FLOOD")) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.needShowAlert, 0);
}
isSentError = true;
}
});
isSentError = true;
}
if (isSentError) {
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (isSentError) {
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj);
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
processSentMessage(newMsgObj.id);
@ -1719,8 +1798,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
removeFromSendingMessages(newMsgObj.id);
}
});
}
}
});
}
}, new QuickAckDelegate() {
@Override
@ -1737,38 +1816,45 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}, ConnectionsManager.RequestFlagCanCompress | ConnectionsManager.RequestFlagInvokeAfter | (req instanceof TLRPC.TL_messages_sendMessage ? ConnectionsManager.RequestFlagNeedQuickAck : 0));
}
private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage, String originalPath) {
private void processSentMessage(TLRPC.Message newMsg, TLRPC.Message sentMessage, String originalPath, boolean post) {
if (sentMessage == null) {
return;
}
if (sentMessage.media instanceof TLRPC.TL_messageMediaPhoto && sentMessage.media.photo != null && newMsg.media instanceof TLRPC.TL_messageMediaPhoto && newMsg.media.photo != null) {
MessagesStorage.getInstance().putSentFile(originalPath, sentMessage.media.photo, 0);
for (TLRPC.PhotoSize size : sentMessage.media.photo.sizes) {
if (size == null || size.location == null || size instanceof TLRPC.TL_photoSizeEmpty || size.type == null) {
continue;
}
for (TLRPC.PhotoSize size2 : newMsg.media.photo.sizes) {
if (size2 == null || size2.location == null || size2.type == null) {
if (newMsg.media.photo.sizes.size() == 1 && newMsg.media.photo.sizes.get(0).location instanceof TLRPC.TL_fileLocationUnavailable) {
newMsg.media.photo.sizes = sentMessage.media.photo.sizes;
} else {
for (int a = 0; a < sentMessage.media.photo.sizes.size(); a++) {
TLRPC.PhotoSize size = sentMessage.media.photo.sizes.get(a);
if (size == null || size.location == null || size instanceof TLRPC.TL_photoSizeEmpty || size.type == null) {
continue;
}
if (size2.location.volume_id == Integer.MIN_VALUE && size.type.equals(size2.type) || size.w == size2.w && size.h == size2.h) {
String fileName = size2.location.volume_id + "_" + size2.location.local_id;
String fileName2 = size.location.volume_id + "_" + size.location.local_id;
if (fileName.equals(fileName2)) {
for (int b = 0; b < newMsg.media.photo.sizes.size(); b++) {
TLRPC.PhotoSize size2 = newMsg.media.photo.sizes.get(b);
if (size2 == null || size2.location == null || size2.type == null) {
continue;
}
if (size2.location.volume_id == Integer.MIN_VALUE && size.type.equals(size2.type) || size.w == size2.w && size.h == size2.h) {
String fileName = size2.location.volume_id + "_" + size2.location.local_id;
String fileName2 = size.location.volume_id + "_" + size.location.local_id;
if (fileName.equals(fileName2)) {
break;
}
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
File cacheFile2;
if (sentMessage.media.photo.sizes.size() == 1 || size.w > 90 || size.h > 90) {
cacheFile2 = FileLoader.getPathToAttach(size);
} else {
cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
}
cacheFile.renameTo(cacheFile2);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, post);
size2.location = size.location;
size2.size = size.size;
break;
}
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
File cacheFile2;
if (sentMessage.media.photo.sizes.size() == 1 || size.w > 90 || size.h > 90) {
cacheFile2 = FileLoader.getPathToAttach(size);
} else {
cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
}
cacheFile.renameTo(cacheFile2);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location);
size2.location = size.location;
break;
}
}
}
@ -1788,7 +1874,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
cacheFile.renameTo(cacheFile2);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, post);
size2.location = size.location;
}
}
@ -1819,8 +1905,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName + ".jpg");
File cacheFile2 = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName2 + ".jpg");
cacheFile.renameTo(cacheFile2);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location);
ImageLoader.getInstance().replaceImageInCache(fileName, fileName2, size.location, post);
size2.location = size.location;
size2.size = size.size;
}
} else if (MessageObject.isStickerMessage(sentMessage) && size2 != null && size2.location != null) {
size.location = size2.location;
@ -1830,6 +1917,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
newMsg.media.document.id = sentMessage.media.document.id;
newMsg.media.document.access_hash = sentMessage.media.document.access_hash;
newMsg.media.document.attributes = sentMessage.media.document.attributes;
newMsg.media.document.size = sentMessage.media.document.size;
newMsg.media.document.mime_type = sentMessage.media.document.mime_type;
if (MessageObject.isOut(sentMessage) && MessageObject.isNewGifDocument(sentMessage.media.document)) {
MessagesController.addNewGifToRecent(sentMessage.media.document, sentMessage.date);
}
if (newMsg.attachPath != null && newMsg.attachPath.startsWith(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE).getAbsolutePath())) {
File cacheFile = new File(newMsg.attachPath);
@ -1840,7 +1933,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else {
newMsg.attachPath = "";
if (originalPath != null && originalPath.startsWith("http")) {
MessagesStorage.getInstance().addRecentLocalFile(originalPath, cacheFile2.toString());
MessagesStorage.getInstance().addRecentLocalFile(originalPath, cacheFile2.toString(), newMsg.media.document);
}
}
} else {
@ -2075,13 +2168,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
final TLRPC.TL_document documentFinal = document;
final String originalPathFinal = originalPath;
final String pathFinal = path;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(documentFinal, pathFinal, dialog_id, reply_to_msg, asAdmin, params);
}
});
return true;
@ -2139,12 +2235,15 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
final String originalPathFinal = originalPath;
final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
final TLRPC.TL_document documentFinal = document;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, messageObject.messageOwner.attachPath, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(documentFinal, messageObject.messageOwner.attachPath, dialog_id, reply_to_msg, asAdmin, params);
}
});
}
@ -2210,6 +2309,109 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
prepareSendingPhotos(paths, uris, dialog_id, reply_to_msg, captions, asAdmin);
}
public static void prepareSendingBotContextResult(final TLRPC.BotInlineResult result, final HashMap<String, String> params, final long dialog_id, final MessageObject reply_to_msg, final boolean asAdmin) {
if (result == null) {
return;
}
if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaAuto) {
new Thread(new Runnable() {
@Override
public void run() {
String finalPath = null;
TLRPC.TL_document document = null;
TLRPC.TL_photo photo = null;
if (result instanceof TLRPC.TL_botInlineMediaResultDocument) {
if (result.document != null) {
if (result.document instanceof TLRPC.TL_document) {
document = (TLRPC.TL_document) result.document;
}
}
} else if (result instanceof TLRPC.TL_botInlineMediaResultPhoto) {
if (result.photo != null) {
if (result.photo instanceof TLRPC.TL_photo) {
photo = (TLRPC.TL_photo) result.photo;
}
}
} else {
if (result.content_url != null) {
finalPath = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.MD5(result.content_url) + "." + ImageLoader.getHttpUrlExtension(result.content_url)).getAbsolutePath();
if (result.type.equals("gif")){
document = new TLRPC.TL_document();
document.id = 0;
document.date = ConnectionsManager.getInstance().getCurrentTime();
TLRPC.TL_documentAttributeFilename fileName = new TLRPC.TL_documentAttributeFilename();
fileName.file_name = "animation.gif";
document.attributes.add(fileName);
document.size = 0;
document.dc_id = 0;
document.mime_type = "image/gif";
try {
Bitmap bitmap;
if (finalPath.endsWith("mp4")) {
bitmap = ThumbnailUtils.createVideoThumbnail(finalPath, MediaStore.Video.Thumbnails.MINI_KIND);
} else {
bitmap = ImageLoader.loadBitmap(finalPath, null, 90, 90, true);
}
if (bitmap != null) {
document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, false);
bitmap.recycle();
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (document.thumb == null) {
document.thumb = new TLRPC.TL_photoSize();
document.thumb.w = result.w;
document.thumb.h = result.h;
document.thumb.size = 0;
document.thumb.location = new TLRPC.TL_fileLocationUnavailable();
document.thumb.type = "x";
}
} else if (result.type.equals("photo")) {
File cacheFile = new File(finalPath);
if (cacheFile.exists()) {
photo = SendMessagesHelper.getInstance().generatePhotoSizes(cacheFile.toString(), null);
}
if (photo == null) {
photo = new TLRPC.TL_photo();
photo.date = ConnectionsManager.getInstance().getCurrentTime();
TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize();
photoSize.w = result.w;
photoSize.h = result.h;
photoSize.size = 1;
photoSize.location = new TLRPC.TL_fileLocationUnavailable();
photoSize.type = "x";
photo.sizes.add(photoSize);
}
}
}
}
final String finalPathFinal = finalPath;
final TLRPC.TL_document finalDocument = document;
final TLRPC.TL_photo finalPhoto = photo;
if (params != null && result.content_url != null) {
params.put("originalPath", result.content_url);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (finalDocument != null) {
finalDocument.caption = result.send_message.caption;
SendMessagesHelper.getInstance().sendMessage(finalDocument, finalPathFinal, dialog_id, reply_to_msg, asAdmin, params);
} else if (finalPhoto != null) {
finalPhoto.caption = result.send_message.caption;
SendMessagesHelper.getInstance().sendMessage(finalPhoto, result.content_url, dialog_id, reply_to_msg, asAdmin, params);
}
}
});
}
}).run();
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageText) {
SendMessagesHelper.getInstance().sendMessage(result.send_message.message, dialog_id, reply_to_msg, null, !result.send_message.no_webpage, asAdmin, result.send_message.entities, params);
}
}
public static void prepareSendingPhotosSearch(final ArrayList<MediaController.SearchImage> photos, final long dialog_id, final MessageObject reply_to_msg, final boolean asAdmin) {
if (photos == null || photos.isEmpty()) {
return;
@ -2221,14 +2423,27 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
for (int a = 0; a < photos.size(); a++) {
final MediaController.SearchImage searchImage = photos.get(a);
if (searchImage.type == 1) {
final HashMap<String, String> params = new HashMap<>();
TLRPC.TL_document document = null;
if (!isEncrypted) {
document = (TLRPC.TL_document) MessagesStorage.getInstance().getSentFile(searchImage.imageUrl, !isEncrypted ? 1 : 4);
File cacheFile;
if (searchImage.document instanceof TLRPC.TL_document) {
document = (TLRPC.TL_document) searchImage.document;
cacheFile = FileLoader.getPathToAttach(document, true);
} else {
if (!isEncrypted) {
TLRPC.Document doc = (TLRPC.Document) MessagesStorage.getInstance().getSentFile(searchImage.imageUrl, !isEncrypted ? 1 : 4);
if (doc instanceof TLRPC.TL_document) {
document = (TLRPC.TL_document) doc;
}
}
String md5 = Utilities.MD5(searchImage.imageUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.imageUrl);
cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5);
}
String md5 = Utilities.MD5(searchImage.imageUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.imageUrl);
File cacheFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), md5);
if (document == null) {
File thumbFile;
if (searchImage.localUrl != null) {
params.put("url", searchImage.localUrl);
}
File thumbFile = null;
document = new TLRPC.TL_document();
document.id = 0;
document.date = ConnectionsManager.getInstance().getCurrentTime();
@ -2242,7 +2457,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
thumbFile = cacheFile;
} else {
cacheFile = null;
String thumb = Utilities.MD5(searchImage.thumbUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.imageUrl);
}
if (thumbFile == null) {
String thumb = Utilities.MD5(searchImage.thumbUrl) + "." + ImageLoader.getHttpUrlExtension(searchImage.thumbUrl);
thumbFile = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), thumb);
if (!thumbFile.exists()) {
thumbFile = null;
@ -2250,7 +2467,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
if (thumbFile != null) {
try {
Bitmap bitmap = ImageLoader.loadBitmap(thumbFile.getAbsolutePath(), null, 90, 90, true);
Bitmap bitmap;
if (thumbFile.getAbsolutePath().endsWith("mp4")) {
bitmap = ThumbnailUtils.createVideoThumbnail(thumbFile.getAbsolutePath(), MediaStore.Video.Thumbnails.MINI_KIND);
} else {
bitmap = ImageLoader.loadBitmap(thumbFile.getAbsolutePath(), null, 90, 90, true);
}
if (bitmap != null) {
document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, isEncrypted);
bitmap.recycle();
@ -2258,7 +2480,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
}
if (document.thumb == null) {
document.thumb = new TLRPC.TL_photoSize();
document.thumb.w = searchImage.width;
document.thumb.h = searchImage.height;
@ -2268,13 +2491,19 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
}
if (searchImage.caption != null) {
document.caption = searchImage.caption.toString();
}
final TLRPC.TL_document documentFinal = document;
final String originalPathFinal = searchImage.imageUrl;
final String pathFinal = cacheFile == null ? searchImage.imageUrl : cacheFile.toString();
if (params != null && searchImage.imageUrl != null) {
params.put("originalPath", searchImage.imageUrl);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(documentFinal, pathFinal, dialog_id, reply_to_msg, asAdmin, params);
}
});
} else {
@ -2315,13 +2544,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (searchImage.caption != null) {
photo.caption = searchImage.caption.toString();
}
final String originalPathFinal = searchImage.imageUrl;
final TLRPC.TL_photo photoFinal = photo;
final boolean needDownloadHttpFinal = needDownloadHttp;
final HashMap<String, String> params = new HashMap<>();
if (searchImage.imageUrl != null) {
params.put("originalPath", searchImage.imageUrl);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(photoFinal, needDownloadHttpFinal ? searchImage.imageUrl : null, dialog_id, reply_to_msg, asAdmin, params);
}
});
}
@ -2360,7 +2592,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
int count = (int) Math.ceil(textFinal.length() / 4096.0f);
for (int a = 0; a < count; a++) {
String mess = textFinal.substring(a * 4096, Math.min((a + 1) * 4096, textFinal.length()));
SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true, asAdmin);
SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true, asAdmin, null, null);
}
}
}
@ -2458,12 +2690,15 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (captions != null) {
photo.caption = captions.get(a);
}
final String originalPathFinal = originalPath;
final TLRPC.TL_photo photoFinal = photo;
final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(photoFinal, originalPathFinal, null, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(photoFinal, null, dialog_id, reply_to_msg, asAdmin, params);
}
});
}
@ -2586,10 +2821,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
final TLRPC.TL_video videoFinal = video;
final String originalPathFinal = originalPath;
final String finalPath = path;
final HashMap<String, String> params = new HashMap<>();
if (originalPath != null) {
params.put("originalPath", originalPath);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
SendMessagesHelper.getInstance().sendMessage(videoFinal, videoEditedInfo, originalPathFinal, finalPath, dialog_id, reply_to_msg, asAdmin);
SendMessagesHelper.getInstance().sendMessage(videoFinal, videoEditedInfo, finalPath, dialog_id, reply_to_msg, asAdmin, params);
}
});
} else {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -68,7 +68,7 @@ public class UserConfig {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("registeredForPush", registeredForPush);
editor.putString("pushString", pushString);
editor.putString("pushString2", pushString);
editor.putInt("lastSendMessageId", lastSendMessageId);
editor.putInt("lastLocalId", lastLocalId);
editor.putString("contactsHash", contactsHash);
@ -182,7 +182,7 @@ public class UserConfig {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
registeredForPush = preferences.getBoolean("registeredForPush", false);
pushString = preferences.getString("pushString", "");
pushString = preferences.getString("pushString2", "");
lastSendMessageId = preferences.getInt("lastSendMessageId", -210000);
lastLocalId = preferences.getInt("lastLocalId", -210000);
contactsHash = preferences.getString("contactsHash", "");
@ -209,7 +209,7 @@ public class UserConfig {
} else {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
registeredForPush = preferences.getBoolean("registeredForPush", false);
pushString = preferences.getString("pushString", "");
pushString = preferences.getString("pushString2", "");
lastSendMessageId = preferences.getInt("lastSendMessageId", -210000);
lastLocalId = preferences.getInt("lastLocalId", -210000);
contactsHash = preferences.getString("contactsHash", "");

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -47,7 +47,8 @@ public class Utilities {
public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride);
public native static int pinBitmap(Bitmap bitmap);
public native static void blurBitmap(Object bitmap, int radius, int unpin);
public native static int unpinBitmap(Bitmap bitmap);
public native static void blurBitmap(Object bitmap, int radius, int unpin, int width, int height, int stride);
public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer);
public native static boolean loadWebpImage(Bitmap bitmap, ByteBuffer buffer, int len, BitmapFactory.Options options, boolean unpin);
public native static int convertVideoFrame(ByteBuffer src, ByteBuffer dest, int destFormat, int width, int height, int padding, int swap);
@ -74,6 +75,23 @@ public class Utilities {
return val;
}
public static Long parseLong(String value) {
if (value == null) {
return 0L;
}
Long val = 0L;
try {
Matcher matcher = pattern.matcher(value);
if (matcher.find()) {
String num = matcher.group(0);
val = Long.parseLong(num);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return val;
}
public static String parseIntToString(String value) {
Matcher matcher = pattern.matcher(value);
if (matcher.find()) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger;
@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
if (dialog_id == 0 || max_id == 0) {
return;
}
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false);
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true, false, null, null);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
}

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.query;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.query;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.query;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.query;
@ -172,7 +172,7 @@ public class SharedMediaQuery {
return false;
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaVideo ||
message.media instanceof TLRPC.TL_messageMediaDocument ||
message.media instanceof TLRPC.TL_messageMediaDocument && !MessageObject.isGifDocument(message.media.document) ||
message.media instanceof TLRPC.TL_messageMediaAudio) {
return true;
} else if (!message.entities.isEmpty()) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.query;
@ -62,7 +62,7 @@ public class StickersQuery {
}
public static void checkStickers() {
if (!loadingStickers && (!stickersLoaded || loadDate < (System.currentTimeMillis() / 1000 - 60 * 60))) {
if (!loadingStickers && (!stickersLoaded || Math.abs(System.currentTimeMillis() / 1000 - loadDate) >= 60 * 60)) {
loadStickers(true, false);
}
}
@ -332,7 +332,7 @@ public class StickersQuery {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public void run() {
if (cache && (res == null || date < (int) (System.currentTimeMillis() / 1000 - 60 * 60)) || !cache && res == null && hash == 0) {
if (cache && (res == null || Math.abs(System.currentTimeMillis() / 1000 - date) >= 60 * 60) || !cache && res == null && hash == 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {

View file

@ -24,8 +24,6 @@ import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewGroup;
import org.telegram.messenger.support.widget.RecyclerView;
import java.util.Arrays;
/**

View file

@ -4184,7 +4184,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView, NestedScro
private SparseIntArray mMaxScrap = new SparseIntArray();
private int mAttachCount = 0;
private static final int DEFAULT_MAX_SCRAP = 5;
private static final int DEFAULT_MAX_SCRAP = 10;
public void clear() {
mScrap.clear();

View file

@ -27,7 +27,7 @@ import android.view.Surface;
@TargetApi(17)
public class InputSurface {
private static final boolean VERBOSE = false;
private static final int EGL_RECORDABLE_ANDROID = 0x3142;
private static final int EGL_OPENGL_ES2_BIT = 4;
private EGLDisplay mEGLDisplay;
@ -124,8 +124,7 @@ public class InputSurface {
private void checkEglError(String msg) {
boolean failed = false;
int error;
while ((error = EGL14.eglGetError()) != EGL14.EGL_SUCCESS) {
while (EGL14.eglGetError() != EGL14.EGL_SUCCESS) {
failed = true;
}
if (failed) {

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.video;
@ -378,7 +378,7 @@ public class MP4Builder {
SampleToChunkBox stsc = new SampleToChunkBox();
stsc.setEntries(new LinkedList<SampleToChunkBox.Entry>());
long lastOffset = -1;
long lastOffset;
int lastChunkNumber = 1;
int lastSampleCount = 0;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.video;
@ -20,7 +20,7 @@ import java.util.ArrayList;
@TargetApi(16)
public class Mp4Movie {
private Matrix matrix = Matrix.ROTATE_0;
private ArrayList<Track> tracks = new ArrayList<Track>();
private ArrayList<Track> tracks = new ArrayList<>();
private File cacheFile;
private int width;
private int height;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.video;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.messenger.video;
@ -35,7 +35,7 @@ import java.util.Map;
@TargetApi(16)
public class Track {
private long trackId = 0;
private ArrayList<Sample> samples = new ArrayList<Sample>();
private ArrayList<Sample> samples = new ArrayList<>();
private long duration = 0;
private String handler;
private AbstractMediaHeaderBox headerBox = null;
@ -46,9 +46,9 @@ public class Track {
private int height;
private int width;
private float volume = 0;
private ArrayList<Long> sampleDurations = new ArrayList<Long>();
private ArrayList<Long> sampleDurations = new ArrayList<>();
private boolean isAudio = false;
private static Map<Integer, Integer> samplingFrequencyIndexMap = new HashMap<Integer, Integer>();
private static Map<Integer, Integer> samplingFrequencyIndexMap = new HashMap<>();
private long lastPresentationTimeUs = 0;
private boolean first = true;
@ -70,12 +70,12 @@ public class Track {
public Track(int id, MediaFormat format, boolean isAudio) throws Exception {
trackId = id;
if (!isAudio) {
sampleDurations.add((long)3015);
sampleDurations.add((long) 3015);
duration = 3015;
width = format.getInteger(MediaFormat.KEY_WIDTH);
height = format.getInteger(MediaFormat.KEY_HEIGHT);
timeScale = 90000;
syncSamples = new LinkedList<Integer>();
syncSamples = new LinkedList<>();
handler = "vide";
headerBox = new VideoMediaHeaderBox();
sampleDescriptionBox = new SampleDescriptionBox();
@ -93,14 +93,14 @@ public class Track {
AvcConfigurationBox avcConfigurationBox = new AvcConfigurationBox();
if (format.getByteBuffer("csd-0") != null) {
ArrayList<byte[]> spsArray = new ArrayList<byte[]>();
ArrayList<byte[]> spsArray = new ArrayList<>();
ByteBuffer spsBuff = format.getByteBuffer("csd-0");
spsBuff.position(4);
byte[] spsBytes = new byte[spsBuff.remaining()];
spsBuff.get(spsBytes);
spsArray.add(spsBytes);
ArrayList<byte[]> ppsArray = new ArrayList<byte[]>();
ArrayList<byte[]> ppsArray = new ArrayList<>();
ByteBuffer ppsBuff = format.getByteBuffer("csd-1");
ppsBuff.position(4);
byte[] ppsBytes = new byte[ppsBuff.remaining()];
@ -134,7 +134,7 @@ public class Track {
sampleDescriptionBox.addBox(visualSampleEntry);
}
} else {
sampleDurations.add((long)1024);
sampleDurations.add((long) 1024);
duration = 1024;
isAudio = true;
volume = 1;
@ -165,7 +165,7 @@ public class Track {
AudioSpecificConfig audioSpecificConfig = new AudioSpecificConfig();
audioSpecificConfig.setAudioObjectType(2);
audioSpecificConfig.setSamplingFrequencyIndex(samplingFrequencyIndexMap.get((int)audioSampleEntry.getSampleRate()));
audioSpecificConfig.setSamplingFrequencyIndex(samplingFrequencyIndexMap.get((int) audioSampleEntry.getSampleRate()));
audioSpecificConfig.setChannelConfiguration(audioSampleEntry.getChannelCount());
decoderConfigDescriptor.setAudioSpecificInfo(audioSpecificConfig);

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.tgnet;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.tgnet;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.tgnet;

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;
@ -431,7 +431,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH || event != null && (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
if (/*actionId == EditorInfo.IME_ACTION_SEARCH || */event != null && (event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
AndroidUtilities.hideKeyboard(searchField);
if (listener != null) {
listener.onSearchPressed(searchField);

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.ActionBar;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

View file

@ -3,7 +3,7 @@
* 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.
* Copyright Nikolai Kudashov, 2013-2016.
*/
package org.telegram.ui.Adapters;

Some files were not shown because too many files have changed in this diff Show more