From dd78d9983afd37430c1bacff8d589d46ef80a73d Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 4 Nov 2016 02:46:28 +0100 Subject: [PATCH] Improve media viewer. --- TMessagesProj/jni/mr_wrapper.c | 27 +- .../telegram/messenger/AndroidUtilities.java | 2 +- .../org/telegram/messenger/ImageLoader.java | 10 +- .../telegram/messenger/LocaleController.java | 4 +- .../telegram/messenger/MediaController.java | 6 +- .../messenger/MessagesController.java | 22 - .../org/telegram/messenger/MrMailbox.java | 4 +- .../messenger/query/SharedMediaQuery.java | 72 +-- .../main/java/org/telegram/tgnet/TLRPC.java | 31 - .../telegram/ui/Adapters/MentionsAdapter.java | 24 +- .../telegram/ui/Cells/ChatMessageCell.java | 15 +- .../java/org/telegram/ui/ChatActivity.java | 49 +- .../PhotoViewerCaptionEnterView.java | 605 ------------------ .../telegram/ui/DocumentSelectActivity.java | 4 +- .../java/org/telegram/ui/LaunchActivity.java | 2 +- .../java/org/telegram/ui/PhotoViewer.java | 259 ++++---- .../org/telegram/ui/SecretPhotoViewer.java | 360 ----------- .../org/telegram/ui/SettingsActivity.java | 19 +- .../src/main/res/values-de/strings.xml | 7 +- .../src/main/res/values-es/strings.xml | 5 +- .../src/main/res/values-it/strings.xml | 5 +- .../src/main/res/values-nl/strings.xml | 5 +- .../src/main/res/values-pt/strings.xml | 5 +- TMessagesProj/src/main/res/values/strings.xml | 7 +- 24 files changed, 269 insertions(+), 1280 deletions(-) delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java delete mode 100644 TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java diff --git a/TMessagesProj/jni/mr_wrapper.c b/TMessagesProj/jni/mr_wrapper.c index bc5c3fee2..0a807ecf9 100644 --- a/TMessagesProj/jni/mr_wrapper.c +++ b/TMessagesProj/jni/mr_wrapper.c @@ -38,7 +38,7 @@ if(a) { (*env)->ReleaseStringUTFChars(env, (a), a##Ptr); } #define JSTRING_NEW(a) \ - (*env)->NewStringUTF(env, a? a : "") /*should handle NULL arguments!*/ + (*env)->NewStringUTF(env, a? a : "") /*should handle NULL arguments, does not return NULL!*/ /* our log handler */ @@ -53,7 +53,7 @@ static void s_log_callback_(int type, const char* msg) case 'w': prio = ANDROID_LOG_WARN; break; default: prio = ANDROID_LOG_ERROR; break; } - __android_log_print(prio, "LibreChat", "%s\n", msg); /* on problems, add `-llog` to `Android.mk` */ + __android_log_print(prio, "DeltaChat", "%s\n", msg); /* on problems, add `-llog` to `Android.mk` */ } @@ -423,6 +423,28 @@ JNIEXPORT jint Java_org_telegram_messenger_MrMailbox_MrChatSendMedia(JNIEnv *env } +JNIEXPORT jintArray Java_org_telegram_messenger_MrMailbox_MrMailboxGetChatMedia(JNIEnv *env, jclass c, jlong hMailbox, jint chat_id, jint msg_type, jint or_msg_type) +{ + carray* ca = mrmailbox_get_chat_media((mrmailbox_t*)hMailbox, chat_id, msg_type, or_msg_type); + if( ca == NULL ) { return NULL; } + + int i, icnt = carray_count(ca); + jintArray ret = (*env)->NewIntArray(env, icnt); if (ret == NULL) { return NULL; } + + if( icnt ) { + void** ca_data = carray_data(ca); + jint* temp = calloc(icnt, sizeof(jint)); + for( i = 0; i < icnt; i++ ) { + temp[i] = (jint)ca_data[i]; + } + (*env)->SetIntArrayRegion(env, ret, 0, icnt, temp); + free(temp); + } + + return ret; +} + + /******************************************************************************* * MrMsglist ******************************************************************************/ @@ -519,7 +541,6 @@ JNIEXPORT jstring Java_org_telegram_messenger_MrMailbox_MrMsgGetParam(JNIEnv *en CHAR_REF(def); char* temp = mrparam_get(ths? ths->m_param:NULL, key, defPtr); jstring ret = JSTRING_NEW(temp); - mrlog_info(" MrMsgGetParam(): got %s", temp); free(temp); CHAR_UNREF(def); return ret; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 492f37172..2d21bd6ef 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -1104,7 +1104,7 @@ public class AndroidUtilities { } File storageDir = null; if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { - storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Telegram"); + storageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Delta Chat"); if (!storageDir.mkdirs()) { if (!storageDir.exists()){ FileLog.d("tmessages", "failed to create directory"); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java index 1906f9dad..efaaec3b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java @@ -1286,12 +1286,12 @@ public class ImageLoader { try { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { - telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram"); + telegramPath = new File(Environment.getExternalStorageDirectory(), "Delta Chat"); telegramPath.mkdirs(); if (telegramPath.isDirectory()) { try { - File imagePath = new File(telegramPath, "Telegram Images"); + File imagePath = new File(telegramPath, "Delta Chat Images"); imagePath.mkdir(); if (imagePath.isDirectory() && canMoveFiles(cachePath, imagePath, FileLoader.MEDIA_DIR_IMAGE)) { mediaDirs.put(FileLoader.MEDIA_DIR_IMAGE, imagePath); @@ -1302,7 +1302,7 @@ public class ImageLoader { } try { - File videoPath = new File(telegramPath, "Telegram Video"); + File videoPath = new File(telegramPath, "Delta Chat Video"); videoPath.mkdir(); if (videoPath.isDirectory() && canMoveFiles(cachePath, videoPath, FileLoader.MEDIA_DIR_VIDEO)) { mediaDirs.put(FileLoader.MEDIA_DIR_VIDEO, videoPath); @@ -1313,7 +1313,7 @@ public class ImageLoader { } try { - File audioPath = new File(telegramPath, "Telegram Audio"); + File audioPath = new File(telegramPath, "Delta Chat Audio"); audioPath.mkdir(); if (audioPath.isDirectory() && canMoveFiles(cachePath, audioPath, FileLoader.MEDIA_DIR_AUDIO)) { new File(audioPath, ".nomedia").createNewFile(); @@ -1325,7 +1325,7 @@ public class ImageLoader { } try { - File documentPath = new File(telegramPath, "Telegram Documents"); + File documentPath = new File(telegramPath, "Delta Chat Documents"); documentPath.mkdir(); if (documentPath.isDirectory() && canMoveFiles(cachePath, documentPath, FileLoader.MEDIA_DIR_DOCUMENT)) { new File(documentPath, ".nomedia").createNewFile(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java index 3e8041b1b..597c4916d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java @@ -51,7 +51,6 @@ public class LocaleController { public FastDateFormat formatterMonth; public FastDateFormat formatterYear; public FastDateFormat formatterMonthYear; - public FastDateFormat formatterYearMax; public FastDateFormat chatDate; public FastDateFormat chatFullDate; @@ -822,8 +821,7 @@ public class LocaleController { nameDisplayOrder = lang.toLowerCase().equals("ko") ? 2 : 1; formatterMonth = createFormatter(locale, getStringInternal("formatterMonth", R.string.formatterMonth), "dd MMM"); - formatterYear = createFormatter(locale, getStringInternal("formatterYear", R.string.formatterYear), "dd.MM.yy"); - formatterYearMax = createFormatter(locale, getStringInternal("formatterYearMax", R.string.formatterYearMax), "dd.MM.yyyy"); + formatterYear = createFormatter(locale, getStringInternal("formatterYear", R.string.formatterYear), "dd.MM.yyyy"); chatDate = createFormatter(locale, getStringInternal("chatDate", R.string.chatDate), "d MMMM"); chatFullDate = createFormatter(locale, getStringInternal("chatFullDate", R.string.chatFullDate), "d MMMM yyyy"); formatterWeek = createFormatter(locale, getStringInternal("formatterWeek", R.string.formatterWeek), "EEE"); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index c74459b38..3389e6037 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -3050,10 +3050,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, public void checkSaveToGalleryFiles() { try { - File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram"); - File imagePath = new File(telegramPath, "Telegram Images"); + File telegramPath = new File(Environment.getExternalStorageDirectory(), "Delta Chat"); + File imagePath = new File(telegramPath, "Delta Chat Images"); imagePath.mkdir(); - File videoPath = new File(telegramPath, "Telegram Video"); + File videoPath = new File(telegramPath, "Delta Chat Video"); videoPath.mkdir(); if (saveToGallery) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 489a6c8e2..63678e42a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -201,7 +201,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByServer); - addSupportUser(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enableJoined = preferences.getBoolean("EnableContactJoined", true); @@ -291,26 +290,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter return true; } - public void addSupportUser() { - TLRPC.TL_userForeign_old2 user = new TLRPC.TL_userForeign_old2(); - user.phone = "333"; - user.id = 333000; - user.first_name = "Telegram"; - user.last_name = ""; - user.status = null; - user.photo = new TLRPC.TL_userProfilePhotoEmpty(); - putUser(user, true); - - user = new TLRPC.TL_userForeign_old2(); - user.phone = "42777"; - user.id = 777000; - user.first_name = "Telegram"; - user.last_name = "Notifications"; - user.status = null; - user.photo = new TLRPC.TL_userProfilePhotoEmpty(); - putUser(user, true); - } - public static TLRPC.InputUser getInputUser(TLRPC.User user) { if (user == null) { return new TLRPC.TL_inputUserEmpty(); @@ -560,7 +539,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter currentDeleteTaskRunnable = null; } - addSupportUser(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MrMailbox.java b/TMessagesProj/src/main/java/org/telegram/messenger/MrMailbox.java index 9724a8c37..385dca2d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MrMailbox.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MrMailbox.java @@ -80,7 +80,7 @@ public class MrMailbox { ret.unread = state!=MR_OUT_READ; // the state of outgoing messages ret.media_unread = ret.unread; ret.flags = 0; // posible flags: MESSAGE_FLAG_HAS_FROM_ID, however, this seems to be read only - ret.post = false; // ? true=avatar wird in gruppen nicht angezeigt + ret.post = false; // ? true=avatar wird in gruppen nicht angezeigt, wird aber in isFromUser() auch überprüft... ret.out = ret.from_id==1; // true=outgoing message, read eg. in MessageObject.isOutOwner() ret.created_by_mr = true; @@ -217,7 +217,7 @@ public class MrMailbox { public native static long MrMailboxGetChatlist (long hMailbox); // returns hChatlist which must be unref'd after usage public native static long MrMailboxGetChatById (long hMailbox, int id); // return hChat which must be unref'd after usage public native static int MrMailboxCreateChatByContactId(long hMailbox, int contact_id); // returns chat_id - + public native static int[] MrMailboxGetChatMedia (long hMailbox, int chat_id, int msg_type, int or_msg_type); public native static long MrMailboxGetMsgById (long hMailbox, int id); // return hMsg which must be unref'd after usage public native static void MrMailboxDeleteMsgById (long hMailbox, int id); public native static int MrMailboxSetConfig (long hMailbox, String key, String value); // value may be NULL diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java index 218c26d90..6e6de893e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/query/SharedMediaQuery.java @@ -16,8 +16,10 @@ import org.telegram.messenger.ChatObject; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; +import org.telegram.messenger.MrMailbox; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.FileLog; +import org.telegram.messenger.Utilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.NativeByteBuffer; import org.telegram.tgnet.RequestDelegate; @@ -85,6 +87,25 @@ public class SharedMediaQuery { } public static void getMediaCount(final long uid, final int type, final int classGuid, boolean fromCache) { + + Utilities.globalQueue.postRunnable(new Runnable() { + @Override + public void run() { + + int[] media = new int[0]; + if( type == SharedMediaQuery.MEDIA_PHOTOVIDEO ) { + media = MrMailbox.MrMailboxGetChatMedia(MrMailbox.hMailbox, (int)uid, MrMailbox.MR_MSG_IMAGE, MrMailbox.MR_MSG_VIDEO); + } + + NotificationCenter.getInstance().postNotificationName(NotificationCenter.mediaCountDidLoaded, + uid, media.length, false /*not from cache*/, type, media); + + + } + }); + + + /* int lower_part = (int)uid; if (fromCache || lower_part == 0) { getMediaCountDatabase(uid, type, classGuid); @@ -135,6 +156,7 @@ public class SharedMediaQuery { }); ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); } + */ } public static int getMediaType(TLRPC.Message message) { @@ -200,23 +222,6 @@ public class SharedMediaQuery { } } - private static void processLoadedMediaCount(final int count, final long uid, final int type, final int classGuid, final boolean fromCache) { - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - int lower_part = (int) uid; - if (fromCache && count == -1 && lower_part != 0) { - getMediaCount(uid, type, classGuid, false); - } else { - if (!fromCache) { - putMediaCountDatabase(uid, type, count); - } - NotificationCenter.getInstance().postNotificationName(NotificationCenter.mediaCountDidLoaded, uid, (fromCache && count == -1 ? 0 : count), fromCache, type); - } - } - }); - } - private static void putMediaCountDatabase(final long uid, final int type, final int count) { /* MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @@ -238,39 +243,6 @@ public class SharedMediaQuery { */ } - private static void getMediaCountDatabase(final long uid, final int type, final int classGuid) { - /* - MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { - @Override - public void run() { - try { - int count = -1; - SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized(String.format(Locale.US, "SELECT count FROM media_counts_v2 WHERE uid = %d AND type = %d LIMIT 1", uid, type)); - if (cursor.next()) { - count = cursor.intValue(0); - } - cursor.dispose(); - int lower_part = (int)uid; - if (count == -1 && lower_part == 0) { - cursor = MessagesStorage.getInstance().getDatabase().queryFinalized(String.format(Locale.US, "SELECT COUNT(mid) FROM media_v2 WHERE uid = %d AND type = %d LIMIT 1", uid, type)); - if (cursor.next()) { - count = cursor.intValue(0); - } - cursor.dispose(); - - if (count != -1) { - putMediaCountDatabase(uid, type, count); - } - } - processLoadedMediaCount(count, uid, type, classGuid, true); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - }); - */ - } - private static void loadMediaDatabase(final long uid, final int offset, final int count, final int max_id, final int type, final int classGuid, final boolean isChannel) { /* MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index f7a981d2e..5c746bea4 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -3060,37 +3060,6 @@ public class TLRPC { } } - public static class TL_inlineBotSwitchPM extends TLObject { - public static int constructor = 0x3c20629f; - - public String text; - public String start_param; - - public static TL_inlineBotSwitchPM TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { - if (TL_inlineBotSwitchPM.constructor != constructor) { - if (exception) { - throw new RuntimeException(String.format("can't parse magic %x in TL_inlineBotSwitchPM", constructor)); - } else { - return null; - } - } - TL_inlineBotSwitchPM result = new TL_inlineBotSwitchPM(); - result.readParams(stream, exception); - return result; - } - - public void readParams(AbstractSerializedData stream, boolean exception) { - text = stream.readString(exception); - start_param = stream.readString(exception); - } - - public void serializeToStream(AbstractSerializedData stream) { - stream.writeInt32(constructor); - stream.writeString(text); - stream.writeString(start_param); - } - } - public static class Update extends TLObject { public int chat_id; public int user_id; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java index de2fcb4bf..4063b6fd6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java @@ -55,9 +55,9 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { private ArrayList searchResultCommands; private ArrayList searchResultCommandsHelp; private ArrayList searchResultCommandsUsers; - private ArrayList searchResultBotContext; - private TLRPC.TL_inlineBotSwitchPM searchResultBotContextSwitch; - private HashMap searchResultBotContextById; + //private ArrayList searchResultBotContext; + //private TLRPC.TL_inlineBotSwitchPM searchResultBotContextSwitch; + //private HashMap searchResultBotContextById; private MentionsAdapterDelegate delegate; private HashMap botInfo; private int resultStartPosition; @@ -709,9 +709,9 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public int getItemCount() { - if (searchResultBotContext != null) { + /*if (searchResultBotContext != null) { return searchResultBotContext.size() + (searchResultBotContextSwitch != null ? 1 : 0); - } else if (searchResultUsernames != null) { + } else */ if (searchResultUsernames != null) { return searchResultUsernames.size(); } else if (searchResultHashtags != null) { return searchResultHashtags.size(); @@ -723,18 +723,18 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public int getItemViewType(int position) { - if (searchResultBotContext != null) { + /*if (searchResultBotContext != null) { if (position == 0 && searchResultBotContextSwitch != null) { return 2; } return 1; - } else { + } else */ { return 0; } } public Object getItem(int i) { - if (searchResultBotContext != null) { + /*if (searchResultBotContext != null) { if (searchResultBotContextSwitch != null) { if (i == 0) { return searchResultBotContextSwitch; @@ -746,7 +746,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { return null; } return searchResultBotContext.get(i); - } else if (searchResultUsernames != null) { + } else */ if (searchResultUsernames != null) { if (i < 0 || i >= searchResultUsernames.size()) { return null; } @@ -781,7 +781,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { }*/ public boolean isBotContext() { - return searchResultBotContext != null; + return false; //searchResultBotContext != null; } public boolean isMediaLayout() { @@ -810,7 +810,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { - if (searchResultBotContext != null) { + /*if (searchResultBotContext != null) { boolean hasTop = searchResultBotContextSwitch != null; if (holder.getItemViewType() == 2) { if (hasTop) { @@ -822,7 +822,7 @@ public class MentionsAdapter extends BaseSearchAdapterRecycler { } ((ContextLinkCell) holder.itemView).setLink(searchResultBotContext.get(position), contextMedia, position != searchResultBotContext.size() - 1, hasTop && position == 0); } - } else { + } else*/ { if (searchResultUsernames != null) { ((MentionCell) holder.itemView).setUser(searchResultUsernames.get(position)); } else if (searchResultHashtags != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 97fd07ae9..84f27146b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -776,10 +776,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (imagePressed) { /*if (currentMessageObject.isSecretPhoto()) { imagePressed = false; - } else*/ if (currentMessageObject.isSendError()) { + } else if (currentMessageObject.isSendError()) { imagePressed = false; result = false; - } else if (currentMessageObject.type == 8 && buttonState == -1 && MediaController.getInstance().canAutoplayGifs() && photoImage.getAnimation() == null) { + } else*/ if (currentMessageObject.type == 8 && buttonState == -1 && MediaController.getInstance().canAutoplayGifs() && photoImage.getAnimation() == null) { imagePressed = false; result = false; } @@ -888,6 +888,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } if (!result) { result = checkPhotoImageMotionEvent(event); + if( result ) { + result = true; + } } if (event.getAction() == MotionEvent.ACTION_CANCEL) { @@ -3280,7 +3283,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate boolean fromBot = currentMessageObject.messageOwner.params != null && currentMessageObject.messageOwner.params.containsKey("query_id"); if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) { - if (currentMessageObject.isOut() && currentMessageObject.isSending() || currentMessageObject.isSendError() && fromBot) { + /*if ((currentMessageObject.isOut() && currentMessageObject.isSending()) || (currentMessageObject.isSendError() && fromBot)) { MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this); buttonState = 4; radialProgress.setBackground(getDrawableForCurrentState(), !fromBot, animated); @@ -3290,7 +3293,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate progress = 1.0f; } radialProgress.setProgress(progress != null ? progress : 0, false); - } else { + } else*/ { if (fileExists) { MediaController.getInstance().removeLoadingFileObserver(this); boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject); @@ -3356,7 +3359,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate invalidate(); } } else { - if (currentMessageObject.isOut() && currentMessageObject.isSending()) { + /*if (currentMessageObject.isOut() && currentMessageObject.isSending()) { if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) { MediaController.getInstance().addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this); boolean needProgress = currentMessageObject.messageOwner.attachPath == null || !currentMessageObject.messageOwner.attachPath.startsWith("http"); @@ -3379,7 +3382,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } invalidate(); } - } else { + } else*/ { if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() != 0) { MediaController.getInstance().removeLoadingFileObserver(this); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 55cc616c8..a74aa9b83 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -71,7 +71,6 @@ import org.telegram.messenger.browser.Browser; import org.telegram.messenger.query.DraftQuery; import org.telegram.messenger.query.MessagesSearchQuery; import org.telegram.messenger.query.MessagesQuery; -import org.telegram.messenger.query.SearchQuery; import org.telegram.messenger.query.StickersQuery; import org.telegram.messenger.support.widget.GridLayoutManager; import org.telegram.messenger.support.widget.LinearLayoutManager; @@ -89,7 +88,6 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; -import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.SimpleTextView; @@ -103,7 +101,6 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.Cells.ChatMessageCell; import org.telegram.ui.Cells.ChatUnreadCell; -import org.telegram.ui.Cells.CheckBoxCell; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Cells.BotHelpCell; @@ -166,7 +163,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private ArrayList actionModeViews = new ArrayList<>(); private ChatAvatarContainer avatarContainer; private TextView bottomOverlayText; - private TextView secretViewStatusTextView; private NumberTextView selectedMessagesCountTextView; private FrameLayout actionModeTitleContainer; private SimpleTextView actionModeTextView; @@ -205,10 +201,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private SimpleTextView pinnedMessageNameTextView; private SimpleTextView pinnedMessageTextView; private FrameLayout alertView; - private Runnable hideAlertViewRunnable; + //private Runnable hideAlertViewRunnable; private TextView alertNameTextView; private TextView alertTextView; - private AnimatorSet alertViewAnimator; + //private AnimatorSet alertViewAnimator; private FrameLayout searchContainer; private ImageView searchUpButton; private ImageView searchDownButton; @@ -312,9 +308,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private String startVideoEdit = null; - private Runnable openSecretPhotoRunnable = null; - private float startX = 0; - private float startY = 0; + //private Runnable openSecretPhotoRunnable = null; + //private float startX = 0; + //private float startY = 0; private final static int copy = 10; private final static int id_forward = 11; @@ -1497,6 +1493,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateMessagesVisisblePart(); } }); + /* -- seems to be needed only for the secrect photo stuff chatListView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -1548,6 +1545,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return false; } }); + */ chatListView.setOnInterceptTouchListener(new RecyclerListView.OnInterceptTouchListener() { @Override public boolean onInterceptTouchEvent(MotionEvent event) { @@ -1573,8 +1571,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } final ChatMessageCell cell = (ChatMessageCell) view; final MessageObject messageObject = cell.getMessageObject(); - if (messageObject == null || messageObject.isSending() || !messageObject.isSecretPhoto() || !cell.getPhotoImage().isInsideImage(x, y - top)) { + //if (messageObject == null || messageObject.isSending() || !messageObject.isSecretPhoto() || !cell.getPhotoImage().isInsideImage(x, y - top)) { + // the condition above is always true due to !messageObject.isSecretPhoto(), however, the loop is important, note the continue above break; + /* } File file = FileLoader.getPathToMessage(messageObject.messageOwner); if (!file.exists()) { @@ -1602,6 +1602,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }; AndroidUtilities.runOnUIThread(openSecretPhotoRunnable, 100); return true; + */ } } return false; @@ -1961,10 +1962,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not mentionGridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { - Object object = mentionsAdapter.getItem(position); - if (object instanceof TLRPC.TL_inlineBotSwitchPM) { + //Object object = mentionsAdapter.getItem(position); + /*if (object instanceof TLRPC.TL_inlineBotSwitchPM) { return 100; - } else { + } else*/ { /*if (mentionsAdapter.getBotContextSwitch() != null) { position--; }*/ @@ -4142,9 +4143,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } else { - if (messageObject.isSending()) { + /*if (messageObject.isSending()) { return -1; - } + }*/ if (messageObject.type == 6) { return -1; } else if (messageObject.isSendError()) { @@ -4154,7 +4155,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return 20; } } else if (messageObject.type == 10 || messageObject.type == 11) { - if (messageObject.getId() == 0 || messageObject.isSending()) { + if (messageObject.getId() == 0 /*|| messageObject.isSending()*/) { return -1; } else { return 1; @@ -7341,9 +7342,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else if (lower_part < 0) { args.putInt("chat_id", -lower_part); } - if (!MessagesController.checkCanOpenChat(args, activity)) { + /*if (!MessagesController.checkCanOpenChat(args, activity)) { return; - } + }*/ ChatActivity chatActivity = new ChatActivity(args); if (presentFragment(chatActivity, true)) { @@ -7777,9 +7778,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (postId != 0) { args.putInt("message_id", postId); } - if (MessagesController.checkCanOpenChat(args, ChatActivity.this)) { + //if (MessagesController.checkCanOpenChat(args, ChatActivity.this)) { presentFragment(new ChatActivity(args), true); - } + //} } } @@ -7905,12 +7906,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void didPressedImage(ChatMessageCell cell) { MessageObject message = cell.getMessageObject(); - if (message.isSendError()) { + /*if (message.isSendError()) { -- for our Messenger, sending is completely asynchrounous - as soon as there is a GUI object, it can be accessed createMenu(cell, false); return; } else if (message.isSending()) { return; - } + }*/ if (message.type == 13) { showDialog(new StickersAlert(getParentActivity(), message.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE ? chatActivityEnterView : null)); } else if (Build.VERSION.SDK_INT >= 16 && message.isVideo() || message.type == 1 || message.type == 0 && !message.isWebpageDocument() || message.isGif()) { @@ -7985,9 +7986,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (uid < 0) { Bundle args = new Bundle(); args.putInt("chat_id", -uid); - if (MessagesController.checkCanOpenChat(args, ChatActivity.this)) { + //if (MessagesController.checkCanOpenChat(args, ChatActivity.this)) { presentFragment(new ChatActivity(args), true); - } + //} } else if (uid != UserConfig.getClientUserId()) { Bundle args = new Bundle(); args.putInt("user_id", uid); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java deleted file mode 100644 index 4d5808c6b..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java +++ /dev/null @@ -1,605 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.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-2016. - */ - -package org.telegram.ui.Components; - -import android.animation.AnimatorSet; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.os.Build; -import android.text.Editable; -import android.text.InputFilter; -import android.text.TextWatcher; -import android.text.style.ImageSpan; -import android.util.TypedValue; -import android.view.ActionMode; -import android.view.Gravity; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.inputmethod.EditorInfo; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; - -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.Emoji; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; -import org.telegram.tgnet.TLRPC; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class PhotoViewerCaptionEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayoutPhoto.SizeNotifierFrameLayoutPhotoDelegate { - - public interface PhotoViewerCaptionEnterViewDelegate { - void onCaptionEnter(); - void onTextChanged(CharSequence text); - void onWindowSizeChanged(int size); - } - - private EditText messageEditText; - private ImageView emojiButton; - private EmojiView emojiView; - private SizeNotifierFrameLayoutPhoto sizeNotifierLayout; - - private ActionMode currentActionMode; - - private AnimatorSet runningAnimation; - private AnimatorSet runningAnimation2; - private ObjectAnimator runningAnimationAudio; - private int runningAnimationType; - private int audioInterfaceState; - - private int lastSizeChangeValue1; - private boolean lastSizeChangeValue2; - - private int keyboardHeight; - private int keyboardHeightLand; - private boolean keyboardVisible; - private int emojiPadding; - - private boolean innerTextChange; - - private PhotoViewerCaptionEnterViewDelegate delegate; - - private View windowView; - - public PhotoViewerCaptionEnterView(Context context, SizeNotifierFrameLayoutPhoto parent, final View window) { - super(context); - setBackgroundColor(0x7f000000); - setFocusable(true); - setFocusableInTouchMode(true); - windowView = window; - - sizeNotifierLayout = parent; - - LinearLayout textFieldContainer = new LinearLayout(context); - textFieldContainer.setOrientation(LinearLayout.HORIZONTAL); - addView(textFieldContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 2, 0, 0, 0)); - - FrameLayout frameLayout = new FrameLayout(context); - textFieldContainer.addView(frameLayout, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1.0f)); - - emojiButton = new ImageView(context); - emojiButton.setImageResource(R.drawable.ic_smile_w); - emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0); - frameLayout.addView(emojiButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT)); - emojiButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!isPopupShowing()) { - showPopup(1); - } else { - openKeyboardInternal(); - } - } - }); - - messageEditText = new EditText(context) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - try { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } catch (Exception e) { - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(51)); - FileLog.e("tmessages", e); - } - } - }; - if (Build.VERSION.SDK_INT >= 23) { - messageEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - currentActionMode = mode; - return true; - } - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - if (Build.VERSION.SDK_INT >= 23) { - fixActionMode(mode); - } - return true; - } - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return false; - } - - @Override - public void onDestroyActionMode(ActionMode mode) { - if (currentActionMode == mode) { - currentActionMode = null; - } - } - }); - - messageEditText.setCustomInsertionActionModeCallback(new ActionMode.Callback() { - @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { - currentActionMode = mode; - return true; - } - - @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - if (Build.VERSION.SDK_INT >= 23) { - fixActionMode(mode); - } - return true; - } - - @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - return false; - } - - @Override - public void onDestroyActionMode(ActionMode mode) { - if (currentActionMode == mode) { - currentActionMode = null; - } - } - }); - } - messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption)); - messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); - messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES); - messageEditText.setMaxLines(4); - messageEditText.setHorizontallyScrolling(false); - messageEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); - messageEditText.setGravity(Gravity.BOTTOM); - messageEditText.setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(12)); - messageEditText.setBackgroundDrawable(null); - AndroidUtilities.clearCursorDrawable(messageEditText); - messageEditText.setTextColor(0xffffffff); - messageEditText.setHintTextColor(0xb2ffffff); - InputFilter[] inputFilters = new InputFilter[1]; - inputFilters[0] = new InputFilter.LengthFilter(200); - messageEditText.setFilters(inputFilters); - frameLayout.addView(messageEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 52, 0, 6, 0)); - messageEditText.setOnKeyListener(new OnKeyListener() { - @Override - public boolean onKey(View view, int i, KeyEvent keyEvent) { - if (i == KeyEvent.KEYCODE_BACK) { - if (hideActionMode()) { - return true; - } else if (!keyboardVisible && isPopupShowing()) { - if (keyEvent.getAction() == 1) { - showPopup(0); - } - return true; - } - } - return false; - } - }); - messageEditText.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - if (isPopupShowing()) { - showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2); - } - } - }); - /*messageEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { - if (i == EditorInfo.IME_ACTION_DONE || i == EditorInfo.IME_ACTION_NEXT) { - delegate.onCaptionEnter(); - return true; - } else - if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) { - delegate.onCaptionEnter(); - return true; - } - return false; - } - });*/ - messageEditText.addTextChangedListener(new TextWatcher() { - boolean processChange = false; - - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { - - } - - @Override - public void onTextChanged(CharSequence charSequence, int start, int before, int count) { - if (innerTextChange) { - return; - } - - if (delegate != null) { - delegate.onTextChanged(charSequence); - } - - if (before != count && (count - before) > 1) { - processChange = true; - } - } - - @Override - public void afterTextChanged(Editable editable) { - if (innerTextChange) { - return; - } - if (processChange) { - ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class); - for (int i = 0; i < spans.length; i++) { - editable.removeSpan(spans[i]); - } - Emoji.replaceEmoji(editable, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); - processChange = false; - } - } - }); - } - - public boolean hideActionMode() { - if (Build.VERSION.SDK_INT >= 23 && currentActionMode != null) { - currentActionMode.finish(); - currentActionMode = null; - return true; - } - return false; - } - - @SuppressWarnings("unchecked") - private void fixActionMode(ActionMode mode) { - try { - Class classActionMode = Class.forName("com.android.internal.view.FloatingActionMode"); - Field fieldToolbar = classActionMode.getDeclaredField("mFloatingToolbar"); - fieldToolbar.setAccessible(true); - Object toolbar = fieldToolbar.get(mode); - - Class classToolbar = Class.forName("com.android.internal.widget.FloatingToolbar"); - Field fieldToolbarPopup = classToolbar.getDeclaredField("mPopup"); - Field fieldToolbarWidth = classToolbar.getDeclaredField("mWidthChanged"); - fieldToolbarPopup.setAccessible(true); - fieldToolbarWidth.setAccessible(true); - Object popup = fieldToolbarPopup.get(toolbar); - - Class classToolbarPopup = Class.forName("com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup"); - Field fieldToolbarPopupParent = classToolbarPopup.getDeclaredField("mParent"); - fieldToolbarPopupParent.setAccessible(true); - - View currentView = (View) fieldToolbarPopupParent.get(popup); - if (currentView != windowView) { - fieldToolbarPopupParent.set(popup, windowView); - - Method method = classActionMode.getDeclaredMethod("updateViewLocationInWindow"); - method.setAccessible(true); - method.invoke(mode); - } - } catch (Throwable e) { - FileLog.e("tmessages", e); - } - } - - private void onWindowSizeChanged() { - int size = sizeNotifierLayout.getHeight(); - if (!keyboardVisible) { - size -= emojiPadding; - } - if (delegate != null) { - delegate.onWindowSizeChanged(size); - } - } - - public void onCreate() { - NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded); - sizeNotifierLayout.setDelegate(this); - } - - public void onDestroy() { - hidePopup(); - if (isKeyboardVisible()) { - closeKeyboard(); - } - keyboardVisible = false; - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded); - if (sizeNotifierLayout != null) { - sizeNotifierLayout.setDelegate(null); - } - } - - public void setDelegate(PhotoViewerCaptionEnterViewDelegate delegate) { - this.delegate = delegate; - } - - public void setFieldText(CharSequence text) { - if (messageEditText == null) { - return; - } - messageEditText.setText(text); - messageEditText.setSelection(messageEditText.getText().length()); - if (delegate != null) { - delegate.onTextChanged(messageEditText.getText()); - } - } - - public int getCursorPosition() { - if (messageEditText == null) { - return 0; - } - return messageEditText.getSelectionStart(); - } - - public void replaceWithText(int start, int len, String text) { - try { - StringBuilder builder = new StringBuilder(messageEditText.getText()); - builder.replace(start, start + len, text); - messageEditText.setText(builder); - if (start + text.length() <= messageEditText.length()) { - messageEditText.setSelection(start + text.length()); - } else { - messageEditText.setSelection(messageEditText.length()); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - - public void setFieldFocused(boolean focus) { - if (messageEditText == null) { - return; - } - if (focus) { - if (!messageEditText.isFocused()) { - messageEditText.postDelayed(new Runnable() { - @Override - public void run() { - if (messageEditText != null) { - try { - messageEditText.requestFocus(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - } - }, 600); - } - } else { - if (messageEditText.isFocused() && !keyboardVisible) { - messageEditText.clearFocus(); - } - } - } - - public CharSequence getFieldCharSequence() { - return messageEditText.getText(); - } - - public int getEmojiPadding() { - return emojiPadding; - } - - public boolean isPopupView(View view) { - return view == emojiView; - } - - private void showPopup(int show) { - if (show == 1) { - if (emojiView == null) { - emojiView = new EmojiView(false, false, getContext()); - emojiView.setListener(new EmojiView.Listener() { - public boolean onBackspace() { - if (messageEditText.length() == 0) { - return false; - } - messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); - return true; - } - - public void onEmojiSelected(String symbol) { - int i = messageEditText.getSelectionEnd(); - if (i < 0) { - i = 0; - } - try { - innerTextChange = true; - CharSequence localCharSequence = Emoji.replaceEmoji(symbol/* + "\uFE0F"*/, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); - messageEditText.setText(messageEditText.getText().insert(i, localCharSequence)); - int j = i + localCharSequence.length(); - messageEditText.setSelection(j, j); - } catch (Exception e) { - FileLog.e("tmessages", e); - } finally { - innerTextChange = false; - } - } - - public void onStickerSelected(TLRPC.Document sticker) { - - } - - @Override - public void onStickersSettingsClick() { - - } - - @Override - public void onGifSelected(TLRPC.Document gif) { - - } - - @Override - public void onGifTab(boolean opened) { - - } - - @Override - public void onStickersTab(boolean opened) { - - } - - @Override - public void onClearEmojiRecent() { - - } - }); - sizeNotifierLayout.addView(emojiView); - } - - emojiView.setVisibility(VISIBLE); - - if (keyboardHeight <= 0) { - keyboardHeight = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height", AndroidUtilities.dp(200)); - } - if (keyboardHeightLand <= 0) { - keyboardHeightLand = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height_land3", AndroidUtilities.dp(200)); - } - int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight; - - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams(); - layoutParams.width = AndroidUtilities.displaySize.x; - layoutParams.height = currentHeight; - emojiView.setLayoutParams(layoutParams); - AndroidUtilities.hideKeyboard(messageEditText); - if (sizeNotifierLayout != null) { - emojiPadding = currentHeight; - sizeNotifierLayout.requestLayout(); - emojiButton.setImageResource(R.drawable.ic_keyboard_w); - onWindowSizeChanged(); - } - } else { - if (emojiButton != null) { - emojiButton.setImageResource(R.drawable.ic_smile_w); - } - if (emojiView != null) { - emojiView.setVisibility(GONE); - } - if (sizeNotifierLayout != null) { - if (show == 0) { - emojiPadding = 0; - } - sizeNotifierLayout.requestLayout(); - onWindowSizeChanged(); - } - } - } - - public void hidePopup() { - if (isPopupShowing()) { - showPopup(0); - } - } - - private void openKeyboardInternal() { - showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2); - AndroidUtilities.showKeyboard(messageEditText); - } - - public void openKeyboard() { - messageEditText.requestFocus(); - AndroidUtilities.showKeyboard(messageEditText); - } - - public boolean isPopupShowing() { - return emojiView != null && emojiView.getVisibility() == VISIBLE; - } - - public void closeKeyboard() { - AndroidUtilities.hideKeyboard(messageEditText); - } - - public boolean isKeyboardVisible() { - return AndroidUtilities.usingHardwareInput && getLayoutParams() != null && ((FrameLayout.LayoutParams) getLayoutParams()).bottomMargin == 0 || keyboardVisible; - } - - @Override - public void onSizeChanged(int height, boolean isWidthGreater) { - if (height > AndroidUtilities.dp(50) && keyboardVisible) { - if (isWidthGreater) { - keyboardHeightLand = height; - ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit(); - } else { - keyboardHeight = height; - ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height", keyboardHeight).commit(); - } - } - - if (isPopupShowing()) { - int newHeight; - if (isWidthGreater) { - newHeight = keyboardHeightLand; - } else { - newHeight = keyboardHeight; - } - - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams(); - if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) { - layoutParams.width = AndroidUtilities.displaySize.x; - layoutParams.height = newHeight; - emojiView.setLayoutParams(layoutParams); - if (sizeNotifierLayout != null) { - emojiPadding = layoutParams.height; - sizeNotifierLayout.requestLayout(); - onWindowSizeChanged(); - } - } - } - - if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) { - onWindowSizeChanged(); - return; - } - lastSizeChangeValue1 = height; - lastSizeChangeValue2 = isWidthGreater; - - boolean oldValue = keyboardVisible; - keyboardVisible = height > 0; - if (keyboardVisible && isPopupShowing()) { - showPopup(0); - } - if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) { - emojiPadding = 0; - sizeNotifierLayout.requestLayout(); - } - onWindowSizeChanged(); - } - - @Override - public void didReceivedNotification(int id, Object... args) { - if (id == NotificationCenter.emojiDidLoaded) { - if (emojiView != null) { - emojiView.invalidateViews(); - } - } - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 7a36f9e21..0c5f7b7ee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -589,10 +589,10 @@ public class DocumentSelectActivity extends BaseFragment { items.add(fs); try { - File telegramPath = new File(Environment.getExternalStorageDirectory(), "Telegram"); + File telegramPath = new File(Environment.getExternalStorageDirectory(), "Delta Chat"); if (telegramPath.exists()) { fs = new ListItem(); - fs.title = "Telegram"; + fs.title = "Delta Chat"; fs.subtitle = telegramPath.toString(); fs.icon = R.drawable.ic_directory; fs.file = telegramPath; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index b8785f0a5..23c39d95a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -1709,7 +1709,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override protected void onDestroy() { PhotoViewer.getInstance().destroyPhotoViewer(); - SecretPhotoViewer.getInstance().destroyPhotoViewer(); + //SecretPhotoViewer.getInstance().destroyPhotoViewer(); StickerPreviewViewer.getInstance().destroy(); try { if (visibleDialog != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 3556cd425..6acbd7318 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -53,10 +53,12 @@ import android.widget.ImageView; import android.widget.ListView; import android.widget.Scroller; import android.widget.TextView; +import android.widget.Toast; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.Emoji; import org.telegram.messenger.ImageLoader; +import org.telegram.messenger.MrMailbox; import org.telegram.messenger.UserObject; import org.telegram.messenger.exoplayer.AspectRatioFrameLayout; import org.telegram.messenger.exoplayer.ExoPlayer; @@ -90,7 +92,6 @@ import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PhotoCropView; import org.telegram.ui.Components.PhotoFilterView; import org.telegram.ui.Components.PickerBottomLayout; -import org.telegram.ui.Components.PhotoViewerCaptionEnterView; import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.SeekBar; import org.telegram.ui.Components.SizeNotifierFrameLayoutPhoto; @@ -126,7 +127,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private TextView nameTextView; private TextView dateTextView; private ActionBarMenuItem menuItem; - private ImageView shareButton; + //private ImageView shareButton; -- we have a menu atop, this is clearer, tg uses different positions for image/video private BackgroundDrawable backgroundDrawable = new BackgroundDrawable(0xff000000); private CheckBox checkImageView; private PickerBottomLayout pickerView; @@ -134,19 +135,19 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private RadialProgressView radialProgressViews[] = new RadialProgressView[3]; private ActionBarMenuItem cropItem; private ActionBarMenuItem tuneItem; - private ActionBarMenuItem captionItem; - private ActionBarMenuItem captionDoneItem; + //private ActionBarMenuItem captionItem; + //private ActionBarMenuItem captionDoneItem; private AnimatorSet currentActionBarAnimation; private PhotoCropView photoCropView; private PhotoFilterView photoFilterView; private AlertDialog visibleDialog; - private TextView captionTextView; - private TextView captionTextViewOld; - private TextView captionTextViewNew; - private PhotoViewerCaptionEnterView captionEditText; + //private TextView captionTextView; + //private TextView captionTextViewOld; + //private TextView captionTextViewNew; + //private PhotoViewerCaptionEnterView captionEditText; private boolean canShowBottom = true; private int sendPhotoType = 0; - private boolean needCaptionLayout; + //private boolean needCaptionLayout; private AnimatedFileDrawable currentAnimation; private AspectRatioFrameLayout aspectRatioFrameLayout; @@ -196,7 +197,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private PlaceProviderObject hideAfterAnimation; private boolean disableShowCheck = false; - private String lastTitle; + //private String lastTitle; private int currentEditMode; @@ -231,7 +232,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private float animateToY; private float animateToScale; private float animationValue; - private int currentRotation; private long animationStartTime; private AnimatorSet imageMoveAnimation; private AnimatorSet changeModeAnimation; @@ -270,16 +270,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private ArrayList avatarsArr = new ArrayList<>(); private ArrayList imagesArrLocationsSizes = new ArrayList<>(); private ArrayList imagesArrLocals = new ArrayList<>(); - private TLRPC.FileLocation currentUserAvatarLocation = null; + //private TLRPC.FileLocation currentUserAvatarLocation = null; private final static int gallery_menu_save = 1; private final static int gallery_menu_showall = 2; private final static int gallery_menu_send = 3; private final static int gallery_menu_crop = 4; - private final static int gallery_menu_delete = 6; + //private final static int gallery_menu_delete = 6;-- for now, the user should use the long-click in the cat view private final static int gallery_menu_tune = 7; - private final static int gallery_menu_caption = 8; - private final static int gallery_menu_caption_done = 9; + //private final static int gallery_menu_caption = 8;-- currently, we do not allow messages along images; KISS: just use a separate message + //private final static int gallery_menu_caption_done = 9; private final static int gallery_menu_share = 10; private final static int gallery_menu_openin = 11; @@ -591,9 +591,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (child.getVisibility() == GONE) { continue; } - if (captionEditText.isPopupView(child)) { + /*if (captionEditText.isPopupView(child)) { child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY)); - } else { + } else*/ { measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); } } @@ -603,7 +603,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); - int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) ? captionEditText.getEmojiPadding() : 0; + int paddingBottom = 0;//getKeyboardHeight() <= AndroidUtilities.dp(20) ? captionEditText.getEmojiPadding() : 0; for (int i = 0; i < count; i++) { final View child = getChildAt(i); @@ -653,22 +653,24 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } if (child == mentionListView) { - if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) { + //if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) { childTop += AndroidUtilities.dp(400); - } else { + /*} else { childTop -= captionEditText.getMeasuredHeight(); - } - } else if (child == captionEditText) { + }*/ + } + /* else if (child == captionEditText) { if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) { childTop += AndroidUtilities.dp(400); } - } else if (child == pickerView || child == captionTextViewNew || child == captionTextViewOld) { + } + else if (child == pickerView || child == captionTextViewNew || child == captionTextViewOld) { if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) { childTop += AndroidUtilities.dp(400); } } else if (captionEditText.isPopupView(child)) { childTop = captionEditText.getBottom(); - } + } */ child.layout(childLeft, childTop, childLeft + width, childTop + height); } @@ -768,11 +770,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat avatarsArr.add(photo); } } + /* if (!avatarsArr.isEmpty()) { menuItem.showSubItem(gallery_menu_delete); } else { menuItem.hideSubItem(gallery_menu_delete); } + */ needSearchImageInArr = false; currentIndex = -1; if (setToImage != -1) { @@ -792,14 +796,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (uid == currentDialogId || uid == mergeDialogId) { if (uid == currentDialogId) { totalImagesCount = (Integer) args[1]; - /*if ((Boolean) args[2]) { - SharedMediaQuery.getMediaCount(currentDialogId, SharedMediaQuery.MEDIA_PHOTOVIDEO, classGuid, false); - }*/ } else if (uid == mergeDialogId) { totalImagesCountMerge = (Integer) args[1]; - /*if ((Boolean) args[2]) { - SharedMediaQuery.getMediaCount(mergeDialogId, SharedMediaQuery.MEDIA_PHOTOVIDEO, classGuid, false); - }*/ } if (needSearchImageInArr && isFirstLoading) { isFirstLoading = false; @@ -929,11 +927,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } } - } else if (id == NotificationCenter.emojiDidLoaded) { + } /*else if (id == NotificationCenter.emojiDidLoaded) { if (captionTextView != null) { captionTextView.invalidate(); } - } + }*/ } private void onSharePressed() { @@ -999,10 +997,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat @Override public boolean dispatchKeyEventPreIme(KeyEvent event) { if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { - if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) { + /*if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) { closeCaptionEnter(false); return false; - } + }*/ PhotoViewer.getInstance().closePhoto(true, false); return true; } @@ -1058,10 +1056,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat @Override public void onItemClick(int id) { if (id == -1) { - if (needCaptionLayout && (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible())) { + /*if (needCaptionLayout && (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible())) { closeCaptionEnter(false); return; - } + }*/ closePhoto(true, false); } else if (id == gallery_menu_save) { if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { @@ -1080,12 +1078,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat MediaController.saveFile(f.toString(), parentActivity, currentMessageObject != null && currentMessageObject.isVideo() ? 1 : 0, null, null); } else { AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); - builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); builder.setMessage(LocaleController.getString("PleaseDownload", R.string.PleaseDownload)); showAlertDialog(builder); } } else if (id == gallery_menu_showall) { + Toast.makeText(parentActivity, LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_LONG).show(); + /* if (opennedFromMedia) { closePhoto(true, false); } else if (currentDialogId != 0) { @@ -1095,6 +1094,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat args2.putLong("dialog_id", currentDialogId); ((LaunchActivity) parentActivity).presentFragment(new MediaActivity(args2), false, true); } + */ } else if (id == gallery_menu_send) { /*Intent intent = new Intent(this, MessagesActivity.class); intent.putExtra("onlySelect", true); @@ -1132,7 +1132,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat switchToEditMode(1); } else if (id == gallery_menu_tune) { switchToEditMode(2); - } else if (id == gallery_menu_delete) { + } + /* else if (id == gallery_menu_delete) { if (parentActivity == null) { return; } @@ -1216,7 +1217,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); - } else if (id == gallery_menu_caption) { + } */ + /*else if (id == gallery_menu_caption) { if (imageMoveAnimation != null || changeModeAnimation != null) { return; } @@ -1238,7 +1240,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar.setTitle(LocaleController.getString("PhotoCaption", R.string.PhotoCaption)); } else if (id == gallery_menu_caption_done) { closeCaptionEnter(true); - } else if (id == gallery_menu_share) { + } + */ + else if (id == gallery_menu_share) { onSharePressed(); } else if (id == gallery_menu_openin) { try { @@ -1278,10 +1282,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat menuItem.addSubItem(gallery_menu_showall, LocaleController.getString("ShowAllMedia", R.string.ShowAllMedia), 0); menuItem.addSubItem(gallery_menu_share, LocaleController.getString("ShareFile", R.string.ShareFile), 0); menuItem.addSubItem(gallery_menu_save, LocaleController.getString("SaveToGallery", R.string.SaveToGallery), 0); - menuItem.addSubItem(gallery_menu_delete, LocaleController.getString("Delete", R.string.Delete), 0); + //menuItem.addSubItem(gallery_menu_delete, LocaleController.getString("Delete", R.string.Delete), 0); -- for now, the user should use the long-click in the cat view - captionDoneItem = menu.addItemWithWidth(gallery_menu_caption_done, R.drawable.ic_done, AndroidUtilities.dp(56)); - captionItem = menu.addItemWithWidth(gallery_menu_caption, R.drawable.photo_text, AndroidUtilities.dp(56)); + //captionDoneItem = menu.addItemWithWidth(gallery_menu_caption_done, R.drawable.ic_done, AndroidUtilities.dp(56)); + //captionItem = menu.addItemWithWidth(gallery_menu_caption, R.drawable.photo_text, AndroidUtilities.dp(56)); cropItem = menu.addItemWithWidth(gallery_menu_crop, R.drawable.photo_crop, AndroidUtilities.dp(56)); tuneItem = menu.addItemWithWidth(gallery_menu_tune, R.drawable.photo_tools, AndroidUtilities.dp(56)); @@ -1289,6 +1293,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat bottomLayout.setBackgroundColor(0x7f000000); containerView.addView(bottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT)); + /* captionTextViewOld = new TextView(actvityContext); captionTextViewOld.setMaxLines(10); captionTextViewOld.setBackgroundColor(0x7f000000); @@ -1310,6 +1315,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat captionTextViewNew.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); captionTextViewNew.setVisibility(View.INVISIBLE); containerView.addView(captionTextViewNew, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48)); + */ radialProgressViews[0] = new RadialProgressView(containerView.getContext(), containerView); radialProgressViews[0].setBackgroundState(0, false); @@ -1318,6 +1324,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat radialProgressViews[2] = new RadialProgressView(containerView.getContext(), containerView); radialProgressViews[2].setBackgroundState(0, false); + /* shareButton = new ImageView(containerView.getContext()); shareButton.setImageResource(R.drawable.share); shareButton.setScaleType(ImageView.ScaleType.CENTER); @@ -1329,6 +1336,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat onSharePressed(); } }); + */ nameTextView = new TextView(containerView.getContext()); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); @@ -1524,6 +1532,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); + /* captionEditText = new PhotoViewerCaptionEnterView(actvityContext, containerView, windowView); captionEditText.setDelegate(new PhotoViewerCaptionEnterView.PhotoViewerCaptionEnterViewDelegate() { @Override @@ -1555,6 +1564,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }); containerView.addView(captionEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, -400)); + */ mentionListView = new RecyclerListView(actvityContext); mentionListView.setTag(5); @@ -1666,11 +1676,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat int len = mentionsAdapter.getResultLength(); if (object instanceof TLRPC.User) { TLRPC.User user = (TLRPC.User) object; - if (user != null) { + /*if (user != null) { captionEditText.replaceWithText(start, len, "@" + user.username + " "); - } + }*/ } else if (object instanceof String) { - captionEditText.replaceWithText(start, len, object + " "); + //captionEditText.replaceWithText(start, len, object + " "); } } }); @@ -1830,8 +1840,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat videoPlayerControlFrameLayout.setVisibility(View.VISIBLE); dateTextView.setVisibility(View.GONE); nameTextView.setVisibility(View.GONE); - shareButton.setVisibility(View.GONE); - menuItem.showSubItem(gallery_menu_share); + //shareButton.setVisibility(View.GONE); + //menuItem.showSubItem(gallery_menu_share); } if (videoTextureView.getSurfaceTexture() != null) { videoPlayer.setSurface(new Surface(videoTextureView.getSurfaceTexture())); @@ -1860,11 +1870,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat videoPlayerControlFrameLayout.setVisibility(View.GONE); dateTextView.setVisibility(View.VISIBLE); nameTextView.setVisibility(View.VISIBLE); - shareButton.setVisibility(View.VISIBLE); - menuItem.hideSubItem(gallery_menu_share); + //shareButton.setVisibility(View.VISIBLE); + //menuItem.hideSubItem(gallery_menu_share); } } + /* private void updateCaptionTextForCurrentPhoto(Object object) { CharSequence caption = null; if (object instanceof MediaController.PhotoEntry) { @@ -1878,7 +1889,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat captionEditText.setFieldText(caption); } } + */ + /* private void closeCaptionEnter(boolean apply) { Object object = imagesArrLocals.get(currentIndex); if (apply) { @@ -1926,6 +1939,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat captionEditText.closeKeyboard(); } } + */ private void showAlertDialog(AlertDialog.Builder builder) { if (parentActivity == null) { @@ -2075,9 +2089,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(pickerView, "translationY", 0)); arrayList.add(ObjectAnimator.ofFloat(actionBar, "translationY", 0)); - if (needCaptionLayout) { + /*if (needCaptionLayout) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "translationY", 0)); - } + }*/ if (sendPhotoType == 0) { arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", 1)); } @@ -2088,9 +2102,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public void onAnimationStart(Animator animation) { pickerView.setVisibility(View.VISIBLE); actionBar.setVisibility(View.VISIBLE); - if (needCaptionLayout) { + /*if (needCaptionLayout) { captionTextView.setVisibility(captionTextView.getTag() != null ? View.VISIBLE : View.INVISIBLE); - } + }*/ if (sendPhotoType == 0) { checkImageView.setVisibility(View.VISIBLE); } @@ -2130,9 +2144,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(96))); arrayList.add(ObjectAnimator.ofFloat(actionBar, "translationY", 0, -actionBar.getHeight())); - if (needCaptionLayout) { + /*if (needCaptionLayout) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "translationY", 0, AndroidUtilities.dp(96))); - } + }*/ if (sendPhotoType == 0) { arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", 1, 0)); } @@ -2144,9 +2158,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat changeModeAnimation = null; pickerView.setVisibility(View.GONE); actionBar.setVisibility(View.GONE); - if (needCaptionLayout) { + /*if (needCaptionLayout) { captionTextView.setVisibility(View.INVISIBLE); - } + }*/ if (sendPhotoType == 0) { checkImageView.setVisibility(View.GONE); } @@ -2243,9 +2257,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(pickerView, "translationY", 0, AndroidUtilities.dp(96))); arrayList.add(ObjectAnimator.ofFloat(actionBar, "translationY", 0, -actionBar.getHeight())); - if (needCaptionLayout) { + /*if (needCaptionLayout) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "translationY", 0, AndroidUtilities.dp(96))); - } + }*/ if (sendPhotoType == 0) { arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", 1, 0)); } @@ -2257,9 +2271,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat changeModeAnimation = null; pickerView.setVisibility(View.GONE); actionBar.setVisibility(View.GONE); - if (needCaptionLayout) { + /*if (needCaptionLayout) { captionTextView.setVisibility(View.INVISIBLE); - } + }*/ if (sendPhotoType == 0) { checkImageView.setVisibility(View.GONE); } @@ -2319,9 +2333,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat AnimatorSet animatorSet = new AnimatorSet(); ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(pickerView, "alpha", show ? 1.0f : 0.0f)); - if (needCaptionLayout) { + /*if (needCaptionLayout) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f)); - } + }*/ if (sendPhotoType == 0) { arrayList.add(ObjectAnimator.ofFloat(checkImageView, "alpha", show ? 1.0f : 0.0f)); } @@ -2335,9 +2349,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar.setVisibility(View.VISIBLE); if (canShowBottom) { bottomLayout.setVisibility(View.VISIBLE); - if (captionTextView.getTag() != null) { + /*if (captionTextView.getTag() != null) { captionTextView.setVisibility(View.VISIBLE); - } + }*/ } } isActionBarVisible = show; @@ -2348,9 +2362,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arrayList = new ArrayList<>(); arrayList.add(ObjectAnimator.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f)); arrayList.add(ObjectAnimator.ofFloat(bottomLayout, "alpha", show ? 1.0f : 0.0f)); - if (captionTextView.getTag() != null) { + /*if (captionTextView.getTag() != null) { arrayList.add(ObjectAnimator.ofFloat(captionTextView, "alpha", show ? 1.0f : 0.0f)); - } + }*/ currentActionBarAnimation = new AnimatorSet(); currentActionBarAnimation.playTogether(arrayList); if (!show) { @@ -2361,9 +2375,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat actionBar.setVisibility(View.GONE); if (canShowBottom) { bottomLayout.setVisibility(View.GONE); - if (captionTextView.getTag() != null) { + /*if (captionTextView.getTag() != null) { captionTextView.setVisibility(View.INVISIBLE); - } + }*/ } currentActionBarAnimation = null; } @@ -2376,16 +2390,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else { actionBar.setAlpha(show ? 1.0f : 0.0f); bottomLayout.setAlpha(show ? 1.0f : 0.0f); - if (captionTextView.getTag() != null) { + /*if (captionTextView.getTag() != null) { captionTextView.setAlpha(show ? 1.0f : 0.0f); - } + }*/ if (!show) { actionBar.setVisibility(View.GONE); if (canShowBottom) { bottomLayout.setVisibility(View.GONE); - if (captionTextView.getTag() != null) { + /*if (captionTextView.getTag() != null) { captionTextView.setVisibility(View.INVISIBLE); - } + }*/ } } } @@ -2509,7 +2523,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat endReached[0] = false; endReached[1] = mergeDialogId == 0; opennedFromMedia = false; - needCaptionLayout = false; + //needCaptionLayout = false; canShowBottom = true; imagesArr.clear(); imagesArrLocations.clear(); @@ -2521,14 +2535,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imagesByIdsTemp[a].clear(); } imagesArrTemp.clear(); - currentUserAvatarLocation = null; + //currentUserAvatarLocation = null; containerView.setPadding(0, 0, 0, 0); currentThumb = object != null ? object.thumb : null; menuItem.setVisibility(View.VISIBLE); bottomLayout.setVisibility(View.VISIBLE); - shareButton.setVisibility(View.GONE); + //shareButton.setVisibility(View.GONE); menuItem.hideSubItem(gallery_menu_showall); - menuItem.hideSubItem(gallery_menu_share); + //menuItem.hideSubItem(gallery_menu_share); menuItem.hideSubItem(gallery_menu_openin); actionBar.setTranslationY(0); pickerView.setTranslationY(0); @@ -2538,13 +2552,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat pickerView.setVisibility(View.GONE); cropItem.setVisibility(View.GONE); tuneItem.setVisibility(View.GONE); - captionItem.setVisibility(View.GONE); - captionDoneItem.setVisibility(View.GONE); - captionEditText.setVisibility(View.GONE); + //captionItem.setVisibility(View.GONE); + //captionDoneItem.setVisibility(View.GONE); + //captionEditText.setVisibility(View.GONE); mentionListView.setVisibility(View.GONE); editorDoneLayout.setVisibility(View.GONE); - captionTextView.setTag(null); - captionTextView.setVisibility(View.INVISIBLE); + //captionTextView.setTag(null); + //captionTextView.setVisibility(View.INVISIBLE); if (photoCropView != null) { photoCropView.setVisibility(View.GONE); } @@ -2573,15 +2587,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat imagesArrLocations.add(fileLocation); imagesArrLocationsSizes.add(object.size); avatarsArr.add(new TLRPC.TL_photoEmpty()); - shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); + //shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); menuItem.hideSubItem(gallery_menu_showall); - if (shareButton.getVisibility() == View.VISIBLE) { + /*if (shareButton.getVisibility() == View.VISIBLE) { menuItem.hideSubItem(gallery_menu_share); - } else { + } else*/ { menuItem.showSubItem(gallery_menu_share); } setImageIndex(0, true); - currentUserAvatarLocation = fileLocation; + //currentUserAvatarLocation = fileLocation; } else if (messages != null) { menuItem.showSubItem(gallery_menu_showall); opennedFromMedia = true; @@ -2611,12 +2625,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat mentionsAdapter.setChatInfo(parentChatActivity.info); mentionsAdapter.setNeedUsernames(parentChatActivity.currentChat != null); mentionsAdapter.setNeedBotContext(false); - captionItem.setVisibility(cropItem.getVisibility()); - captionEditText.setVisibility(cropItem.getVisibility()); - needCaptionLayout = captionItem.getVisibility() == View.VISIBLE; - if (needCaptionLayout) { - captionEditText.onCreate(); - } + //captionItem.setVisibility(cropItem.getVisibility()); + //captionEditText.setVisibility(cropItem.getVisibility()); + //needCaptionLayout = captionItem.getVisibility() == View.VISIBLE; + //if (needCaptionLayout) { + // captionEditText.onCreate(); + //} } if (Build.VERSION.SDK_INT >= 16) { tuneItem.setVisibility(cropItem.getVisibility()); @@ -2672,16 +2686,29 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat sameImage = currentMessageObject != null && currentMessageObject.getId() == newMessageObject.getId(); currentMessageObject = newMessageObject; isVideo = currentMessageObject.isVideo(); + + /* if (currentMessageObject.canDeleteMessage(null)) { menuItem.showSubItem(gallery_menu_delete); } else { menuItem.hideSubItem(gallery_menu_delete); } + */ + if (isVideo && Build.VERSION.SDK_INT >= 16) { menuItem.showSubItem(gallery_menu_openin); } else { menuItem.hideSubItem(gallery_menu_openin); } + + if( currentMessageObject!=null && currentMessageObject.messageOwner!=null ) + { + long hContact = MrMailbox.MrMailboxGetContactById(MrMailbox.hMailbox, currentMessageObject.messageOwner.from_id); + nameTextView.setText(MrMailbox.MrContactGetDisplayName(hContact)); + MrMailbox.MrContactUnref(hContact); + } + + /* if (currentMessageObject.isFromUser()) { TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id); if (user != null) { @@ -2697,6 +2724,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat nameTextView.setText(""); } } + */ + long date = (long) currentMessageObject.messageOwner.date * 1000; String dateString = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))); if (currentFileNames[0] != null && isVideo) { @@ -2705,7 +2734,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat dateTextView.setText(dateString); } CharSequence caption = currentMessageObject.caption; - setCurrentCaption(caption); + //setCurrentCaption(caption); if (currentAnimation != null) { menuItem.hideSubItem(gallery_menu_save); @@ -2713,7 +2742,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (!currentMessageObject.canDeleteMessage(null)) { menuItem.setVisibility(View.GONE); } - shareButton.setVisibility(View.VISIBLE); + //shareButton.setVisibility(View.VISIBLE); actionBar.setTitle(LocaleController.getString("AttachGif", R.string.AttachGif)); } else { if (totalImagesCount + totalImagesCountMerge != 0 && !needSearchImageInArr) { @@ -2757,14 +2786,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } if (currentMessageObject.messageOwner.ttl != 0) { menuItem.hideSubItem(gallery_menu_save); - shareButton.setVisibility(View.GONE); + //shareButton.setVisibility(View.GONE); menuItem.hideSubItem(gallery_menu_share); } else { menuItem.showSubItem(gallery_menu_save); - shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); - if (shareButton.getVisibility() == View.VISIBLE) { + //shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); + /*if (shareButton.getVisibility() == View.VISIBLE) { menuItem.hideSubItem(gallery_menu_share); - } else { + } else*/ { menuItem.showSubItem(gallery_menu_share); } } @@ -2772,11 +2801,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } else if (!imagesArrLocations.isEmpty()) { nameTextView.setText(""); dateTextView.setText(""); + /* if (avatarsDialogId == UserConfig.getClientUserId() && !avatarsArr.isEmpty()) { menuItem.showSubItem(gallery_menu_delete); } else { menuItem.hideSubItem(gallery_menu_delete); } + */ TLRPC.FileLocation old = currentFileLocation; if (index < 0 || index >= imagesArrLocations.size()) { closePhoto(false, false); @@ -2788,10 +2819,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, imagesArrLocations.size())); menuItem.showSubItem(gallery_menu_save); - shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); - if (shareButton.getVisibility() == View.VISIBLE) { + //shareButton.setVisibility(videoPlayerControlFrameLayout == null || videoPlayerControlFrameLayout.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE); + /*if (shareButton.getVisibility() == View.VISIBLE) { menuItem.hideSubItem(gallery_menu_share); - } else { + } else*/ { menuItem.showSubItem(gallery_menu_share); } } else if (!imagesArrLocals.isEmpty()) { @@ -2824,8 +2855,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat checkImageView.setChecked(placeProvider.isPhotoChecked(currentIndex), false); } - setCurrentCaption(caption); - updateCaptionTextForCurrentPhoto(object); + //setCurrentCaption(caption); + //updateCaptionTextForCurrentPhoto(object); } @@ -2918,6 +2949,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } + /* private void setCurrentCaption(final CharSequence caption) { if (caption != null && caption.length() > 0) { captionTextView = captionTextViewOld; @@ -2943,6 +2975,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat captionTextView.setVisibility(View.INVISIBLE); } } + */ private void checkProgress(int a, boolean animated) { if (currentFileNames[a] != null) { @@ -3399,12 +3432,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (parentActivity == null || !isVisible || checkAnimation() || placeProvider == null) { return; } + /* if (captionEditText.hideActionMode() && !fromEditMode) { return; } + */ releasePlayer(); - captionEditText.onDestroy(); + //captionEditText.onDestroy(); parentChatActivity = null; NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded); @@ -3604,9 +3639,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } catch (Exception e) { FileLog.e("tmessages", e); } - if (captionEditText != null) { + /*if (captionEditText != null) { captionEditText.onDestroy(); - } + }*/ Instance = null; } @@ -3676,9 +3711,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat closePhoto(false, false); return; } - if (captionDoneItem.getVisibility() != View.GONE) { - closeCaptionEnter(true); - } + //if (captionDoneItem.getVisibility() != View.GONE) { + // closeCaptionEnter(true); + //} } public boolean isVisible() { @@ -3770,9 +3805,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } } - if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) { + /*if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) { return true; - } + }*/ if (currentEditMode == 0 && ev.getPointerCount() == 1 && gestureDetector.onTouchEvent(ev)) { if (doubleTap) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java deleted file mode 100644 index 989fc2ac8..000000000 --- a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * This is the source code of Telegram for Android v. 3.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-2016. - */ - -package org.telegram.ui; - -import android.app.Activity; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.PixelFormat; -import android.graphics.RectF; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.text.Layout; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.text.TextUtils; -import android.util.SparseArray; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.view.WindowManager; -import android.widget.FrameLayout; - -import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ImageLoader; -import org.telegram.messenger.ImageReceiver; -import org.telegram.messenger.MessageObject; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.FileLoader; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; -import org.telegram.tgnet.ConnectionsManager; -import org.telegram.tgnet.TLRPC; -import org.telegram.ui.Components.LayoutHelper; - -import java.io.File; -import java.util.ArrayList; - -public class SecretPhotoViewer implements NotificationCenter.NotificationCenterDelegate { - - private class FrameLayoutDrawer extends FrameLayout { - public FrameLayoutDrawer(Context context) { - super(context); - setWillNotDraw(false); - } - - @Override - protected void onDraw(Canvas canvas) { - getInstance().onDraw(canvas); - } - } - - private class SecretDeleteTimer extends FrameLayout { - private String currentInfoString; - private int infoWidth; - private TextPaint infoPaint = null; - private StaticLayout infoLayout = null; - private Paint deleteProgressPaint; - private RectF deleteProgressRect = new RectF(); - private Drawable drawable = null; - - public SecretDeleteTimer(Context context) { - super(context); - setWillNotDraw(false); - - infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - infoPaint.setTextSize(AndroidUtilities.dp(15)); - infoPaint.setColor(0xffffffff); - - deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG); - deleteProgressPaint.setColor(0xffe6e6e6); - - drawable = getResources().getDrawable(R.drawable.circle1); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - deleteProgressRect.set(getMeasuredWidth() - AndroidUtilities.dp(30), AndroidUtilities.dp(2), getMeasuredWidth() - AndroidUtilities.dp(2), AndroidUtilities.dp(30)); - } - - @Override - protected void onDraw(Canvas canvas) { - if (currentMessageObject == null || currentMessageObject.messageOwner.destroyTime == 0) { - return; - } - - if (drawable != null) { - drawable.setBounds(getMeasuredWidth() - AndroidUtilities.dp(32), 0, getMeasuredWidth(), AndroidUtilities.dp(32)); - drawable.draw(canvas); - } - - long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance().getTimeDifference() * 1000; - float progress = Math.max(0, (long)currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f); - canvas.drawArc(deleteProgressRect, -90, -360 * progress, true, deleteProgressPaint); - if (progress != 0) { - int offset = AndroidUtilities.dp(2); - invalidate((int)deleteProgressRect.left - offset, (int)deleteProgressRect.top - offset, (int)deleteProgressRect.right + offset * 2, (int)deleteProgressRect.bottom + offset * 2); - } - //updateSecretTimeText(); - - if (infoLayout != null) { - canvas.save(); - canvas.translate(getMeasuredWidth() - AndroidUtilities.dp(38) - infoWidth, AndroidUtilities.dp(7)); - infoLayout.draw(canvas); - canvas.restore(); - } - } - } - - private Activity parentActivity; - private WindowManager.LayoutParams windowLayoutParams; - private FrameLayout windowView; - private FrameLayoutDrawer containerView; - private ImageReceiver centerImage = new ImageReceiver(); - private SecretDeleteTimer secretDeleteTimer; - private boolean isVisible = false; - - private MessageObject currentMessageObject = null; - - private static volatile SecretPhotoViewer Instance = null; - public static SecretPhotoViewer getInstance() { - SecretPhotoViewer localInstance = Instance; - if (localInstance == null) { - synchronized (PhotoViewer.class) { - localInstance = Instance; - if (localInstance == null) { - Instance = localInstance = new SecretPhotoViewer(); - } - } - } - return localInstance; - } - - @SuppressWarnings("unchecked") - @Override - public void didReceivedNotification(int id, Object... args) { - if (id == NotificationCenter.messagesDeleted) { - if (currentMessageObject == null) { - return; - } - int channelId = (Integer) args[1]; - if (channelId != 0) { - return; - } - ArrayList markAsDeletedMessages = (ArrayList)args[0]; - if (markAsDeletedMessages.contains(currentMessageObject.getId())) { - closePhoto(); - } - } else if (id == NotificationCenter.didCreatedNewDeleteTask) { - if (currentMessageObject == null || secretDeleteTimer == null) { - return; - } - SparseArray> mids = (SparseArray>)args[0]; - for(int i = 0; i < mids.size(); i++) { - int key = mids.keyAt(i); - ArrayList arr = mids.get(key); - for (Integer mid : arr) { - if (currentMessageObject.getId() == mid) { - currentMessageObject.messageOwner.destroyTime = key; - secretDeleteTimer.invalidate(); - return; - } - } - } - } - } - - public void setParentActivity(Activity activity) { - if (parentActivity == activity) { - return; - } - parentActivity = activity; - - windowView = new FrameLayout(activity); - windowView.setBackgroundColor(0xff000000); - windowView.setFocusable(true); - windowView.setFocusableInTouchMode(true); - if (Build.VERSION.SDK_INT >= 23) { - windowView.setFitsSystemWindows(true); - } - - containerView = new FrameLayoutDrawer(activity); - containerView.setFocusable(false); - windowView.addView(containerView); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)containerView.getLayoutParams(); - layoutParams.width = LayoutHelper.MATCH_PARENT; - layoutParams.height = LayoutHelper.MATCH_PARENT; - layoutParams.gravity = Gravity.TOP | Gravity.LEFT; - containerView.setLayoutParams(layoutParams); - containerView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { - closePhoto(); - } - return true; - } - }); - - secretDeleteTimer = new SecretDeleteTimer(activity); - containerView.addView(secretDeleteTimer); - layoutParams = (FrameLayout.LayoutParams)secretDeleteTimer.getLayoutParams(); - layoutParams.gravity = Gravity.TOP | Gravity.RIGHT; - layoutParams.width = AndroidUtilities.dp(100); - layoutParams.height = AndroidUtilities.dp(32); - layoutParams.rightMargin = AndroidUtilities.dp(19); - layoutParams.topMargin = AndroidUtilities.dp(19); - secretDeleteTimer.setLayoutParams(layoutParams); - - windowLayoutParams = new WindowManager.LayoutParams(); - windowLayoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; - windowLayoutParams.format = PixelFormat.TRANSLUCENT; - windowLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; - windowLayoutParams.gravity = Gravity.TOP; - windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; - windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; - - centerImage.setParentView(containerView); - } - - public void openPhoto(MessageObject messageObject) { - if (parentActivity == null || messageObject == null || messageObject.messageOwner.media == null || messageObject.messageOwner.media.photo == null) { - return; - } - - NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesDeleted); - NotificationCenter.getInstance().addObserver(this, NotificationCenter.didCreatedNewDeleteTask); - - TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); - int size = sizeFull.size; - if (size == 0) { - size = -1; - } - BitmapDrawable drawable = ImageLoader.getInstance().getImageFromMemory(sizeFull.location, null, null); - if (drawable == null) { - File file = FileLoader.getPathToAttach(sizeFull); - Bitmap bitmap = null; - BitmapFactory.Options options = null; - if (Build.VERSION.SDK_INT < 21) { - options = new BitmapFactory.Options(); - options.inDither = true; - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - options.inPurgeable = true; - options.inSampleSize = 1; - options.inMutable = true; - } - try { - bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options); - } catch (Throwable e) { - FileLog.e("tmessages", e); - } - if (bitmap != null) { - drawable = new BitmapDrawable(bitmap); - ImageLoader.getInstance().putImageToCache(drawable, sizeFull.location.volume_id + "_" + sizeFull.location.local_id); - } - } - if (drawable != null) { - centerImage.setImageBitmap(drawable); - } else { - centerImage.setImage(sizeFull.location, null, null, size, null, false); - } - - currentMessageObject = messageObject; - - AndroidUtilities.lockOrientation(parentActivity); - - try { - if (windowView.getParent() != null) { - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); - wm.removeView(windowView); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); - wm.addView(windowView, windowLayoutParams); - secretDeleteTimer.invalidate(); - isVisible = true; - } - - public boolean isVisible() { - return isVisible; - } - - public void closePhoto() { - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask); - if (parentActivity == null) { - return; - } - currentMessageObject = null; - isVisible = false; - AndroidUtilities.unlockOrientation(parentActivity); - AndroidUtilities.runOnUIThread(new Runnable() { - @Override - public void run() { - centerImage.setImageBitmap((Bitmap)null); - } - }); - try { - if (windowView.getParent() != null) { - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); - wm.removeView(windowView); - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - - public void destroyPhotoViewer() { - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted); - NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask); - isVisible = false; - currentMessageObject = null; - if (parentActivity == null || windowView == null) { - return; - } - try { - if (windowView.getParent() != null) { - WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); - wm.removeViewImmediate(windowView); - } - windowView = null; - } catch (Exception e) { - FileLog.e("tmessages", e); - } - Instance = null; - } - - private void onDraw(Canvas canvas) { - canvas.save(); - canvas.translate(containerView.getWidth() / 2, containerView.getHeight() / 2); - Bitmap bitmap = centerImage.getBitmap(); - if (bitmap != null) { - int bitmapWidth = bitmap.getWidth(); - int bitmapHeight = bitmap.getHeight(); - - float scaleX = (float) containerView.getWidth() / (float) bitmapWidth; - float scaleY = (float) containerView.getHeight() / (float) bitmapHeight; - float scale = scaleX > scaleY ? scaleY : scaleX; - int width = (int) (bitmapWidth * scale); - int height = (int) (bitmapHeight * scale); - - centerImage.setImageCoords(-width / 2, -height / 2, width, height); - centerImage.draw(canvas); - } - canvas.restore(); - } -} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index da885b121..be2e87892 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -121,7 +121,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private int supportSectionRow; private int supportSectionRow2; private int askQuestionRow; - private int telegramFaqRow; + private int helpRow; private int privacyPolicyRow; private int sendLogsRow; private int clearLogsRow; @@ -231,7 +231,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter mobileDownloadRow = -1;//rowCount++; wifiDownloadRow = -1;//rowCount++; roamingDownloadRow = -1;//rowCount++; - saveToGalleryRow = rowCount++; + saveToGalleryRow = -1;//rowCount++; -- for now, we do not use this option, this results in confusing folders ("AppName" and "AppName Images" etc.); instead, for now, the user can use the option to manually save a media cacheRow = rowCount++; messagesSectionRow = rowCount++; @@ -251,7 +251,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter supportSectionRow = rowCount++; supportSectionRow2 = rowCount++; askQuestionRow = -1; // EDIT BY MR -- rowCount++; - telegramFaqRow = rowCount++; + helpRow = rowCount++; privacyPolicyRow = -1; // EDIT BY MR -- rowCount++; sendLogsRow = -1; // EDIT BY MR clearLogsRow = -1; // EDIT BY MR @@ -513,11 +513,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); */ - } else if (i == telegramFaqRow) { - /* EDIT BY MR - Browser.openUrl(getParentActivity(), LocaleController.getString("TelegramFaqUrl", R.string.TelegramFaqUrl)); - */ - // EDIT BY MR + } else if (i == helpRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName) + " " + getVersion()); builder.setMessage(MrMailbox.MrMailboxGetInfo(MrMailbox.hMailbox)+" Frontend based upon Telegram for Android."); @@ -528,7 +524,6 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } }); showDialog(builder.create()); - // /EDIT BY MR } else if (i == privacyPolicyRow) { /* EDIT BY MR @@ -1271,7 +1266,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow || i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == autoplayGifsRow || i == privacyRow || i == wifiDownloadRow || i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow || - i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow || + i == switchBackendButtonRow || i == helpRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow || i == stickersRow || i == cacheRow || i == raiseToSpeakRow || i == privacyPolicyRow || i == customTabsRow || i == directShareRow || i == versionRow; } @@ -1356,7 +1351,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter textCell.setText(LocaleController.getString("PrivacySettings", R.string.PrivacySettings), true); } else if (i == switchBackendButtonRow) { textCell.setText("Switch Backend", true); - } else if (i == telegramFaqRow) { + } else if (i == helpRow) { textCell.setText(LocaleController.getString("AboutThisProgram", R.string.AboutThisProgram), true); } else if (i == contactsReimportRow) { textCell.setText(LocaleController.getString("ImportContacts", R.string.ImportContacts), true); @@ -1551,7 +1546,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter return 1; } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == autoplayGifsRow || i == raiseToSpeakRow || i == customTabsRow || i == directShareRow) { return 3; - } else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow || i == stickersRow || i == cacheRow || i == privacyPolicyRow) { + } else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == switchBackendButtonRow || i == helpRow || i == contactsReimportRow || i == textSizeRow || i == languageRow || i == contactsSortRow || i == stickersRow || i == cacheRow || i == privacyPolicyRow) { return 2; } else if (i == versionRow) { return 5; diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 507e2b7ca..744e462cc 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -507,8 +507,6 @@ Aus Linear Radial - Möchtest du wirklich dieses Bild löschen? - Möchtest du wirklich dieses Video löschen? Änderungen verwerfen? Suchverlauf löschen? Löschen @@ -820,8 +818,7 @@ MMMM yyyy dd MMM - dd.MM.yy - dd.MM.yyyy + dd.MM.yyyy d MMMM d MMMM, yyyy EEE @@ -868,5 +865,5 @@ Ein Klick auf die Antwort-Pfeile startet einen Chat. Diese Funktion ist in dieser Version noch nicht eingebaut. Mit meinem Delta Chat Messenger gesendet - Kurznachricht + Sofortnachricht diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index e2148009e..12f34ef80 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -508,8 +508,6 @@ Apagado Lineal Radial - ¿Quieres eliminar esta foto? - ¿Quieres eliminar este vídeo? ¿Descartar cambios? ¿Quieres borrar el historial de búsqueda? Borrar @@ -821,8 +819,7 @@ MMMM \'de\' yyyy dd \'de\' MMM - dd.MM.yy - dd.MM.yyyy + dd.MM.yyyy d \'de\' MMMM d \'de\' MMMM \'de\' yyyy EEE diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index fe0b5fbdf..8e1faab0a 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -508,8 +508,6 @@ No Lineare Radiale - Sei sicuro di voler eliminare questa foto? - Sei sicuro di voler eliminare questo video? Annullare le modifiche? Cancellare la cronologia di ricerca? Cancella @@ -821,8 +819,7 @@ MMMM yyyy dd MMM - dd.MM.yy - dd.MM.yyyy + dd.MM.yyyy d MMMM d MMMM, yyyy EEE diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index 76fffa3d5..c3f2be8b2 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -508,8 +508,6 @@ Uit Lineair Radiaal - Foto echt verwijderen? - Video echt verwijderen? Wijzigingen negeren? Zoekgeschiedenis wissen? Wissen @@ -821,8 +819,7 @@ MMMM yyyy dd MMM - dd-MM-yy - dd-MM-yyyy + dd-MM-yyyy d MMMM d MMMM yyyy EEE diff --git a/TMessagesProj/src/main/res/values-pt/strings.xml b/TMessagesProj/src/main/res/values-pt/strings.xml index 894119c7d..25a08da93 100644 --- a/TMessagesProj/src/main/res/values-pt/strings.xml +++ b/TMessagesProj/src/main/res/values-pt/strings.xml @@ -508,8 +508,6 @@ Desativado Linear Radial - Você tem certeza que deseja apagar esta foto? - Você tem certeza que deseja apagar este vídeo? Descartar mudanças? Limpar histórico de busca? Limpar @@ -821,8 +819,7 @@ MMMM yyyy dd MMM - dd.MM.yy - dd.MM.yyyy + dd.MM.yyyy d MMMM d MMMM, yyyy EEE diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index fa2bc9e56..68d02e91c 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -508,8 +508,6 @@ Off Linear Radial - Are you sure you want to delete this photo? - Are you sure you want to delete this video? Discard changes? Clear search history? Clear @@ -822,8 +820,7 @@ MMMM yyyy MMM dd - dd.MM.yy - dd.MM.yyyy + dd.MM.yyyy MMMM d MMMM d, yyyy EEE @@ -869,5 +866,5 @@ This function is not yet available in this version. Cannot load file. Sent with my Delta Chat Messenger - Short message + Instant message