mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Bug fixes
This commit is contained in:
parent
53ddefb818
commit
3354342390
25 changed files with 267 additions and 173 deletions
|
@ -80,7 +80,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 343
|
||||
versionName "1.9.1"
|
||||
versionCode 344
|
||||
versionName "1.9.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,15 @@ public class AndroidUtilities {
|
|||
}
|
||||
|
||||
public static void RunOnUIThread(Runnable runnable) {
|
||||
RunOnUIThread(runnable, 0);
|
||||
}
|
||||
|
||||
public static void RunOnUIThread(Runnable runnable, long delay) {
|
||||
if (delay == 0) {
|
||||
ApplicationLoader.applicationHandler.post(runnable);
|
||||
} else {
|
||||
ApplicationLoader.applicationHandler.postDelayed(runnable, delay);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
package org.telegram.android;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
|
@ -589,6 +592,36 @@ public class ImageLoader {
|
|||
}
|
||||
});
|
||||
|
||||
BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context arg0, Intent intent) {
|
||||
FileLog.e("tmessages", "file system changed");
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
FileLoader.getInstance().setMediaDirs(createMediaPaths());
|
||||
}
|
||||
};
|
||||
if (Intent.ACTION_MEDIA_UNMOUNTED.equals(intent.getAction())) {
|
||||
AndroidUtilities.RunOnUIThread(r, 1000);
|
||||
} else {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
|
||||
filter.addAction(Intent.ACTION_MEDIA_CHECKING);
|
||||
filter.addAction(Intent.ACTION_MEDIA_EJECT);
|
||||
filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
|
||||
filter.addAction(Intent.ACTION_MEDIA_NOFS);
|
||||
filter.addAction(Intent.ACTION_MEDIA_REMOVED);
|
||||
filter.addAction(Intent.ACTION_MEDIA_SHARED);
|
||||
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
|
||||
filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
|
||||
filter.addDataScheme("file");
|
||||
ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
|
||||
|
||||
FileLoader.getInstance().setMediaDirs(createMediaPaths());
|
||||
}
|
||||
|
||||
|
@ -603,6 +636,7 @@ public class ImageLoader {
|
|||
}
|
||||
}
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath);
|
||||
FileLog.e("tmessages", "cache path = " + cachePath);
|
||||
|
||||
try {
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
|
@ -613,8 +647,8 @@ public class ImageLoader {
|
|||
File imagePath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Images");
|
||||
imagePath.mkdir();
|
||||
if (imagePath.isDirectory()) {
|
||||
//new File(imagePath, ".nomedia").delete();
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath);
|
||||
FileLog.e("tmessages", "image path = " + imagePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -625,6 +659,7 @@ public class ImageLoader {
|
|||
videoPath.mkdir();
|
||||
if (videoPath.isDirectory()) {
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath);
|
||||
FileLog.e("tmessages", "video path = " + videoPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -636,6 +671,7 @@ public class ImageLoader {
|
|||
if (audioPath.isDirectory()) {
|
||||
new File(audioPath, ".nomedia").createNewFile();
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_AUDIO, audioPath);
|
||||
FileLog.e("tmessages", "audio path = " + audioPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -647,12 +683,14 @@ public class ImageLoader {
|
|||
if (documentPath.isDirectory()) {
|
||||
new File(documentPath, ".nomedia").createNewFile();
|
||||
mediaDirs.put(FileLoader.MEDIA_DIR_DOCUMENT, documentPath);
|
||||
FileLog.e("tmessages", "documents path = " + documentPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
MediaController.getInstance().checkSaveToGalleryFiles();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
@ -1020,12 +1058,16 @@ public class ImageLoader {
|
|||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
ImageLoader.getInstance().clearMemory();
|
||||
try {
|
||||
if (b == null) {
|
||||
b = BitmapFactory.decodeFile(path, bmOptions);
|
||||
}
|
||||
if (b != null) {
|
||||
b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);
|
||||
}
|
||||
} catch (Throwable e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
}
|
||||
} else if (uri != null) {
|
||||
try {
|
||||
|
@ -1050,7 +1092,12 @@ public class ImageLoader {
|
|||
}
|
||||
|
||||
private static TLRPC.PhotoSize scaleAndSaveImageInternal(Bitmap bitmap, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache) throws Exception {
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
|
||||
Bitmap scaledBitmap = null;
|
||||
if (scaleFactor > 1) {
|
||||
scaledBitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
|
||||
} else {
|
||||
scaledBitmap = bitmap;
|
||||
}
|
||||
|
||||
TLRPC.TL_fileLocation location = new TLRPC.TL_fileLocation();
|
||||
location.volume_id = Integer.MIN_VALUE;
|
||||
|
@ -1064,8 +1111,19 @@ public class ImageLoader {
|
|||
size = new TLRPC.TL_photoCachedSize();
|
||||
}
|
||||
size.location = location;
|
||||
size.w = (int)(photoW / scaleFactor);
|
||||
size.h = (int)(photoH / scaleFactor);
|
||||
size.w = scaledBitmap.getWidth();
|
||||
size.h = scaledBitmap.getHeight();
|
||||
if (size.w <= 100 && size.h <= 100) {
|
||||
size.type = "s";
|
||||
} else if (size.w <= 320 && size.h <= 320) {
|
||||
size.type = "m";
|
||||
} else if (size.w <= 800 && size.h <= 800) {
|
||||
size.type = "x";
|
||||
} else if (size.w <= 1280 && size.h <= 1280) {
|
||||
size.type = "y";
|
||||
} else {
|
||||
size.type = "w";
|
||||
}
|
||||
|
||||
if (!cache) {
|
||||
String fileName = location.volume_id + "_" + location.local_id + ".jpg";
|
||||
|
|
|
@ -206,7 +206,16 @@ public class ImageReceiver {
|
|||
bitmapH /= scale;
|
||||
drawRegion.set(x + (w - bitmapW) / 2, y + (h - bitmapH) / 2, x + (w + bitmapW) / 2, y + (h + bitmapH) / 2);
|
||||
bitmapDrawable.setBounds(drawRegion);
|
||||
try {
|
||||
bitmapDrawable.draw(canvas);
|
||||
} catch (Exception e) {
|
||||
if (currentPath != null) {
|
||||
ImageLoader.getInstance().removeImage(currentPath);
|
||||
currentPath = null;
|
||||
}
|
||||
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
canvas.restore();
|
||||
} else {
|
||||
if (Math.abs(scaleW - scaleH) > 0.00001f) {
|
||||
|
@ -222,7 +231,16 @@ public class ImageReceiver {
|
|||
}
|
||||
bitmapDrawable.setBounds(drawRegion);
|
||||
if (isVisible) {
|
||||
try {
|
||||
bitmapDrawable.draw(canvas);
|
||||
} catch (Exception e) {
|
||||
if (currentPath != null) {
|
||||
ImageLoader.getInstance().removeImage(currentPath);
|
||||
currentPath = null;
|
||||
}
|
||||
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
|
@ -230,7 +248,16 @@ public class ImageReceiver {
|
|||
drawRegion.set(x, y, x + w, y + h);
|
||||
bitmapDrawable.setBounds(drawRegion);
|
||||
if (isVisible) {
|
||||
try {
|
||||
bitmapDrawable.draw(canvas);
|
||||
} catch (Exception e) {
|
||||
if (currentPath != null) {
|
||||
ImageLoader.getInstance().removeImage(currentPath);
|
||||
currentPath = null;
|
||||
}
|
||||
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,10 +266,8 @@ public class ImageReceiver {
|
|||
drawRegion.set(x, y, x + w, y + h);
|
||||
last_placeholder.setBounds(drawRegion);
|
||||
if (isVisible) {
|
||||
try {
|
||||
last_placeholder.draw(canvas);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (currentPath != null) {
|
||||
ImageLoader.getInstance().removeImage(currentPath);
|
||||
|
@ -251,6 +276,12 @@ public class ImageReceiver {
|
|||
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ package org.telegram.android;
|
|||
import android.graphics.drawable.BitmapDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -29,11 +31,6 @@ public class LruCache {
|
|||
private int size;
|
||||
private int maxSize;
|
||||
|
||||
private int putCount;
|
||||
private int evictionCount;
|
||||
private int hitCount;
|
||||
private int missCount;
|
||||
|
||||
/**
|
||||
* @param maxSize for caches that do not override {@link #sizeOf}, this is
|
||||
* the maximum number of entries in the cache. For all other caches,
|
||||
|
@ -63,10 +60,8 @@ public class LruCache {
|
|||
synchronized (this) {
|
||||
mapValue = map.get(key);
|
||||
if (mapValue != null) {
|
||||
hitCount++;
|
||||
return mapValue;
|
||||
}
|
||||
missCount++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -92,7 +87,6 @@ public class LruCache {
|
|||
|
||||
BitmapDrawable previous;
|
||||
synchronized (this) {
|
||||
putCount++;
|
||||
size += safeSizeOf(key, value);
|
||||
previous = map.put(key, value);
|
||||
if (previous != null) {
|
||||
|
@ -114,7 +108,7 @@ public class LruCache {
|
|||
entryRemoved(false, key, previous, value);
|
||||
}
|
||||
|
||||
trimToSize(maxSize);
|
||||
trimToSize(maxSize, key);
|
||||
return previous;
|
||||
}
|
||||
|
||||
|
@ -122,27 +116,22 @@ public class LruCache {
|
|||
* @param maxSize the maximum size of the cache before returning. May be -1
|
||||
* to evict even 0-sized elements.
|
||||
*/
|
||||
private void trimToSize(int maxSize) {
|
||||
while (true) {
|
||||
String key;
|
||||
BitmapDrawable value;
|
||||
private void trimToSize(int maxSize, String justAdded) {
|
||||
synchronized (this) {
|
||||
if (size < 0 || (map.isEmpty() && size != 0)) {
|
||||
throw new IllegalStateException(getClass().getName()
|
||||
+ ".sizeOf() is reporting inconsistent results!");
|
||||
}
|
||||
|
||||
Iterator<HashMap.Entry<String, BitmapDrawable>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (size <= maxSize || map.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
HashMap.Entry<String, BitmapDrawable> entry = iterator.next();
|
||||
|
||||
Map.Entry<String, BitmapDrawable> toEvict = map.entrySet().iterator().next();
|
||||
key = toEvict.getKey();
|
||||
value = toEvict.getValue();
|
||||
map.remove(key);
|
||||
size -= safeSizeOf(key, value);
|
||||
evictionCount++;
|
||||
String key = entry.getKey();
|
||||
if (justAdded != null && justAdded.equals(key)) {
|
||||
continue;
|
||||
}
|
||||
BitmapDrawable value = entry.getValue();
|
||||
size -= safeSizeOf(key, value);
|
||||
iterator.remove();
|
||||
|
||||
String[] args = key.split("@");
|
||||
if (args.length > 1) {
|
||||
|
@ -158,6 +147,7 @@ public class LruCache {
|
|||
entryRemoved(true, key, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the entry for {@code key} if it exists.
|
||||
|
@ -239,7 +229,7 @@ public class LruCache {
|
|||
* Clear the cache, calling {@link #entryRemoved} on each removed entry.
|
||||
*/
|
||||
public final void evictAll() {
|
||||
trimToSize(-1); // -1 will evict 0-sized elements
|
||||
trimToSize(-1, null); // -1 will evict 0-sized elements
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,40 +249,4 @@ public class LruCache {
|
|||
public synchronized final int maxSize() {
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of times {@link #get} returned a value.
|
||||
*/
|
||||
public synchronized final int hitCount() {
|
||||
return hitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of times {@link #get} returned null or required a new
|
||||
* value to be created.
|
||||
*/
|
||||
public synchronized final int missCount() {
|
||||
return missCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of times {@link #put} was called.
|
||||
*/
|
||||
public synchronized final int putCount() {
|
||||
return putCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of values that have been evicted.
|
||||
*/
|
||||
public synchronized final int evictionCount() {
|
||||
return evictionCount;
|
||||
}
|
||||
|
||||
@Override public synchronized final String toString() {
|
||||
int accesses = hitCount + missCount;
|
||||
int hitPercent = accesses != 0 ? (100 * hitCount / accesses) : 0;
|
||||
return String.format("LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]",
|
||||
maxSize, hitCount, missCount, hitPercent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1794,6 +1794,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
|||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putBoolean("save_gallery", saveToGallery);
|
||||
editor.commit();
|
||||
checkSaveToGalleryFiles();
|
||||
}
|
||||
|
||||
public void checkSaveToGalleryFiles() {
|
||||
try {
|
||||
File telegramPath = new File(Environment.getExternalStorageDirectory(), LocaleController.getString("AppName", R.string.AppName));
|
||||
File imagePath = new File(telegramPath, LocaleController.getString("AppName", R.string.AppName) + " Images");
|
||||
|
|
|
@ -417,7 +417,7 @@ public class MessageObject {
|
|||
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
return FileLoader.getAttachFileName(sizeFull);
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.Html;
|
||||
|
||||
|
@ -228,8 +226,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
TLRPC.TL_photos_photo photo = (TLRPC.TL_photos_photo) response;
|
||||
ArrayList<TLRPC.PhotoSize> sizes = photo.photo.sizes;
|
||||
TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 100, 100);
|
||||
TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 1000, 1000);
|
||||
TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 100);
|
||||
TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 1000);
|
||||
user.photo = new TLRPC.TL_userProfilePhoto();
|
||||
user.photo.photo_id = photo.photo.id;
|
||||
if (smallSize != null) {
|
||||
|
|
|
@ -2600,7 +2600,7 @@ public class MessagesStorage {
|
|||
}
|
||||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
if ((downloadMask & MediaController.AUTODOWNLOAD_MASK_PHOTO) != 0) {
|
||||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.media.photo.sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.media.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||
if (photoSize != null) {
|
||||
id = message.media.photo.id;
|
||||
type = MediaController.AUTODOWNLOAD_MASK_PHOTO;
|
||||
|
|
|
@ -46,23 +46,21 @@ public class PhotoObject {
|
|||
}
|
||||
}
|
||||
|
||||
public static PhotoObject getClosestImageWithSize(ArrayList<PhotoObject> arr, int width, int height) {
|
||||
public static PhotoObject getClosestImageWithSize(ArrayList<PhotoObject> arr, int side) {
|
||||
if (arr == null) {
|
||||
return null;
|
||||
}
|
||||
int closestWidth = 9999;
|
||||
int closestHeight = 9999;
|
||||
|
||||
int lastSide = 0;
|
||||
PhotoObject closestObject = null;
|
||||
for (PhotoObject obj : arr) {
|
||||
if (obj == null || obj.photoOwner == null) {
|
||||
continue;
|
||||
}
|
||||
int diffW = Math.abs(obj.photoOwner.w - width);
|
||||
int diffH = Math.abs(obj.photoOwner.h - height);
|
||||
if (closestObject == null || closestWidth > diffW || closestHeight > diffH || closestObject.photoOwner instanceof TLRPC.TL_photoCachedSize) {
|
||||
int currentSide = obj.photoOwner.w >= obj.photoOwner.h ? obj.photoOwner.w : obj.photoOwner.h;
|
||||
if (closestObject == null || closestObject.photoOwner instanceof TLRPC.TL_photoCachedSize || currentSide <= side && lastSide < currentSide) {
|
||||
closestObject = obj;
|
||||
closestWidth = diffW;
|
||||
closestHeight = diffH;
|
||||
lastSide = currentSide;
|
||||
}
|
||||
}
|
||||
return closestObject;
|
||||
|
|
|
@ -1555,19 +1555,16 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
|||
public TLRPC.TL_photo generatePhotoSizes(String path, Uri imageUri) {
|
||||
long time = System.currentTimeMillis();
|
||||
Bitmap bitmap = ImageLoader.loadBitmap(path, imageUri, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
if (bitmap == null && AndroidUtilities.getPhotoSize() != 800) {
|
||||
bitmap = ImageLoader.loadBitmap(path, imageUri, 800, 800);
|
||||
}
|
||||
ArrayList<TLRPC.PhotoSize> sizes = new ArrayList<TLRPC.PhotoSize>();
|
||||
TLRPC.PhotoSize size = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, true);
|
||||
if (size != null) {
|
||||
size.type = "s";
|
||||
sizes.add(size);
|
||||
}
|
||||
size = ImageLoader.scaleAndSaveImage(bitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false);
|
||||
if (size != null) {
|
||||
if (AndroidUtilities.getPhotoSize() == 800) {
|
||||
size.type = "x";
|
||||
} else {
|
||||
size.type = "y";
|
||||
}
|
||||
sizes.add(size);
|
||||
}
|
||||
if (bitmap != null) {
|
||||
|
|
|
@ -946,17 +946,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||
if (netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isRoaming() || netInfo.isAvailable())) {
|
||||
if (netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isAvailable())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
|
||||
if (netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isRoaming())) {
|
||||
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
|
||||
return true;
|
||||
} else {
|
||||
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if(netInfo != null && (netInfo.isConnectedOrConnecting() || netInfo.isRoaming())) {
|
||||
if(netInfo != null && netInfo.isConnectedOrConnecting()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ public class FileLoader {
|
|||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = message.media.photo.sizes;
|
||||
if (sizes.size() > 0) {
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
return getPathToAttach(sizeFull);
|
||||
}
|
||||
|
@ -636,23 +636,20 @@ public class FileLoader {
|
|||
return new File(dir, getAttachFileName(attach));
|
||||
}
|
||||
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int width, int height) {
|
||||
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) {
|
||||
if (sizes == null) {
|
||||
return null;
|
||||
}
|
||||
int closestWidth = 9999;
|
||||
int closestHeight = 9999;
|
||||
int lastSide = 0;
|
||||
TLRPC.PhotoSize closestObject = null;
|
||||
for (TLRPC.PhotoSize obj : sizes) {
|
||||
if (obj == null) {
|
||||
continue;
|
||||
}
|
||||
int diffW = Math.abs(obj.w - width);
|
||||
int diffH = Math.abs(obj.h - height);
|
||||
if (closestObject == null || closestObject instanceof TLRPC.TL_photoCachedSize || closestWidth > diffW || closestHeight > diffH) {
|
||||
int currentSide = obj.w >= obj.h ? obj.w : obj.h;
|
||||
if (closestObject == null || closestObject instanceof TLRPC.TL_photoCachedSize || currentSide <= side && lastSide < currentSide) {
|
||||
closestObject = obj;
|
||||
closestWidth = diffW;
|
||||
closestHeight = diffH;
|
||||
lastSide = currentSide;
|
||||
}
|
||||
}
|
||||
return closestObject;
|
||||
|
|
|
@ -532,8 +532,8 @@ public class Utilities {
|
|||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), LocaleController.getString("AppName", R.string.AppName));
|
||||
if (storageDir != null) {
|
||||
if (! storageDir.mkdirs()) {
|
||||
if (! storageDir.exists()){
|
||||
if (!storageDir.mkdirs()) {
|
||||
if (!storageDir.exists()){
|
||||
FileLog.d("tmessages", "failed to create directory");
|
||||
return null;
|
||||
}
|
||||
|
@ -633,8 +633,7 @@ public class Utilities {
|
|||
try {
|
||||
File storageDir = getAlbumDir();
|
||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||
String imageFileName = "IMG_" + timeStamp + "_";
|
||||
return File.createTempFile(imageFileName, ".jpg", storageDir);
|
||||
return new File(storageDir, "IMG_" + timeStamp + ".jpg");
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
@ -683,8 +682,7 @@ public class Utilities {
|
|||
try {
|
||||
File storageDir = getAlbumDir();
|
||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
||||
String imageFileName = "VID_" + timeStamp + "_";
|
||||
return File.createTempFile(imageFileName, ".mp4", storageDir);
|
||||
return new File(storageDir, "VID_" + timeStamp + ".mp4");
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
|
|
@ -472,7 +472,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
photoWidth = AndroidUtilities.dp(86);
|
||||
photoHeight = AndroidUtilities.dp(86);
|
||||
backgroundWidth = photoWidth + Math.max(nameWidth, infoWidth) + AndroidUtilities.dp(68);
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
|
||||
if (currentPhotoObject != null) {
|
||||
if (currentPhotoObject.image != null) {
|
||||
photoImage.setImageBitmap(currentPhotoObject.image);
|
||||
|
@ -507,7 +507,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
photoHeight = AndroidUtilities.getPhotoSize();
|
||||
}
|
||||
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
|
||||
if (currentPhotoObject != null) {
|
||||
boolean noSize = false;
|
||||
if (currentMessageObject.type == 3 || currentMessageObject.type == 8) {
|
||||
|
|
|
@ -1599,7 +1599,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
Bitmap bitmap = ImageLoader.loadBitmap(f.getAbsolutePath(), null, 90, 90);
|
||||
if (bitmap != null) {
|
||||
document.thumb = ImageLoader.scaleAndSaveImage(bitmap, 90, 90, 55, currentEncryptedChat != null);
|
||||
document.thumb.type = "s";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -1674,6 +1673,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
video.thumb = size;
|
||||
if (video.thumb == null) {
|
||||
video.thumb = new TLRPC.TL_photoSizeEmpty();
|
||||
video.thumb.type = "s";
|
||||
} else {
|
||||
video.thumb.type = "s";
|
||||
}
|
||||
|
@ -1702,8 +1702,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (temp != null && temp.exists()) {
|
||||
video.size = (int) temp.length();
|
||||
}
|
||||
boolean infoObtained = false;
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||
MediaMetadataRetriever mediaMetadataRetriever = null;
|
||||
try {
|
||||
mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||
mediaMetadataRetriever.setDataSource(videoPath);
|
||||
String width = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
|
||||
if (width != null) {
|
||||
|
@ -1717,17 +1720,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (duration != null) {
|
||||
video.duration = (int) Math.ceil(Long.parseLong(duration) / 1000.0f);
|
||||
}
|
||||
infoObtained = true;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
try {
|
||||
if (mediaMetadataRetriever != null) {
|
||||
mediaMetadataRetriever.release();
|
||||
} else {
|
||||
MediaPlayer mp = MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(videoPath)));
|
||||
if (mp == null) {
|
||||
return;
|
||||
mediaMetadataRetriever = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!infoObtained) {
|
||||
try {
|
||||
MediaPlayer mp = MediaPlayer.create(ApplicationLoader.applicationContext, Uri.fromFile(new File(videoPath)));
|
||||
if (mp != null) {
|
||||
video.duration = (int) Math.ceil(mp.getDuration() / 1000.0f);
|
||||
video.w = mp.getVideoWidth();
|
||||
video.h = mp.getVideoHeight();
|
||||
mp.release();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3572,7 +3591,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (message.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||
photoImage.setImage(message.messageOwner.action.newUserPhoto.photo_small, "50_50", AndroidUtilities.getUserAvatarForId(currentUser.id));
|
||||
} else {
|
||||
PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, AndroidUtilities.dp(64), AndroidUtilities.dp(64));
|
||||
PhotoObject photo = PhotoObject.getClosestImageWithSize(message.photoThumbs, AndroidUtilities.dp(64));
|
||||
if (photo != null) {
|
||||
if (photo.image != null) {
|
||||
photoImage.setImageBitmap(photo.image);
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.os.Bundle;
|
|||
import android.os.Parcelable;
|
||||
import android.provider.ContactsContract;
|
||||
import android.view.ActionMode;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -1013,6 +1014,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.getVisibility() == View.VISIBLE && !layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
layersActionBarLayout.onKeyUp(keyCode, event);
|
||||
} else if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
rightActionBarLayout.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
actionBarLayout.onKeyUp(keyCode, event);
|
||||
}
|
||||
} else {
|
||||
actionBarLayout.onKeyUp(keyCode, event);
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
|
|
|
@ -413,7 +413,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
if (message.imagePreview != null) {
|
||||
imageView.setImageBitmap(message.imagePreview);
|
||||
} else {
|
||||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 80, 80);
|
||||
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 80);
|
||||
imageView.setImage(photoSize.location, null, R.drawable.photo_placeholder_in);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -335,7 +335,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (photo instanceof TLRPC.TL_photoEmpty || photo.sizes == null) {
|
||||
continue;
|
||||
}
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 640, 640);
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 640);
|
||||
if (sizeFull != null) {
|
||||
if (currentFileLocation != null) {
|
||||
for (TLRPC.PhotoSize size : photo.sizes) {
|
||||
|
@ -682,7 +682,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (current) {
|
||||
MessagesController.getInstance().deleteUserPhoto(null);
|
||||
closePhoto(false);
|
||||
} else {
|
||||
} else if (photo != null) {
|
||||
TLRPC.TL_inputPhoto inputPhoto = new TLRPC.TL_inputPhoto();
|
||||
inputPhoto.id = photo.id;
|
||||
inputPhoto.access_hash = photo.access_hash;
|
||||
|
@ -951,7 +951,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (message.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||
return message.messageOwner.action.newUserPhoto.photo_big;
|
||||
} else {
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
size[0] = sizeFull.size;
|
||||
if (size[0] == 0) {
|
||||
|
@ -963,7 +963,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
}
|
||||
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && message.messageOwner.media.photo != null) {
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
size[0] = sizeFull.size;
|
||||
if (size[0] == 0) {
|
||||
|
@ -1014,7 +1014,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
location.secret = sizeFull.secret;
|
||||
return location;
|
||||
} else {
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.action.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation();
|
||||
location.local_id = sizeFull.location.local_id;
|
||||
|
@ -1025,7 +1025,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
}
|
||||
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||
if (sizeFull != null) {
|
||||
TLRPC.TL_inputFileLocation location = new TLRPC.TL_inputFileLocation();
|
||||
location.local_id = sizeFull.location.local_id;
|
||||
|
|
|
@ -445,7 +445,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
|||
TextView messageText = (TextView)view.findViewById(R.id.message_text);
|
||||
BackupImageView imageView = (BackupImageView) view.findViewById(R.id.message_image);
|
||||
imageView.imageReceiver.setAspectFit(true);
|
||||
PhotoObject currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize());
|
||||
PhotoObject currentPhotoObject = PhotoObject.getClosestImageWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
|
||||
boolean photoSet = false;
|
||||
if (currentPhotoObject != null) {
|
||||
boolean photoExist = true;
|
||||
|
|
|
@ -143,8 +143,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
TLRPC.TL_photos_photo photo = (TLRPC.TL_photos_photo)response;
|
||||
ArrayList<TLRPC.PhotoSize> sizes = photo.photo.sizes;
|
||||
TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 100, 100);
|
||||
TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 1000, 1000);
|
||||
TLRPC.PhotoSize smallSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 100);
|
||||
TLRPC.PhotoSize bigSize = FileLoader.getClosestPhotoSizeWithSize(sizes, 1000);
|
||||
user.photo = new TLRPC.TL_userProfilePhoto();
|
||||
user.photo.photo_id = photo.photo.id;
|
||||
if (smallSize != null) {
|
||||
|
|
|
@ -119,7 +119,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height));
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
|
||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
||||
|
@ -273,7 +273,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
width = height;
|
||||
height = temp;
|
||||
}
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height));
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
|
||||
if (!f.exists()) {
|
||||
|
@ -532,7 +532,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
|||
BackupImageView image = (BackupImageView)view.findViewById(R.id.image);
|
||||
View selection = view.findViewById(R.id.selection);
|
||||
TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, AndroidUtilities.dp(100), AndroidUtilities.dp(100));
|
||||
TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, AndroidUtilities.dp(100));
|
||||
if (size != null && size.location != null) {
|
||||
image.setImage(size.location, "100_100", 0);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
|
||||
private void positionLogoImage(int height) {
|
||||
if (logoImageView != null) {
|
||||
if (logoImageView != null && logoImageView.getDrawable() != null) {
|
||||
LayoutParams layoutParams = (LayoutParams) logoImageView.getLayoutParams();
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
|
@ -482,7 +482,7 @@ public class ActionBarLayer extends FrameLayout {
|
|||
}
|
||||
|
||||
public void setBackOverlayVisible(boolean visible) {
|
||||
if (actionOverlay == null) {
|
||||
if (actionOverlay == null || parentFragment == null || parentFragment.parentLayout == null) {
|
||||
return;
|
||||
}
|
||||
isBackOverlayVisible = visible;
|
||||
|
|
|
@ -218,6 +218,17 @@ public class ActionBarMenuItem extends ImageView {
|
|||
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
||||
popupLayout.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST));
|
||||
popupWindow.getContentView().setFocusableInTouchMode(true);
|
||||
popupWindow.getContentView().setOnKeyListener(new OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_UP && popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
popupWindow.setFocusable(true);
|
||||
if (popupLayout.getMeasuredWidth() == 0) {
|
||||
|
|
|
@ -510,7 +510,7 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
|
|||
});
|
||||
emojiPopup = new PopupWindow(emojiView);
|
||||
|
||||
/*Utry {
|
||||
/*try {
|
||||
Method method = emojiPopup.getClass().getMethod("setWindowLayoutType", int.class);
|
||||
if (method != null) {
|
||||
method.invoke(emojiPopup, WindowManager.LayoutParams.LAST_SUB_WINDOW);
|
||||
|
@ -545,7 +545,11 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen
|
|||
@Override
|
||||
public void run() {
|
||||
if (messsageEditText != null) {
|
||||
try {
|
||||
messsageEditText.requestFocus();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 600);
|
||||
|
|
Loading…
Reference in a new issue