Stability improvements
This commit is contained in:
parent
ad863779f7
commit
98a0a67c10
@ -19,7 +19,7 @@ tasks.withType(JavaCompile) {
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:20.0.+'
|
||||
compile 'com.google.android.gms:play-services:3.2.+'
|
||||
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
|
||||
compile 'net.hockeyapp.android:HockeySDK:3.0.2'
|
||||
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
@ -32,6 +33,9 @@ import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AndroidUtilities {
|
||||
|
||||
public static ProgressDialog progressDialog;
|
||||
|
||||
private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<String, Typeface>();
|
||||
private static int prevOrientation = -10;
|
||||
private static boolean waitingForSms = false;
|
||||
@ -371,4 +375,32 @@ public class AndroidUtilities {
|
||||
}
|
||||
return photoSize;
|
||||
}
|
||||
|
||||
public static void ShowProgressDialog(final Activity activity, final String message) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(activity != null && !activity.isFinishing()) {
|
||||
progressDialog = new ProgressDialog(activity);
|
||||
if (message != null) {
|
||||
progressDialog.setMessage(message);
|
||||
}
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void HideProgressDialog() {
|
||||
RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (progressDialog != null) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,8 @@ public class MessagesStorage {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (currentVersion < 4) {
|
||||
int version = currentVersion;
|
||||
if (version < 4) {
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS user_photos(uid INTEGER, id INTEGER, data BLOB, PRIMARY KEY (uid, id))").stepThis().dispose();
|
||||
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS mid_idx_media ON media(mid);").stepThis().dispose();
|
||||
@ -254,8 +255,10 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
});
|
||||
database.executeFast("PRAGMA user_version = 4").stepThis().dispose();
|
||||
version = 4;
|
||||
}
|
||||
if (currentVersion < 6) {
|
||||
if (version == 4 && version < 6) {
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS enc_tasks_v2(mid INTEGER PRIMARY KEY, date INTEGER)").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS date_idx_enc_tasks_v2 ON enc_tasks_v2(date);").stepThis().dispose();
|
||||
database.beginTransaction();
|
||||
@ -284,6 +287,12 @@ public class MessagesStorage {
|
||||
|
||||
database.executeFast("ALTER TABLE messages ADD COLUMN media INTEGER default 0").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 6").stepThis().dispose();
|
||||
version = 6;
|
||||
}
|
||||
if (version == 6 && version < 7) {
|
||||
database.executeFast("ALTER TABLE enc_chats ADD COLUMN layer INTEGER default 0").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 6").stepThis().dispose();
|
||||
version = 7;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
|
@ -326,23 +326,23 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.User user, long peer) {
|
||||
sendMessage(null, 0, 0, null, null, null, user, null, null, null, peer, false, null);
|
||||
sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null);
|
||||
}
|
||||
|
||||
public void sendMessage(MessageObject message) {
|
||||
sendMessage(null, 0, 0, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath);
|
||||
sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath);
|
||||
}
|
||||
|
||||
public void sendMessage(MessageObject message, long peer) {
|
||||
sendMessage(null, 0, 0, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath);
|
||||
sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer) {
|
||||
sendMessage(null, 0, 0, null, null, null, null, document, null, originalPath, peer, false, path);
|
||||
sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path);
|
||||
}
|
||||
|
||||
public void sendMessage(String message, long peer) {
|
||||
sendMessage(message, 0, 0, null, null, null, null, null, null, null, peer, false, null);
|
||||
sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null);
|
||||
}
|
||||
|
||||
public void sendMessage(double lat, double lon, long peer) {
|
||||
@ -350,18 +350,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_photo photo, String originalPath, long peer) {
|
||||
sendMessage(null, 0, 0, photo, null, null, null, null, null, originalPath, peer, false, null);
|
||||
sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, null);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer) {
|
||||
sendMessage(null, 0, 0, null, video, null, null, null, null, originalPath, peer, false, path);
|
||||
sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path);
|
||||
}
|
||||
|
||||
public void sendMessage(TLRPC.TL_audio audio, String path, long peer) {
|
||||
sendMessage(null, 0, 0, null, null, null, null, null, audio, null, peer, false, path);
|
||||
sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path);
|
||||
}
|
||||
|
||||
private int sendMessage(String message, double lat, double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path) {
|
||||
private int sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path) {
|
||||
TLRPC.Message newMsg = null;
|
||||
int type = -1;
|
||||
int lower_id = (int) peer;
|
||||
@ -420,7 +420,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
newMsg.media = new TLRPC.TL_messageMediaEmpty();
|
||||
type = 0;
|
||||
newMsg.message = message;
|
||||
} else if (lat != 0 && lon != 0) {
|
||||
} else if (lat != null && lon != null) {
|
||||
if (lower_id != 0) {
|
||||
newMsg = new TLRPC.TL_message();
|
||||
} else {
|
||||
|
@ -45,7 +45,7 @@ public class VideoEncodingService extends Service implements NotificationCenter.
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == NotificationCenter.FileUploadProgressChanged) {
|
||||
String fileName = (String)args[0];
|
||||
if (path.equals(fileName)) {
|
||||
if (path != null && path.equals(fileName)) {
|
||||
Float progress = (Float) args[1];
|
||||
Boolean enc = (Boolean) args[2];
|
||||
currentProgress = (int)(progress * 100);
|
||||
|
@ -9,7 +9,6 @@
|
||||
package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -73,8 +72,6 @@ public class Utilities {
|
||||
|
||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
public static ProgressDialog progressDialog;
|
||||
|
||||
static {
|
||||
try {
|
||||
File URANDOM_FILE = new File("/dev/urandom");
|
||||
@ -426,34 +423,6 @@ public class Utilities {
|
||||
return packedData;
|
||||
}
|
||||
|
||||
public static void ShowProgressDialog(final Activity activity, final String message) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!activity.isFinishing()) {
|
||||
progressDialog = new ProgressDialog(activity);
|
||||
if (message != null) {
|
||||
progressDialog.setMessage(message);
|
||||
}
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void HideProgressDialog(Activity activity) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (progressDialog != null) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean copyFile(InputStream sourceFile, File destFile) throws IOException {
|
||||
OutputStream out = new FileOutputStream(destFile);
|
||||
byte[] buf = new byte[4096];
|
||||
|
@ -834,35 +834,37 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
chatListView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) {
|
||||
if (openSecretPhotoRunnable != null) {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
} else {
|
||||
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||
chatListView.setOnItemClickListener(onItemClickListener);
|
||||
chatListView.setLongClickable(true);
|
||||
}
|
||||
});
|
||||
SecretPhotoViewer.getInstance().closePhoto();
|
||||
if (openSecretPhotoRunnable != null || SecretPhotoViewer.getInstance().isVisible()) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) {
|
||||
if (openSecretPhotoRunnable != null) {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
} else {
|
||||
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||
chatListView.setOnItemClickListener(onItemClickListener);
|
||||
chatListView.setLongClickable(true);
|
||||
}
|
||||
});
|
||||
SecretPhotoViewer.getInstance().closePhoto();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() != MotionEvent.ACTION_DOWN) {
|
||||
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||
return true;
|
||||
} else if (openSecretPhotoRunnable != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) {
|
||||
} else if (event.getAction() != MotionEvent.ACTION_DOWN) {
|
||||
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||
return true;
|
||||
} else if (openSecretPhotoRunnable != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
}
|
||||
} else {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
}
|
||||
} else {
|
||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||
openSecretPhotoRunnable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
if (Build.VERSION.SDK_INT < 11 && listView != null) {
|
||||
listView.setAdapter(null);
|
||||
listView = null;
|
||||
listAdapter = null;
|
||||
|
@ -341,7 +341,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
@Override
|
||||
public void sendButtonPressed(int index) {
|
||||
if (selectedPhotos.isEmpty()) {
|
||||
if (index < 0 || index >= selectedAlbum.photos.size()) {
|
||||
if (selectedAlbum == null || index < 0 || index >= selectedAlbum.photos.size()) {
|
||||
return;
|
||||
}
|
||||
MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index);
|
||||
|
@ -171,9 +171,9 @@ public class ActionBarLayer extends FrameLayout {
|
||||
x = AndroidUtilities.dp(16 + leftMargin);
|
||||
} else {
|
||||
if (!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + (logoImageView.getDrawable() != null ? (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f) : 0);
|
||||
} else {
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + logoImageView.getDrawable().getIntrinsicWidth();
|
||||
x = AndroidUtilities.dp(22 + leftMargin) + (logoImageView.getDrawable() != null ? logoImageView.getDrawable().getIntrinsicWidth() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,11 @@ public class BaseFragment {
|
||||
if (fragmentView != null) {
|
||||
ViewGroup parent = (ViewGroup) fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(fragmentView);
|
||||
try {
|
||||
parent.removeView(fragmentView);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
fragmentView = null;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class LayoutListView extends ListView {
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (onInterceptTouchEventListener != null) {
|
||||
return onInterceptTouchEventListener.onInterceptTouchEvent(ev);
|
||||
return onInterceptTouchEventListener.onInterceptTouchEvent(ev) || super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
@ -153,9 +153,13 @@ public class VideoTimelineView extends View {
|
||||
|
||||
public void setVideoPath(String path) {
|
||||
mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||
mediaMetadataRetriever.setDataSource(path);
|
||||
String duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||
videoLength = Long.parseLong(duration);
|
||||
try {
|
||||
mediaMetadataRetriever.setDataSource(path);
|
||||
String duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
|
||||
videoLength = Long.parseLong(duration);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDelegate(VideoTimelineViewDelegate delegate) {
|
||||
|
Loading…
Reference in New Issue
Block a user