Commit 2b81b7f0 authored by DrKLO's avatar DrKLO

update to 2.9.1

parent 2b8304eb
......@@ -3,7 +3,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'com.android.application'
......@@ -81,7 +81,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 521
versionName "2.8.1"
versionCode 541
versionName "2.9.1"
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -123,6 +123,18 @@
android:windowSoftInputMode="adjustResize|stateHidden">
</activity>
<receiver android:name="org.telegram.android.AutoMessageHeardReceiver">
<intent-filter>
<action android:name="org.telegram.messenger.ACTION_MESSAGE_HEARD"/>
</intent-filter>
</receiver>
<receiver android:name="org.telegram.android.AutoMessageReplyReceiver">
<intent-filter>
<action android:name="org.telegram.messenger.ACTION_MESSAGE_REPLY"/>
</intent-filter>
</receiver>
<receiver android:name="org.telegram.android.SmsListener">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
......@@ -168,6 +180,8 @@
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W" android:value="632dp" />
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H" android:value="598dp" />
<meta-data android:name="com.google.android.gms.car.application" android:resource="@xml/automotive_app_desc" />
</application>
</manifest>
......@@ -27,11 +27,11 @@ package org.telegram.PhoneFormat;
import java.util.ArrayList;
public class CallingCodeInfo {
public ArrayList<String> countries = new ArrayList<String>();
public ArrayList<String> countries = new ArrayList<>();
public String callingCode = "";
public ArrayList<String> trunkPrefixes = new ArrayList<String>();
public ArrayList<String> intlPrefixes = new ArrayList<String>();
public ArrayList<RuleSet> ruleSets = new ArrayList<RuleSet>();
public ArrayList<String> trunkPrefixes = new ArrayList<>();
public ArrayList<String> intlPrefixes = new ArrayList<>();
public ArrayList<RuleSet> ruleSets = new ArrayList<>();
//public ArrayList formatStrings;
String matchingAccessCode(String str) {
......@@ -107,14 +107,14 @@ public class CallingCodeInfo {
for (RuleSet set : ruleSets) {
boolean valid = set.isValid(str, intlPrefix, trunkPrefix, true);
if (valid) {
return valid;
return true;
}
}
for (RuleSet set : ruleSets) {
boolean valid = set.isValid(str, intlPrefix, trunkPrefix, false);
if (valid) {
return valid;
return true;
}
}
......
/*
* This is the source code of Telegram for Android v. 2.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.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class AutoMessageHeardReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
long dialog_id = intent.getLongExtra("dialog_id", 0);
int max_id = intent.getIntExtra("max_id", 0);
if (dialog_id == 0 || max_id == 0) {
return;
}
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
}
}
/*
* This is the source code of Telegram for Android v. 2.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-2014.
*/
package org.telegram.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.RemoteInput;
public class AutoMessageReplyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput == null) {
return;
}
CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY);
if (text == null || text.length() == 0) {
return;
}
long dialog_id = intent.getLongExtra("dialog_id", 0);
int max_id = intent.getIntExtra("max_id", 0);
if (dialog_id == 0 || max_id == 0) {
return;
}
SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
}
}
......@@ -221,7 +221,7 @@ public class Emoji {
private static void loadEmoji(final int page) {
try {
float scale = 1.0f;
float scale;
int imageResize = 1;
if (AndroidUtilities.density <= 1.0f) {
scale = 2.0f;
......@@ -257,7 +257,7 @@ public class Emoji {
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (!imageFile.exists()) {
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
Utilities.copyFile(is, imageFile);
AndroidUtilities.copyFile(is, imageFile);
is.close();
}
......@@ -276,7 +276,7 @@ public class Emoji {
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (!imageFile.exists()) {
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
Utilities.copyFile(is, imageFile);
AndroidUtilities.copyFile(is, imageFile);
is.close();
}
......
......@@ -23,7 +23,6 @@ import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser;
......@@ -359,7 +358,7 @@ public class LocaleController {
}
File finalFile = new File(ApplicationLoader.applicationContext.getFilesDir(), languageCode + ".xml");
if (!Utilities.copyFile(file, finalFile)) {
if (!AndroidUtilities.copyFile(file, finalFile)) {
return false;
}
......@@ -494,7 +493,6 @@ public class LocaleController {
try {
if (stream != null) {
stream.close();
stream = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
......@@ -512,7 +510,7 @@ public class LocaleController {
return;
}
try {
Locale newLocale = null;
Locale newLocale;
if (localeInfo.shortName != null) {
String[] args = localeInfo.shortName.split("_");
if (args.length == 1) {
......@@ -682,50 +680,60 @@ public class LocaleController {
}
public static String formatDate(long date) {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
return formatterDay.format(new Date(date * 1000));
} else if (dateDay + 1 == day && year == dateYear) {
return getString("Yesterday", R.string.Yesterday);
} else if (year == dateYear) {
return formatterMonth.format(new Date(date * 1000));
} else {
return formatterYear.format(new Date(date * 1000));
try {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
return formatterDay.format(new Date(date * 1000));
} else if (dateDay + 1 == day && year == dateYear) {
return getString("Yesterday", R.string.Yesterday);
} else if (year == dateYear) {
return formatterMonth.format(new Date(date * 1000));
} else {
return formatterYear.format(new Date(date * 1000));
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return "LOC_ERR";
}
public static String formatDateOnline(long date) {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
return String.format("%s %s %s", LocaleController.getString("LastSeen", R.string.LastSeen), LocaleController.getString("TodayAt", R.string.TodayAt), formatterDay.format(new Date(date * 1000)));
} else if (dateDay + 1 == day && year == dateYear) {
return String.format("%s %s %s", LocaleController.getString("LastSeen", R.string.LastSeen), LocaleController.getString("YesterdayAt", R.string.YesterdayAt), formatterDay.format(new Date(date * 1000)));
} else if (year == dateYear) {
String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, formatterMonth.format(new Date(date * 1000)), formatterDay.format(new Date(date * 1000)));
return String.format("%s %s", LocaleController.getString("LastSeenDate", R.string.LastSeenDate), format);
} else {
String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, formatterYear.format(new Date(date * 1000)), formatterDay.format(new Date(date * 1000)));
return String.format("%s %s", LocaleController.getString("LastSeenDate", R.string.LastSeenDate), format);
try {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
return String.format("%s %s %s", LocaleController.getString("LastSeen", R.string.LastSeen), LocaleController.getString("TodayAt", R.string.TodayAt), formatterDay.format(new Date(date * 1000)));
} else if (dateDay + 1 == day && year == dateYear) {
return String.format("%s %s %s", LocaleController.getString("LastSeen", R.string.LastSeen), LocaleController.getString("YesterdayAt", R.string.YesterdayAt), formatterDay.format(new Date(date * 1000)));
} else if (year == dateYear) {
String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, formatterMonth.format(new Date(date * 1000)), formatterDay.format(new Date(date * 1000)));
return String.format("%s %s", LocaleController.getString("LastSeenDate", R.string.LastSeenDate), format);
} else {
String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, formatterYear.format(new Date(date * 1000)), formatterDay.format(new Date(date * 1000)));
return String.format("%s %s", LocaleController.getString("LastSeenDate", R.string.LastSeenDate), format);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return "LOC_ERR";
}
private FastDateFormat createFormatter(Locale locale, String format, String defaultFormat) {
if (format == null || format.length() == 0) {
format = defaultFormat;
}
FastDateFormat formatter = null;
FastDateFormat formatter;
try {
formatter = FastDateFormat.getInstance(format, locale);
} catch (Exception e) {
......@@ -758,25 +766,30 @@ public class LocaleController {
}
public static String stringForMessageListDate(long date) {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (year != dateYear) {
return formatterYear.format(new Date(date * 1000));
} else {
int dayDiff = dateDay - day;
if(dayDiff == 0 || dayDiff == -1 && (int)(System.currentTimeMillis() / 1000) - date < 60 * 60 * 8) {
return formatterDay.format(new Date(date * 1000));
} else if(dayDiff > -7 && dayDiff <= -1) {
return formatterWeek.format(new Date(date * 1000));
try {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
int year = rightNow.get(Calendar.YEAR);
rightNow.setTimeInMillis(date * 1000);
int dateDay = rightNow.get(Calendar.DAY_OF_YEAR);
int dateYear = rightNow.get(Calendar.YEAR);
if (year != dateYear) {
return formatterYear.format(new Date(date * 1000));
} else {
return formatterMonth.format(new Date(date * 1000));
int dayDiff = dateDay - day;
if(dayDiff == 0 || dayDiff == -1 && (int)(System.currentTimeMillis() / 1000) - date < 60 * 60 * 8) {
return formatterDay.format(new Date(date * 1000));
} else if(dayDiff > -7 && dayDiff <= -1) {
return formatterWeek.format(new Date(date * 1000));
} else {
return formatterMonth.format(new Date(date * 1000));
}
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
return "LOC_ERR";
}
public static String formatUserStatus(TLRPC.User user) {
......
......@@ -107,7 +107,6 @@ public class LruCache {
if (previous != null) {
entryRemoved(false, key, previous, value);
ImageLoader.getInstance().callGC();
}
trimToSize(maxSize, key);
......@@ -148,7 +147,6 @@ public class LruCache {
entryRemoved(true, key, value, null);
}
ImageLoader.getInstance().callGC();
}
}
......@@ -183,7 +181,6 @@ public class LruCache {
}
entryRemoved(false, key, previous, null);
ImageLoader.getInstance().callGC();
}
return previous;
......
......@@ -25,6 +25,7 @@ import org.telegram.messenger.TLRPC;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.URLSpanNoUnderline;
import org.telegram.ui.Components.URLSpanNoUnderlineBold;
import java.util.AbstractMap;
import java.util.ArrayList;
......@@ -48,10 +49,11 @@ public class MessageObject {
public int contentType;
public String dateKey;
public String monthKey;
public boolean deleted = false;
public boolean deleted;
public float audioProgress;
public int audioProgressSec;
public ArrayList<TLRPC.PhotoSize> photoThumbs;
public VideoEditedInfo videoEditedInfo;
public static TextPaint textPaint;
public int lastLineWidth;
......@@ -147,7 +149,7 @@ public class MessageObject {
if (whoUser != null && fromUser != null) {
if (whoUser.id == fromUser.id) {
if (isOut()) {
messageText = LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf).replace("un1", LocaleController.getString("FromYou", R.string.FromYou));
messageText = LocaleController.getString("ActionAddUserSelfYou", R.string.ActionAddUserSelfYou);
} else {
messageText = replaceWithLink(LocaleController.getString("ActionAddUserSelf", R.string.ActionAddUserSelf), "un1", fromUser);
}
......@@ -331,6 +333,9 @@ public class MessageObject {
if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) {
if (isMediaEmpty()) {
contentType = type = 0;
if (messageText.length() == 0) {
messageText = "Empty message";
}
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
contentType = type = 1;
} else if (message.media instanceof TLRPC.TL_messageMediaGeo || message.media instanceof TLRPC.TL_messageMediaVenue) {
......@@ -351,9 +356,6 @@ public class MessageObject {
type = 8;
} else if (message.media.document.mime_type.equals("image/webp") && isSticker()) {
type = 13;
if (messageOwner.media.document.thumb != null && messageOwner.media.document.thumb.location != null) {
messageOwner.media.document.thumb.location.ext = "webp";
}
} else {
type = 9;
}
......@@ -393,6 +395,11 @@ public class MessageObject {
monthKey = String.format("%d_%02d", dateYear, dateMonth);
}
if (messageOwner.message != null && messageOwner.id < 0 && messageOwner.message.length() > 6 && messageOwner.media instanceof TLRPC.TL_messageMediaVideo) {
videoEditedInfo = new VideoEditedInfo();
videoEditedInfo.parseString(messageOwner.message);
}
generateCaption();
if (generateLayout) {
generateLayout();
......@@ -458,7 +465,7 @@ public class MessageObject {
if (messageOwner.media.webpage.photo != null) {
if (!update || photoThumbs == null) {
photoThumbs = new ArrayList<>(messageOwner.media.webpage.photo.sizes);
} else if (photoThumbs != null && !photoThumbs.isEmpty()) {
} else if (!photoThumbs.isEmpty()) {
for (TLRPC.PhotoSize photoObject : photoThumbs) {
for (TLRPC.PhotoSize size : messageOwner.media.webpage.photo.sizes) {
if (size instanceof TLRPC.TL_photoSizeEmpty) {
......@@ -479,7 +486,7 @@ public class MessageObject {
public CharSequence replaceWithLink(CharSequence source, String param, TLRPC.User user) {
String name = ContactsController.formatName(user.first_name, user.last_name);
int start = TextUtils.indexOf(source, param);
URLSpanNoUnderline span = new URLSpanNoUnderline("" + user.id);
URLSpanNoUnderlineBold span = new URLSpanNoUnderlineBold("" + user.id);
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name}));
builder.setSpan(span, start, start + name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return builder;
......@@ -664,7 +671,7 @@ public class MessageObject {
}
}
StaticLayout textLayout = null;
StaticLayout textLayout;
try {
textLayout = new StaticLayout(messageText, textPaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
......@@ -783,7 +790,6 @@ public class MessageObject {
if (a == blocksCount - 1) {
lastLineWidth = lastLineWidthWithLeft;
}
linesMaxWidth = linesMaxWidthWithLeft;
} else if (a == blocksCount - 1) {
lastLineWidth = linesMaxWidth;
}
......@@ -939,6 +945,20 @@ public class MessageObject {
return false;
}
public static TLRPC.InputStickerSet getInputStickerSet(TLRPC.Message message) {
if (message.media != null && message.media.document != null) {
for (TLRPC.DocumentAttribute attribute : message.media.document.attributes) {
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
if (attribute.stickerset instanceof TLRPC.TL_inputStickerSetEmpty) {
return null;
}
return attribute.stickerset;
}
}
}
return null;
}
public String getStrickerChar() {
if (messageOwner.media != null && messageOwner.media.document != null) {
for (TLRPC.DocumentAttribute attribute : messageOwner.media.document.attributes) {
......@@ -991,8 +1011,8 @@ public class MessageObject {
}
return photoHeight + AndroidUtilities.dp(14);
} else {
int photoHeight = 0;
int photoWidth = 0;
int photoHeight;
int photoWidth;
if (AndroidUtilities.isTablet()) {
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
......@@ -1010,35 +1030,22 @@ public class MessageObject {
if (currentPhotoObject != null) {
float scale = (float) currentPhotoObject.w / (float) photoWidth;
int w = (int) (currentPhotoObject.w / scale);
int h = (int) (currentPhotoObject.h / scale);
if (w == 0) {
w = AndroidUtilities.dp(100);
}
if (h == 0) {
h = AndroidUtilities.dp(100);
}
if (h > photoHeight) {
float scale2 = h;
h = photoHeight;
scale2 /= h;
w = (int) (w / scale2);
} else if (h < AndroidUtilities.dp(120)) {
h = AndroidUtilities.dp(120);
float hScale = (float) currentPhotoObject.h / h;
if (currentPhotoObject.w / hScale < photoWidth) {
w = (int) (currentPhotoObject.w / hScale);
}
}
if (isSecretPhoto()) {
if (AndroidUtilities.isTablet()) {
w = h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
} else {
w = h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
}
}
photoWidth = w;
photoHeight = h;
}
return photoHeight + AndroidUtilities.dp(14);
......@@ -1049,6 +1056,10 @@ public class MessageObject {
return isStickerMessage(messageOwner);
}
public TLRPC.InputStickerSet getInputStickerSet() {
return getInputStickerSet(messageOwner);
}
public boolean isForwarded() {
return (messageOwner.flags & TLRPC.MESSAGE_FLAG_FWD) != 0;
}
......
......@@ -8,6 +8,10 @@
package org.telegram.android;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -51,7 +55,6 @@ public class NotificationCenter {
public static final int didSetPasscode = totalEvents++;
public static final int didSetTwoStepPassword = totalEvents++;
public static final int screenStateChanged = totalEvents++;
public static final int appSwitchedToForeground = totalEvents++;
public static final int didLoadedReplyMessages = totalEvents++;
public static final int newSessionReceived = totalEvents++;
public static final int didReceivedWebpages = totalEvents++;
......@@ -94,14 +97,31 @@ public class NotificationCenter {
public static final int audioDidStarted = totalEvents++;
public static final int audioRouteChanged = totalEvents++;
final private HashMap<Integer, ArrayList<Object>> observers = new HashMap<>();
final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<>();
final private HashMap<Integer, Object> addAfterBroadcast = new HashMap<>();
private HashMap<Integer, ArrayList<Object>> observers = new HashMap<>();
private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<>();
private HashMap<Integer, Object> addAfterBroadcast = new HashMap<>();
private ArrayList<DelayedPost> delayedPosts = new ArrayList<>(10);
private int broadcasting = 0;
private boolean animationInProgress;
public interface NotificationCenterDelegate {
void didReceivedNotification(int id, Object... args);
}
private class DelayedPost {
private DelayedPost(int id, Object[] args) {
this.id = id;
this.args = args;
}
private int id;
private Object[] args;
}
private static volatile NotificationCenter Instance = null;
public static NotificationCenter getInstance() {
NotificationCenter localInstance = Instance;
if (localInstance == null) {
......@@ -115,66 +135,97 @@ public class NotificationCenter {
return localInstance;
}
public interface NotificationCenterDelegate {
void didReceivedNotification(int id, Object... args);
public void setAnimationInProgress(boolean value) {
animationInProgress = value;
if (!animationInProgress && !delayedPosts.isEmpty()) {
for (DelayedPost delayedPost : delayedPosts) {
postNotificationNameInternal(delayedPost.id, true, delayedPost.args);
}
delayedPosts.clear();
}
}
public void postNotificationName(int id, Object... args) {
synchronized (observers) {
broadcasting++;
ArrayList<Object> objects = observers.get(id);
if (objects != null) {
for (Object obj : objects) {
((NotificationCenterDelegate)obj).didReceivedNotification(id, args);
}
boolean allowDuringAnimation = false;
if (id == dialogsNeedReload || id == closeChats || id == messagesDidLoaded || id == mediaCountDidLoaded || id == mediaDidLoaded) {
allowDuringAnimation = true;
}
postNotificationNameInternal(id, allowDuringAnimation, args);
}
public void postNotificationNameInternal(int id, boolean allowDuringAnimation, Object... args) {
if (BuildVars.DEBUG_VERSION) {
if (Thread.currentThread() != ApplicationLoader.applicationHandler.getLooper().getThread()) {
throw new RuntimeException("postNotificationName allowed only from MAIN thread");
}
}
if (!allowDuringAnimation && animationInProgress) {
DelayedPost delayedPost = new DelayedPost(id, args);
delayedPosts.add(delayedPost);
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "delay post notification " + id + " with args count = " + args.length);
}
broadcasting--;
if (broadcasting == 0) {
if (!removeAfterBroadcast.isEmpty()) {
for (HashMap.Entry<Integer, Object> entry : removeAfterBroadcast.entrySet()) {
removeObserver(entry.getValue(), entry.getKey());
}
removeAfterBroadcast.clear();
return;
}
broadcasting++;
ArrayList<Object> objects = observers.get(id);
if (objects != null) {
for (Object obj : objects) {
((NotificationCenterDelegate) obj).didReceivedNotification(id, args);
}
}
broadcasting--;
if (broadcasting == 0) {
if (!removeAfterBroadcast.isEmpty()) {
for (HashMap.Entry<Integer, Object> entry : removeAfterBroadcast.entrySet()) {
removeObserver(entry.getValue(), entry.getKey());
}
if (!addAfterBroadcast.isEmpty()) {
for (HashMap.Entry<Integer, Object> entry : addAfterBroadcast.entrySet()) {
addObserver(entry.getValue(), entry.getKey());
}
addAfterBroadcast.clear();
removeAfterBroadcast.clear();
}
if (!addAfterBroadcast.isEmpty()) {
for (HashMap.Entry<Integer, Object> entry : addAfterBroadcast.entrySet()) {
addObserver(entry.getValue(), entry.getKey());
}
addAfterBroadcast.clear();
}
}
}
public void addObserver(Object observer, int id) {
synchronized (observers) {
if (broadcasting != 0) {
addAfterBroadcast.put(id, observer);
return;
if (BuildVars.DEBUG_VERSION) {
if (Thread.currentThread() != ApplicationLoader.applicationHandler.getLooper().getThread()) {
throw new RuntimeException("addObserver allowed only from MAIN thread");
}
ArrayList<Object> objects = observers.get(id);
if (objects == null) {
observers.put(id, (objects = new ArrayList<>()));
}
if (objects.contains(observer)) {
return;
}
objects.add(observer);
}
if (broadcasting != 0) {
addAfterBroadcast.put(id, observer);
return;
}
ArrayList<Object> objects = observers.get(id);
if (objects == null) {
observers.put(id, (objects = new ArrayList<>()));
}
if (objects.contains(observer)) {
return;
}
objects.add(observer);
}
public void removeObserver(Object observer, int id) {
synchronized (observers) {
if (broadcasting != 0) {
removeAfterBroadcast.put(id, observer);
return;
if (BuildVars.DEBUG_VERSION) {
if (Thread.currentThread() != ApplicationLoader.applicationHandler.getLooper().getThread()) {
throw new RuntimeException("removeObserver allowed only from MAIN thread");
}
ArrayList<Object> objects = observers.get(id);
if (objects != null) {
objects.remove(observer);
if (objects.size() == 0) {
observers.remove(id);
}
}
if (broadcasting != 0) {
removeAfterBroadcast.put(id, observer);
return;
}
ArrayList<Object> objects = observers.get(id);
if (objects != null) {
objects.remove(observer);
if (objects.size() == 0) {
observers.remove(id);
}
}
}
......
......@@ -17,6 +17,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.ApplicationLoader;
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
......
......@@ -44,11 +44,16 @@ public class SmsListener extends BroadcastReceiver {
try {
Pattern pattern = Pattern.compile("[0-9]+");
Matcher matcher = pattern.matcher(wholeString);
final Matcher matcher = pattern.matcher(wholeString);
if (matcher.find()) {
String str = matcher.group(0);
if (str.length() >= 3) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, matcher.group(0));
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveSmsCode, matcher.group(0));
}
});
}
}
} catch (Throwable e) {
......
/*
* This is the source code of Telegram for Android v. 2.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-2014.
*/
package org.telegram.android;
import java.util.Locale;
public class VideoEditedInfo {
public long startTime;
public long endTime;
public int rotationValue;
public int originalWidth;
public int originalHeight;
public int resultWidth;
public int resultHeight;
public int bitrate;
public String originalPath;
public String getString() {
return String.format(Locale.US, "-1_%d_%d_%d_%d_%d_%d_%d_%d_%s", startTime, endTime, rotationValue, originalWidth, originalHeight, bitrate, resultWidth, resultHeight, originalPath);
}
public void parseString(String string) {
if (string.length() < 6) {
return;
}
String args[] = string.split("_");
if (args.length >= 10) {
startTime = Long.parseLong(args[1]);
endTime = Long.parseLong(args[2]);
rotationValue = Integer.parseInt(args[3]);
originalWidth = Integer.parseInt(args[4]);
originalHeight = Integer.parseInt(args[5]);
bitrate = Integer.parseInt(args[6]);
resultWidth = Integer.parseInt(args[7]);
resultHeight = Integer.parseInt(args[8]);
for (int a = 9; a < args.length; a++) {
if (originalPath == null) {
originalPath = args[a];
} else {
originalPath += "_" + args[a];
}
}
}
}
}
......@@ -58,6 +58,8 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.Interpolator;
import org.telegram.android.AndroidUtilities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......
/*
* This is the source code of Telegram for Android v. 1.3.x.
* This is the source code of Telegram for Android v. 2.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-2014.
* Copyright Nikolai Kudashov, 2013-2015.
*/
package org.telegram.messenger;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment