Commit dff666fc authored by DrKLO's avatar DrKLO

Update to 2.4.0

parent 2fcef37b
...@@ -82,7 +82,7 @@ android { ...@@ -82,7 +82,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 21 targetSdkVersion 21
versionCode 416 versionCode 423
versionName "2.3.3" versionName "2.4.0"
} }
} }
This diff is collapsed.
This diff is collapsed.
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
<service android:name="org.telegram.android.NotificationsService" android:enabled="true"/> <service android:name="org.telegram.android.NotificationsService" android:enabled="true"/>
<service android:name="org.telegram.android.NotificationRepeat" android:exported="false"/> <service android:name="org.telegram.android.NotificationRepeat" android:exported="false"/>
<service android:name="org.telegram.android.NotificationDelay" android:exported="false"/>
<service android:name="org.telegram.android.VideoEncodingService" android:enabled="true"/> <service android:name="org.telegram.android.VideoEncodingService" android:enabled="true"/>
<receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true"> <receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true">
......
...@@ -14,7 +14,6 @@ import java.util.ArrayList; ...@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map;
/** /**
* Static library version of {@link android.util.LruCache}. Used to write apps * Static library version of {@link android.util.LruCache}. Used to write apps
...@@ -41,8 +40,8 @@ public class LruCache { ...@@ -41,8 +40,8 @@ public class LruCache {
throw new IllegalArgumentException("maxSize <= 0"); throw new IllegalArgumentException("maxSize <= 0");
} }
this.maxSize = maxSize; this.maxSize = maxSize;
this.map = new LinkedHashMap<String, BitmapDrawable>(0, 0.75f, true); this.map = new LinkedHashMap<>(0, 0.75f, true);
this.mapFilters = new LinkedHashMap<String, ArrayList<String>>(); this.mapFilters = new LinkedHashMap<>();
} }
/** /**
...@@ -69,7 +68,7 @@ public class LruCache { ...@@ -69,7 +68,7 @@ public class LruCache {
public ArrayList<String> getFilterKeys(String key) { public ArrayList<String> getFilterKeys(String key) {
ArrayList<String> arr = mapFilters.get(key); ArrayList<String> arr = mapFilters.get(key);
if (arr != null) { if (arr != null) {
return new ArrayList<String>(arr); return new ArrayList<>(arr);
} }
return null; return null;
} }
...@@ -98,14 +97,17 @@ public class LruCache { ...@@ -98,14 +97,17 @@ public class LruCache {
if (args.length > 1) { if (args.length > 1) {
ArrayList<String> arr = mapFilters.get(args[0]); ArrayList<String> arr = mapFilters.get(args[0]);
if (arr == null) { if (arr == null) {
arr = new ArrayList<String>(); arr = new ArrayList<>();
mapFilters.put(args[0], arr); mapFilters.put(args[0], arr);
} }
arr.add(args[1]); if (!arr.contains(args[1])) {
arr.add(args[1]);
}
} }
if (previous != null) { if (previous != null) {
entryRemoved(false, key, previous, value); entryRemoved(false, key, previous, value);
ImageLoader.getInstance().callGC();
} }
trimToSize(maxSize, key); trimToSize(maxSize, key);
...@@ -137,15 +139,16 @@ public class LruCache { ...@@ -137,15 +139,16 @@ public class LruCache {
if (args.length > 1) { if (args.length > 1) {
ArrayList<String> arr = mapFilters.get(args[0]); ArrayList<String> arr = mapFilters.get(args[0]);
if (arr != null) { if (arr != null) {
arr.remove(key); arr.remove(args[1]);
if (arr.isEmpty()) { if (arr.isEmpty()) {
mapFilters.remove(args[1]); mapFilters.remove(args[0]);
} }
} }
} }
entryRemoved(true, key, value, null); entryRemoved(true, key, value, null);
} }
ImageLoader.getInstance().callGC();
} }
} }
...@@ -172,14 +175,15 @@ public class LruCache { ...@@ -172,14 +175,15 @@ public class LruCache {
if (args.length > 1) { if (args.length > 1) {
ArrayList<String> arr = mapFilters.get(args[0]); ArrayList<String> arr = mapFilters.get(args[0]);
if (arr != null) { if (arr != null) {
arr.remove(key); arr.remove(args[1]);
if (arr.isEmpty()) { if (arr.isEmpty()) {
mapFilters.remove(args[1]); mapFilters.remove(args[0]);
} }
} }
} }
entryRemoved(false, key, previous, null); entryRemoved(false, key, previous, null);
ImageLoader.getInstance().callGC();
} }
return previous; return previous;
......
...@@ -122,6 +122,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -122,6 +122,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public String bucketName; public String bucketName;
public PhotoEntry coverPhoto; public PhotoEntry coverPhoto;
public ArrayList<PhotoEntry> photos = new ArrayList<>(); public ArrayList<PhotoEntry> photos = new ArrayList<>();
public HashMap<Integer, PhotoEntry> photosByIds = new HashMap<>();
public AlbumEntry(int bucketId, String bucketName, PhotoEntry coverPhoto) { public AlbumEntry(int bucketId, String bucketName, PhotoEntry coverPhoto) {
this.bucketId = bucketId; this.bucketId = bucketId;
...@@ -131,6 +132,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -131,6 +132,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public void addPhoto(PhotoEntry photoEntry) { public void addPhoto(PhotoEntry photoEntry) {
photos.add(photoEntry); photos.add(photoEntry);
photosByIds.put(photoEntry.imageId, photoEntry);
} }
} }
...@@ -140,6 +142,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -140,6 +142,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
public long dateTaken; public long dateTaken;
public String path; public String path;
public int orientation; public int orientation;
public String thumbPath;
public String imagePath;
public PhotoEntry(int bucketId, int imageId, long dateTaken, String path, int orientation) { public PhotoEntry(int bucketId, int imageId, long dateTaken, String path, int orientation) {
this.bucketId = bucketId; this.bucketId = bucketId;
...@@ -1095,11 +1099,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -1095,11 +1099,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
if (audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] == 0))) { if (proximitySensor != null && audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] < proximitySensor.getMaximumRange() / 10))) {
return; return;
} }
ignoreProximity = true; ignoreProximity = true;
useFrontSpeaker = event.values[0] == 0; useFrontSpeaker = event.values[0] < proximitySensor.getMaximumRange() / 10;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker); NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker);
MessageObject currentMessageObject = playingMessageObject; MessageObject currentMessageObject = playingMessageObject;
float progress = playingMessageObject.audioProgress; float progress = playingMessageObject.audioProgress;
...@@ -2450,11 +2454,15 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -2450,11 +2454,15 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
decoder.start(); decoder.start();
final int TIMEOUT_USEC = 2500; final int TIMEOUT_USEC = 2500;
ByteBuffer[] decoderInputBuffers = decoder.getInputBuffers(); ByteBuffer[] decoderInputBuffers = null;
ByteBuffer[] encoderOutputBuffers = encoder.getOutputBuffers(); ByteBuffer[] encoderOutputBuffers = null;
ByteBuffer[] encoderInputBuffers = null; ByteBuffer[] encoderInputBuffers = null;
if (Build.VERSION.SDK_INT < 18) { if (Build.VERSION.SDK_INT < 21) {
encoderInputBuffers = encoder.getInputBuffers(); decoderInputBuffers = decoder.getInputBuffers();
encoderOutputBuffers = encoder.getOutputBuffers();
if (Build.VERSION.SDK_INT < 18) {
encoderInputBuffers = encoder.getInputBuffers();
}
} }
checkConversionCanceled(); checkConversionCanceled();
...@@ -2467,7 +2475,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -2467,7 +2475,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (index == videoIndex) { if (index == videoIndex) {
int inputBufIndex = decoder.dequeueInputBuffer(TIMEOUT_USEC); int inputBufIndex = decoder.dequeueInputBuffer(TIMEOUT_USEC);
if (inputBufIndex >= 0) { if (inputBufIndex >= 0) {
ByteBuffer inputBuf = decoderInputBuffers[inputBufIndex]; ByteBuffer inputBuf = null;
if (Build.VERSION.SDK_INT < 21) {
inputBuf = decoderInputBuffers[inputBufIndex];
} else {
inputBuf = decoder.getInputBuffer(inputBufIndex);
}
int chunkSize = extractor.readSampleData(inputBuf, 0); int chunkSize = extractor.readSampleData(inputBuf, 0);
if (chunkSize < 0) { if (chunkSize < 0) {
decoder.queueInputBuffer(inputBufIndex, 0, 0, 0L, MediaCodec.BUFFER_FLAG_END_OF_STREAM); decoder.queueInputBuffer(inputBufIndex, 0, 0, 0L, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
...@@ -2497,7 +2510,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -2497,7 +2510,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) { if (encoderStatus == MediaCodec.INFO_TRY_AGAIN_LATER) {
encoderOutputAvailable = false; encoderOutputAvailable = false;
} else if (encoderStatus == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) { } else if (encoderStatus == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
encoderOutputBuffers = encoder.getOutputBuffers(); if (Build.VERSION.SDK_INT < 21) {
encoderOutputBuffers = encoder.getOutputBuffers();
}
} else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) { } else if (encoderStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
MediaFormat newFormat = encoder.getOutputFormat(); MediaFormat newFormat = encoder.getOutputFormat();
if (videoTrackIndex == -5) { if (videoTrackIndex == -5) {
...@@ -2506,7 +2521,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel ...@@ -2506,7 +2521,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
} else if (encoderStatus < 0) { } else if (encoderStatus < 0) {
throw new RuntimeException("unexpected result from encoder.dequeueOutputBuffer: " + encoderStatus); throw new RuntimeException("unexpected result from encoder.dequeueOutputBuffer: " + encoderStatus);
} else { } else {
ByteBuffer encodedData = encoderOutputBuffers[encoderStatus]; ByteBuffer encodedData = null;
if (Build.VERSION.SDK_INT < 21) {
encodedData = encoderOutputBuffers[encoderStatus];
} else {
encodedData = encoder.getOutputBuffer(encoderStatus);
}
if (encodedData == null) { if (encodedData == null) {
throw new RuntimeException("encoderOutputBuffer " + encoderStatus + " was null"); throw new RuntimeException("encoderOutputBuffer " + encoderStatus + " was null");
} }
......
...@@ -52,6 +52,8 @@ public class NotificationCenter { ...@@ -52,6 +52,8 @@ public class NotificationCenter {
public static final int httpFileDidLoaded = totalEvents++; public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++;
public static final int messageThumbGenerated = totalEvents++;
public static final int wallpapersDidLoaded = totalEvents++; public static final int wallpapersDidLoaded = totalEvents++;
public static final int closeOtherAppActivities = totalEvents++; public static final int closeOtherAppActivities = totalEvents++;
public static final int didUpdatedConnectionState = totalEvents++; public static final int didUpdatedConnectionState = totalEvents++;
...@@ -70,16 +72,16 @@ public class NotificationCenter { ...@@ -70,16 +72,16 @@ public class NotificationCenter {
public static final int FileNewChunkAvailable = totalEvents++; public static final int FileNewChunkAvailable = totalEvents++;
public static final int FilePreparingFailed = totalEvents++; public static final int FilePreparingFailed = totalEvents++;
public final static int audioProgressDidChanged = totalEvents++; public static final int audioProgressDidChanged = totalEvents++;
public final static int audioDidReset = totalEvents++; public static final int audioDidReset = totalEvents++;
public final static int recordProgressChanged = totalEvents++; public static final int recordProgressChanged = totalEvents++;
public final static int recordStarted = totalEvents++; public static final int recordStarted = totalEvents++;
public final static int recordStartError = totalEvents++; public static final int recordStartError = totalEvents++;
public final static int recordStopped = totalEvents++; public static final int recordStopped = totalEvents++;
public final static int screenshotTook = totalEvents++; public static final int screenshotTook = totalEvents++;
public final static int albumsDidLoaded = totalEvents++; public static final int albumsDidLoaded = totalEvents++;
public final static int audioDidSent = totalEvents++; public static final int audioDidSent = totalEvents++;
public final static int audioDidStarted = totalEvents++; public static final int audioDidStarted = totalEvents++;
public static final int audioRouteChanged = totalEvents++; public static final int audioRouteChanged = totalEvents++;
final private HashMap<Integer, ArrayList<Object>> observers = new HashMap<>(); final private HashMap<Integer, ArrayList<Object>> observers = new HashMap<>();
......
/*
* This is the source code of Telegram for Android v. 2.0.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.app.IntentService;
import android.content.Intent;
public class NotificationDelay extends IntentService {
public NotificationDelay() {
super("NotificationDelay");
}
@Override
protected void onHandleIntent(Intent intent) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationsController.getInstance().notificationDelayReached();
}
});
}
}
...@@ -299,6 +299,9 @@ public class TcpConnection extends ConnectionContext { ...@@ -299,6 +299,9 @@ public class TcpConnection extends ConnectionContext {
if (canReuse) { if (canReuse) {
BuffersStorage.getInstance().reuseFreeBuffer(buff); BuffersStorage.getInstance().reuseFreeBuffer(buff);
} }
if (BuildConfig.DEBUG) {
FileLog.e("tmessages", TcpConnection.this + " disconnected, don't send data");
}
return; return;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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