Commit bd4152dc authored by DrKLO's avatar DrKLO

restore photo attach long press, bug fixes

parent ebe7ab78
......@@ -82,7 +82,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 213
versionCode 215
versionName "1.4.9"
}
}
......@@ -113,7 +113,7 @@ jint gifOnJNILoad(JavaVM *vm, void *reserved, JNIEnv *env) {
if (defaultCmap == NULL) {
return -1;
}
return JNI_VERSION_1_6;
return JNI_VERSION_1_4;
}
void gifOnJNIUnload(JavaVM *vm, void *reserved) {
......
......@@ -13,7 +13,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env = 0;
srand(time(NULL));
if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
if ((*vm)->GetEnv(vm, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
return -1;
}
......@@ -21,11 +21,9 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return -1;
}
if (gifOnJNILoad(vm, reserved, env) == -1) {
return -1;
}
gifOnJNILoad(vm, reserved, env);
return JNI_VERSION_1_6;
return JNI_VERSION_1_4;
}
void JNI_OnUnload(JavaVM *vm, void *reserved) {
......
......@@ -5,7 +5,7 @@ jfieldID queryArgsCountField;
jint sqliteOnJNILoad(JavaVM *vm, void *reserved, JNIEnv *env) {
jclass class = (*env)->FindClass(env, "org/telegram/SQLite/SQLitePreparedStatement");
queryArgsCountField = (*env)->GetFieldID(env, class, "queryArgsCount", "I");
return JNI_VERSION_1_6;
return JNI_VERSION_1_4;
}
int Java_org_telegram_SQLite_SQLitePreparedStatement_step(JNIEnv* env, jobject object, int statementHandle) {
......
......@@ -50,6 +50,7 @@ public class LocaleController {
public String name;
public String nameEnglish;
public String shortName;
public boolean embededLang;
}
public ArrayList<LocaleInfo> sortedLanguages = new ArrayList<LocaleController.LocaleInfo>();
......@@ -74,6 +75,7 @@ public class LocaleController {
localeInfo.name = "English";
localeInfo.nameEnglish = "English";
localeInfo.shortName = "en";
localeInfo.embededLang = true;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -81,6 +83,7 @@ public class LocaleController {
localeInfo.name = "Italiano";
localeInfo.nameEnglish = "Italian";
localeInfo.shortName = "it";
localeInfo.embededLang = true;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -95,6 +98,7 @@ public class LocaleController {
localeInfo.name = "Deutsch";
localeInfo.nameEnglish = "German";
localeInfo.shortName = "de";
localeInfo.embededLang = true;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -102,6 +106,7 @@ public class LocaleController {
localeInfo.name = "Nederlands";
localeInfo.nameEnglish = "Dutch";
localeInfo.shortName = "nl";
localeInfo.embededLang = true;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -109,6 +114,7 @@ public class LocaleController {
localeInfo.name = "العربية";
localeInfo.nameEnglish = "Arabic";
localeInfo.shortName = "ar";
localeInfo.embededLang = true;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -123,6 +129,7 @@ public class LocaleController {
localeInfo.name = "System default";
localeInfo.nameEnglish = "System default";
localeInfo.shortName = null;
localeInfo.embededLang = true;
sortedLanguages.add(0, localeInfo);
systemDefaultLocale = Locale.getDefault();
......@@ -197,6 +204,7 @@ public class LocaleController {
localeInfo.name = languageName;
localeInfo.nameEnglish = languageNameInEnglish;
localeInfo.shortName = languageCode;
localeInfo.embededLang = false;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
......@@ -248,6 +256,9 @@ public class LocaleController {
editor.commit();
}
if (newLocale != null) {
if (localeInfo.embededLang) {
localeValues.clear();
}
currentLocale = newLocale;
currentLocaleInfo = localeInfo;
changingConfiguration = true;
......
......@@ -10,7 +10,6 @@ package org.telegram.messenger;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
......@@ -35,7 +34,7 @@ public class NativeLoader {
return;
}
if (Build.VERSION.SDK_INT >= 9) {
if (Build.VERSION.SDK_INT >= 10) {
try {
String folder = null;
long libSize = 0;
......@@ -48,6 +47,7 @@ public class NativeLoader {
} else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) {
folder = "armeabi";
libSize = sizes[0];
libSize2 = sizes[1];
} else if (Build.CPU_ABI.equalsIgnoreCase("x86")) {
folder = "x86";
libSize = sizes[2];
......@@ -57,13 +57,13 @@ public class NativeLoader {
} else {
System.loadLibrary("tmessages");
nativeLoaded = true;
Log.e("tmessages", "Unsupported arch: " + Build.CPU_ABI);
FileLog.e("tmessages", "Unsupported arch: " + Build.CPU_ABI);
return;
}
File destFile = new File(context.getApplicationInfo().nativeLibraryDir + "/libtmessages.so");
if (destFile.exists() && (destFile.length() == libSize || libSize2 != 0 && destFile.length() == libSize2)) {
Log.d("tmessages", "Load normal lib");
FileLog.d("tmessages", "Load normal lib");
try {
System.loadLibrary("tmessages");
nativeLoaded = true;
......@@ -77,7 +77,7 @@ public class NativeLoader {
if (destLocalFile.exists()) {
if (destLocalFile.length() == libSize) {
try {
Log.d("tmessages", "Load local lib");
FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true;
return;
......@@ -89,7 +89,7 @@ public class NativeLoader {
}
}
Log.e("tmessages", "Library not found, arch = " + folder);
FileLog.e("tmessages", "Library not found, arch = " + folder);
ZipFile zipFile = null;
InputStream stream = null;
......@@ -114,25 +114,25 @@ public class NativeLoader {
nativeLoaded = true;
return;
} catch (Exception e) {
e.printStackTrace();
FileLog.e("tmessages", e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (Exception e) {
e.printStackTrace();
FileLog.e("tmessages", e);
}
}
if (zipFile != null) {
try {
zipFile.close();
} catch (Exception e) {
e.printStackTrace();
FileLog.e("tmessages", e);
}
}
}
} catch (Exception e) {
e.printStackTrace();
FileLog.e("tmessages", e);
}
}
......
......@@ -67,6 +67,12 @@ public class ApplicationLoader extends Application {
NativeLoader.initNativeLibs(applicationContext);
try {
LocaleController.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
try {
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
......@@ -119,12 +125,6 @@ public class ApplicationLoader extends Application {
super.onCreate();
lastPauseTime = System.currentTimeMillis();
applicationContext = getApplicationContext();
NativeLoader.initNativeLibs(this);
try {
LocaleController.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
applicationHandler = new Handler(applicationContext.getMainLooper());
......
......@@ -93,7 +93,6 @@ import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.BaseFragment;
import org.telegram.ui.Views.EmojiView;
import org.telegram.ui.Views.GifDrawable;
import org.telegram.ui.Views.LayoutListView;
import org.telegram.ui.Views.MessageActionLayout;
import org.telegram.ui.Views.OnSwipeTouchListener;
......@@ -883,49 +882,21 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
chatListView.setOnTouchListener(new OnSwipeTouchListener() {
public void onSwipeRight() {
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
visibleDialog = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
finishFragment(true);
ChatActivity.this.onSwipeRight();
}
public void onSwipeLeft() {
if (swipeOpening) {
return;
}
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
visibleDialog = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (avatarImageView != null) {
swipeOpening = true;
avatarImageView.performClick();
}
ChatActivity.this.onSwipeLeft();
}
});
emptyView.setOnTouchListener(new OnSwipeTouchListener() {
public void onSwipeRight() {
finishFragment(true);
ChatActivity.this.onSwipeRight();
}
public void onSwipeLeft() {
if (swipeOpening) {
return;
}
if (avatarImageView != null) {
swipeOpening = true;
avatarImageView.performClick();
}
ChatActivity.this.onSwipeLeft();
}
});
if (currentChat != null && (currentChat instanceof TLRPC.TL_chatForbidden || currentChat.left)) {
......@@ -942,6 +913,38 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
return fragmentView;
}
private boolean onSwipeLeft() {
if (swipeOpening) {
return false;
}
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
visibleDialog = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (avatarImageView != null) {
swipeOpening = true;
avatarImageView.performClick();
}
return true;
}
private boolean onSwipeRight() {
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
visibleDialog = null;
}
} catch (Exception e) {
FileLog.e("tmessages", e);
}
finishFragment(true);
return true;
}
private void checkSendButton() {
String message = messsageEditText.getText().toString().trim();
message = message.replaceAll("\n\n+", "\n\n");
......@@ -1247,7 +1250,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
String mime = messageObject.messageOwner.media.document.mime_type;
if (mime != null && mime.equals("text/xml")) {
return 5;
return 4;
}
}
return 4;
......@@ -1291,7 +1294,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
String mime = messageObject.messageOwner.media.document.mime_type;
if (mime != null && mime.equals("text/xml")) {
return 5;
return 4;
}
}
//return 4;
......@@ -1615,7 +1618,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
String ext = "";
int idx = documentFilePath.lastIndexOf(".");
if (idx != -1) {
ext = documentFilePath.substring(idx);
ext = documentFilePath.substring(idx + 1);
}
TLRPC.TL_document document = new TLRPC.TL_document();
document.id = 0;
......@@ -1637,19 +1640,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
document.mime_type = "application/octet-stream";
}
if (document.mime_type.equals("image/gif")) {
GifDrawable gifDrawable = null;
try {
gifDrawable = new GifDrawable(f);
Bitmap bitmap = gifDrawable.getBitmap();
Bitmap bitmap = FileLoader.loadBitmap(f.getAbsolutePath(), null, 90, 90);
if (bitmap != null) {
document.thumb = FileLoader.scaleAndSaveImage(bitmap, 90, 90, 55, currentEncryptedChat != null);
document.thumb.type = "s";
}
gifDrawable.recycle();
} catch (Exception e) {
if (gifDrawable != null) {
gifDrawable.recycle();
}
FileLog.e("tmessages", e);
}
}
......@@ -3187,19 +3184,13 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
document.mime_type = "application/octet-stream";
}
if (document.mime_type.equals("image/gif")) {
GifDrawable gifDrawable = null;
try {
gifDrawable = new GifDrawable(path);
Bitmap bitmap = gifDrawable.getBitmap();
Bitmap bitmap = FileLoader.loadBitmap(path, null, 90, 90);
if (bitmap != null) {
document.thumb = FileLoader.scaleAndSaveImage(bitmap, 90, 90, 55, currentEncryptedChat != null);
document.thumb = FileLoader.scaleAndSaveImage(bitmap, 90, 90, 80, currentEncryptedChat != null);
document.thumb.type = "s";
}
gifDrawable.recycle();
} catch (Exception e) {
if (gifDrawable != null) {
gifDrawable.recycle();
}
FileLog.e("tmessages", e);
}
}
......@@ -3661,6 +3652,26 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
MessagesController.getInstance().cancelSendingMessage(message);
}
}
@Override
public void didLongPressed(ChatBaseCell cell) {
createMenu(cell, false);
}
@Override
public boolean canPerformActions() {
return mActionMode == null;
}
@Override
public boolean onSwipeLeft() {
return ChatActivity.this.onSwipeLeft();
}
@Override
public boolean onSwipeRight() {
return ChatActivity.this.onSwipeRight();
}
};
if (view instanceof ChatMediaCell) {
((ChatMediaCell)view).mediaDelegate = new ChatMediaCell.ChatMediaCellDelegate() {
......
......@@ -65,8 +65,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
private String videoPath = null;
private String sendingText = null;
private String documentPath = null;
private Uri[] imagesPathArray = null;
private String[] documentsPathArray = null;
private ArrayList<Uri> imagesPathArray = null;
private ArrayList<String> documentsPathArray = null;
private ArrayList<TLRPC.User> contactsToSend = null;
private int currentConnectionState;
private View statusView;
......@@ -329,7 +329,18 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
parcelable = Uri.parse(parcelable.toString());
}
if (parcelable != null && type != null && type.startsWith("image/")) {
photoPath = (Uri)parcelable;
if (type.equals("image/gif")) {
try {
documentPath = Utilities.getPath((Uri)parcelable);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
if (documentPath == null) {
photoPath = (Uri) parcelable;
}
} else {
photoPath = (Uri) parcelable;
}
} else {
path = Utilities.getPath((Uri)parcelable);
if (path != null) {
......@@ -356,31 +367,42 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
String type = intent.getType();
if (uris != null) {
if (type != null && type.startsWith("image/")) {
Uri[] uris2 = new Uri[uris.size()];
for (int i = 0; i < uris2.length; i++) {
Parcelable parcelable = uris.get(i);
for (Parcelable parcelable : uris) {
if (!(parcelable instanceof Uri)) {
parcelable = Uri.parse(parcelable.toString());
}
uris2[i] = (Uri)parcelable;
if (type.equals("image/gif")) {
if (documentsPathArray == null) {
documentsPathArray = new ArrayList<String>();
}
try {
documentsPathArray.add(Utilities.getPath((Uri) parcelable));
} catch (Exception e) {
FileLog.e("tmessages", e);
}
} else {
if (imagesPathArray == null) {
imagesPathArray = new ArrayList<Uri>();
}
imagesPathArray.add((Uri) parcelable);
}
}
imagesPathArray = uris2;
} else {
String[] uris2 = new String[uris.size()];
for (int i = 0; i < uris2.length; i++) {
Parcelable parcelable = uris.get(i);
for (Parcelable parcelable : uris) {
if (!(parcelable instanceof Uri)) {
parcelable = Uri.parse(parcelable.toString());
}
String path = Utilities.getPath((Uri)parcelable);
String path = Utilities.getPath((Uri) parcelable);
if (path != null) {
if (path.startsWith("file:")) {
path = path.replace("file://", "");
}
uris2[i] = path;
if (documentsPathArray == null) {
documentsPathArray = new ArrayList<String>();
}
documentsPathArray.add(path);
}
}
documentsPathArray = uris2;
}
} else {
error = true;
......@@ -537,21 +559,27 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
}
if (photoPath != null) {
fragment.processSendingPhoto(null, photoPath);
} else if (videoPath != null) {
}
if (videoPath != null) {
fragment.processSendingVideo(videoPath);
} else if (sendingText != null) {
}
if (sendingText != null) {
fragment.processSendingText(sendingText);
} else if (documentPath != null) {
}
if (documentPath != null) {
fragment.processSendingDocument(documentPath);
} else if (imagesPathArray != null) {
}
if (imagesPathArray != null) {
for (Uri path : imagesPathArray) {
fragment.processSendingPhoto(null, path);
}
} else if (documentsPathArray != null) {
}
if (documentsPathArray != null) {
for (String path : documentsPathArray) {
fragment.processSendingDocument(path);
}
} else if (contactsToSend != null && !contactsToSend.isEmpty()) {
}
if (contactsToSend != null && !contactsToSend.isEmpty()) {
for (TLRPC.User user : contactsToSend) {
MessagesController.getInstance().sendMessage(user, dialog_id);
}
......
......@@ -143,15 +143,6 @@ public class ImageReceiver {
recycleBitmap(null);
}
@Override
protected void finalize() throws Throwable {
try {
clearImage();
} finally {
super.finalize();
}
}
private void recycleBitmap(Bitmap newBitmap) {
if (currentImage == null || isPlaceholder) {
return;
......
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