Compare commits

...

81 Commits

Author SHA1 Message Date
B. Petersen 95786d1268 Update messenger-backend submodule. 2017-11-15 22:41:49 +01:00
B. Petersen cfc69e483e Changelog 2017-11-15 22:33:50 +01:00
B. Petersen 73b59ed4bf Adapt to new synchronous configure function. 2017-11-15 22:28:55 +01:00
B. Petersen e8a996d1f3 Update messenger-backend submodule. 2017-11-15 14:03:54 +01:00
B. Petersen c04ba91b50 Adapt to new blobdir API. 2017-11-15 13:43:07 +01:00
B. Petersen d763be42a1 Adapt to new MR_EVENT_IS_OFFLINE 2017-11-15 13:08:08 +01:00
B. Petersen 10d01b0d68 Adapt configure progress indicator. 2017-11-15 09:45:19 +01:00
B. Petersen 7699c5e63f Bump version 2017-11-14 22:21:34 +01:00
B. Petersen 78a033a221 Changelog 2017-11-14 22:15:08 +01:00
B. Petersen 7f23570160 Update messenger-backend submodule. 2017-11-14 22:10:01 +01:00
B. Petersen a9e1dd7e38 Update messenger-backend submodule. 2017-11-14 20:39:04 +01:00
B. Petersen 058f13f9d8 Show 'Leave groups' menu entry only in groups. 2017-11-14 16:53:25 +01:00
B. Petersen 515fb92873 Update messenger-backend submodule. 2017-11-13 19:25:30 +01:00
B. Petersen abac76125c Adapt to new API. 2017-11-13 19:25:15 +01:00
B. Petersen 149df4e3d7 Adapt to new API. 2017-11-12 23:19:47 +01:00
B. Petersen 0a4796e959 Update messenger-backend submodule. 2017-11-11 12:46:33 +01:00
B. Petersen e79b6d9b1d Adapt to core changes. 2017-11-10 17:18:27 +01:00
B. Petersen af471f4cf8 Adapt getFreshMsgCount() to new core. 2017-11-10 12:25:33 +01:00
B. Petersen 1c97c2e408 Sending messages via MrMailbox instead of MrChat. 2017-11-10 10:54:47 +01:00
B. Petersen 2c34aa83c3 Set os name. 2017-11-07 15:55:06 +01:00
B. Petersen bf93a9e54b Remove mrosnative.c from JNI-wrapper. 2017-11-06 11:30:16 +01:00
B. Petersen c7c3990283 Update messenger-backend submodule. 2017-11-02 23:04:01 +01:00
B. Petersen e4454044f6 Dismissing the contact request popup only marks the messages from the contact in scope as being noticed. 2017-11-02 23:03:15 +01:00
B. Petersen f6ad0f2ee5 Print system messages different from normal messages. 2017-11-02 22:46:31 +01:00
B. Petersen 9abf23073d Add option to block a contact message box that opens when the contact request popup is clicked. 2017-11-02 22:34:04 +01:00
B. Petersen 66253123ad Delete chats directly from the chatlist. Update global search if messages or chats are deleted. 2017-11-02 19:16:19 +01:00
B. Petersen 920a683e9b Do not implicitly leave groups, do not send leave-messages unexpectedly. 2017-11-02 18:20:35 +01:00
B. Petersen a0ce2b5dea Archive chats from chats menu. 2017-11-01 18:27:48 +01:00
B. Petersen be1e1fa3c1 Show 'archived chats' title. 2017-11-01 15:38:29 +01:00
B. Petersen 0a925f8f51 Draw 'Archived' flag. 2017-11-01 14:21:35 +01:00
B. Petersen 2db619e263 Remove dead code. 2017-11-01 13:46:24 +01:00
B. Petersen e75e9410d6 Remove dead code. 2017-11-01 13:37:52 +01:00
B. Petersen bbc09af77b No floating button in archive list. 2017-11-01 13:33:44 +01:00
B. Petersen e3d3f13bef Show archived chats. 2017-11-01 13:13:56 +01:00
B. Petersen affe4ca82e Get rid of global chatlist. 2017-11-01 13:07:17 +01:00
B. Petersen 3b9a2e2d6d Haptical feedback on chatlist longpress. 2017-11-01 07:54:34 +01:00
B. Petersen dff6fedb67 Add option to (un-)archive threads. 2017-10-31 22:05:25 +01:00
B. Petersen 9615a47f03 Possibility to start a chat directly from the deaddrop popup. 2017-10-31 02:54:02 +01:00
B. Petersen 87ae709add Remove dead code. 2017-10-30 09:56:25 +01:00
B. Petersen 80ecd1f697 Update German and Italian translations. 2017-10-29 22:26:08 +01:00
B. Petersen 481b5816b1 Add the deaddrop temporary to the chatlist on new messages from unknown contacts. 2017-10-28 19:33:14 +02:00
B. Petersen 97da31ae2d Init notifications for deaddrop. 2017-10-28 18:37:32 +02:00
B. Petersen 48684bded4 Check vector drawable support on KitKat, see https://stackoverflow.com/questions/37892573/android-vector-drawables-in-support-library-v24-0-0 - seems to work :) 2017-10-28 17:06:54 +02:00
B. Petersen b191ad8b84 Simplify chatlist cell. 2017-10-28 16:52:31 +02:00
B. Petersen 363fa04dca Typo 2017-10-28 16:24:36 +02:00
B. Petersen e8c11aef6e Add Turkish translation. 2017-10-28 16:08:15 +02:00
B. Petersen d0df88b113 Use standard SimpleDateFormat class. 2017-10-28 15:51:11 +02:00
B. Petersen 477f3e638c Use native NumberPicker. 2017-10-28 12:39:47 +02:00
B. Petersen 478e093783 Rework deaddrop line in chatlist. 2017-10-26 22:11:26 +02:00
B. Petersen a7c13e83c9 Refactor Dialogs->Chatlist, prepare showing deaddrop temporary in chatlist. 2017-10-26 18:49:07 +02:00
B. Petersen e9e1db7773 Add Norwegian Bokmål translation and Tamil translations, update Catalan, German, French, Italian, Korean, Dutch, Polish, Portuguese, Russian, Telugu and Ukrainian translations. 2017-10-26 17:02:22 +02:00
B. Petersen f1a2268712 Update messenger-backend submodule. 2017-10-25 21:05:39 +02:00
Björn Petersen d28394d59e Merge pull request #192 from comradekingu/patch-2
linux → Linux, etc
2017-10-25 20:55:11 +02:00
B. Petersen aa5d6d289a Typo 2017-10-25 20:34:26 +02:00
Allan Nordhøy 36f56d557d linux → Linux, etc 2017-10-25 19:22:27 +02:00
B. Petersen e8dcd05f79 Do not show the padlock if end-to-end-encryption is disabled by the user, fixes #190. 2017-10-25 01:49:34 +02:00
B. Petersen b29a50304c Show more detailed reasons about failed end-to-end-encryptions. 2017-10-25 00:23:24 +02:00
B. Petersen 61355499f4 Wording. 2017-10-24 16:23:13 +02:00
B. Petersen 05fd267cb8 Cleanup 2017-10-23 20:26:52 +02:00
B. Petersen 440e3d8a61 Cleanup 2017-10-23 20:24:43 +02:00
B. Petersen ab82ed53e5 Cleanup. 2017-10-23 19:34:03 +02:00
B. Petersen 151c4426ec Update recent emoji view directly; if the recent emoji list is empty, show the first smilies page. 2017-10-23 01:11:01 +02:00
B. Petersen 3c87751491 Rework Emoji code. 2017-10-22 18:03:38 +02:00
B. Petersen 9f93cb8bd8 Rework Emoji code. 2017-10-22 17:53:15 +02:00
B. Petersen 5bf9311371 Cleanup emoji code. 2017-10-22 16:39:56 +02:00
B. Petersen 45fede3a02 Merge com.b44t.messenger and com.b44t.ui. 2017-10-22 13:31:11 +02:00
B. Petersen addadf9634 Cleanup AOSP. 2017-10-22 02:57:52 +02:00
B. Petersen 520a7a6e9e Cleanup 2017-10-22 01:08:17 +02:00
B. Petersen 65eb204ddc Refactor Emoji views. 2017-10-21 19:59:11 +02:00
B. Petersen 6eee460532 Rename Settings*Activity to what they are, a Settings*Fragment. 2017-10-21 17:57:00 +02:00
B. Petersen c85fa85290 Show messages only for explicitly wanted chats. 2017-10-21 02:42:28 +02:00
B. Petersen 39324c6f73 Add copy-to-clipboard function for 'About / Info'. 2017-10-21 01:29:58 +02:00
B. Petersen 9702286e59 Wording (not sure when we parse the status and really show it in the profiles; so we just lower the expectations). 2017-10-18 17:15:19 +02:00
B. Petersen 512acd9fc3 Bump version 2017-10-18 13:44:20 +02:00
B. Petersen 930facc457 Changelog. 2017-10-18 13:27:08 +02:00
B. Petersen 5a428458b5 Show correct export/import done hints. 2017-10-14 16:25:49 +02:00
B. Petersen fa12c90f23 Re-create symbolic links when updating deltachat-core. 2017-10-14 16:00:40 +02:00
B. Petersen 2e16ccb041 Changelog 2017-10-14 02:38:17 +02:00
B. Petersen df7dda0e96 Update messenger-backend submodule. 2017-10-14 02:37:04 +02:00
B. Petersen 28c86b4784 Simplify some AlertDialog.Builder calls. 2017-10-09 17:40:19 +02:00
B. Petersen 175a4ddf95 Bump version. 2017-10-09 16:17:10 +02:00
247 changed files with 3181 additions and 13152 deletions
+29
View File
@@ -1,5 +1,34 @@
# Delta Chat Changelog
## v0.9.8
2017-11-15
* Fix a bug that avoids chat creation under some circumstances (bug introduced in 0.9.7)
## v0.9.7
2017-11-14
* Archive chats or delete chats by a long press
* Notify the user in the chatlist about contact requests of known users or of other Delta Chat clients
* Show messages only for explicitly wanted chats
* Show more detailed reasons about failed end-to-end-encryptions
* Explicit option to leave a group
* Do not show the padlock if end-to-end-encryption is disabled by the user
* Also import images from a backup when using a different device with different paths
* Add copy-to-clipboard function for "About / Info"
* Rework Emoji-code
* Add Norwegian Bokmål translation
* Add Tamil translation
* Add Turkish translation
* Update Catalan, German, French, Italian, Korean, Dutch, Polish, Portuguese, Russian, Telugu and Ukrainian translations
## v0.9.6
2017-10-18
* Support keys generated with multiple subkeys eg. from K-9
* Show PDFs and other attachments with bad names
* Bug fixes
## v0.9.5
2017-10-08
+2 -2
View File
@@ -79,7 +79,7 @@ android {
}
}
defaultConfig.versionCode = 44
defaultConfig.versionCode = 47
sourceSets.main {
jniLibs.srcDir 'libs'
@@ -121,6 +121,6 @@ android {
minSdkVersion 14 // 14: Android 4.0 Ice Cream Sandwich 2011 (Telegram default), 21: Android 5.0 Lollipop 2014 (recommended for InstantRun)
targetSdkVersion 25 // 25: Nougat. CAVE: Do NOT target "Andoid O" without checking the background tasks carefully, see https://developer.android.com/preview/behavior-changes.html#back-all . As long as we target "Nougat", everything works as expected even for "Andoid O" or later
// in general, we should not change the target without reason; eg. after the switch to Nougat, the camera stops working (see https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en )
versionName "0.9.5" // do NOT forget to increase defaultConfig.versionCode!
versionName "0.9.8" // do NOT forget to increase defaultConfig.versionCode!
}
}
+1 -2
View File
@@ -1635,7 +1635,6 @@ LOCAL_SRC_FILES += \
./messenger-backend/src/mrapeerstate.c \
./messenger-backend/src/mrchat.c \
./messenger-backend/src/mrchatlist.c \
./messenger-backend/src/mrcmdline.c \
./messenger-backend/src/mrcontact.c \
./messenger-backend/src/mrdehtml.c \
./messenger-backend/src/mrimap.c \
@@ -1652,7 +1651,6 @@ LOCAL_SRC_FILES += \
./messenger-backend/src/mrmimefactory.c \
./messenger-backend/src/mrmimeparser.c \
./messenger-backend/src/mrmsg.c \
./messenger-backend/src/mrosnative.c \
./messenger-backend/src/mrparam.c \
./messenger-backend/src/mrpgp.c \
./messenger-backend/src/mrpoortext.c \
@@ -1662,6 +1660,7 @@ LOCAL_SRC_FILES += \
./messenger-backend/src/mrsqlite3.c \
./messenger-backend/src/mrstock.c \
./messenger-backend/src/mrtools.c \
./messenger-backend/cmdline/cmdline.c \
./mrwrapper.c
include $(BUILD_SHARED_LIBRARY)
+94 -66
View File
@@ -28,6 +28,7 @@
#include <jni.h>
#include <android/log.h>
#include "messenger-backend/src/mrmailbox.h"
#include "messenger-backend/cmdline/cmdline.h"
#define CHAR_REF(a) \
@@ -223,7 +224,7 @@ static uintptr_t s_mailbox_callback_(mrmailbox_t* mailbox, int event, uintptr_t
JNIEXPORT jlong Java_com_b44t_messenger_MrMailbox_MrMailboxNew(JNIEnv *env, jclass c)
{
s_init_globals(env, c);
return (jlong)mrmailbox_new(s_mailbox_callback_, NULL);
return (jlong)mrmailbox_new(s_mailbox_callback_, NULL, "Android");
}
@@ -246,14 +247,14 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_close(JNIEnv *env, jclass cls)
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getBlobdir(JNIEnv *env, jclass cls)
{
mrmailbox_t* ths = get_mrmailbox_t(env, cls);
return JSTRING_NEW((ths&&ths->m_blobdir)? ths->m_blobdir : NULL);
mrmailbox_t* ths = get_mrmailbox_t(env, cls); if( ths == NULL ) { return JSTRING_NEW(NULL); }
return JSTRING_NEW(ths->m_blobdir);
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_configureAndConnect(JNIEnv *env, jclass cls)
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_configureAndConnect(JNIEnv *env, jclass cls)
{
mrmailbox_configure_and_connect(get_mrmailbox_t(env, cls));
return (jint)mrmailbox_configure_and_connect(get_mrmailbox_t(env, cls));
}
@@ -322,9 +323,9 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxCreateContact(JNIEnv *
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxBlockContact(JNIEnv *env, jclass c, jlong hMailbox, jint contact_id, jint block)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_MrMailboxBlockContact(JNIEnv *env, jclass c, jlong hMailbox, jint contact_id, jint block)
{
return (jint)mrmailbox_block_contact((mrmailbox_t*)hMailbox, contact_id, block);
mrmailbox_block_contact((mrmailbox_t*)hMailbox, contact_id, block);
}
@@ -336,16 +337,16 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_MrMailboxDeleteContact(JNIEnv *
/* MrMailbox - handle chats */
JNIEXPORT jlong Java_com_b44t_messenger_MrMailbox_MrMailboxGetChatlist(JNIEnv *env, jclass c, jlong hMailbox, jstring query)
JNIEXPORT jlong Java_com_b44t_messenger_MrMailbox_MrMailboxGetChatlist(JNIEnv *env, jclass c, jlong hMailbox, jint listflags, jstring query)
{
jlong ret;
if( query ) {
CHAR_REF(query);
ret = (jlong)mrmailbox_get_chatlist((mrmailbox_t*)hMailbox, queryPtr);
ret = (jlong)mrmailbox_get_chatlist((mrmailbox_t*)hMailbox, listflags, queryPtr);
CHAR_UNREF(query);
}
else {
ret = (jlong)mrmailbox_get_chatlist((mrmailbox_t*)hMailbox, NULL);
ret = (jlong)mrmailbox_get_chatlist((mrmailbox_t*)hMailbox, listflags, NULL);
}
return ret;
}
@@ -363,19 +364,30 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_getChatIdByContactId(JNIEnv *en
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_markseenMsgs(JNIEnv *env, jclass cls, jintArray msg_ids)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_markseenMsgs(JNIEnv *env, jclass cls, jintArray msg_ids)
{
int msg_ids_cnt;
const uint32_t* msg_ids_ptr = jintArray2uint32Pointer(env, msg_ids, &msg_ids_cnt);
jint ret = mrmailbox_markseen_msgs(get_mrmailbox_t(env, cls), msg_ids_ptr, msg_ids_cnt);
mrmailbox_markseen_msgs(get_mrmailbox_t(env, cls), msg_ids_ptr, msg_ids_cnt);
free(msg_ids_ptr);
return ret;
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_marknoticedChat(JNIEnv *env, jclass cls, jint chat_id)
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_marknoticedChat(JNIEnv *env, jclass cls, jint chat_id)
{
return (jlong)mrmailbox_marknoticed_chat(get_mrmailbox_t(env, cls), chat_id);
mrmailbox_marknoticed_chat(get_mrmailbox_t(env, cls), chat_id);
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_marknoticedContact(JNIEnv *env, jclass cls, jint contact_id)
{
mrmailbox_marknoticed_contact(get_mrmailbox_t(env, cls), contact_id);
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_archiveChat(JNIEnv *env, jclass cls, jint chat_id, jint archive)
{
mrmailbox_archive_chat(get_mrmailbox_t(env, cls), chat_id, archive);
}
@@ -438,6 +450,13 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_deleteChat(JNIEnv *env, jclass
/* MrMailbox - handle messages */
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_getFreshMsgCount(JNIEnv *env, jclass cls, jint chat_id)
{
return mrmailbox_get_fresh_msg_count(get_mrmailbox_t(env, cls), chat_id);
}
JNIEXPORT jlong Java_com_b44t_messenger_MrMailbox_MrMailboxGetMsg(JNIEnv *env, jclass c, jlong hMailbox, jint id)
{
return (jlong)mrmailbox_get_msg((mrmailbox_t*)hMailbox, id);
@@ -471,6 +490,46 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_forwardMsgs(JNIEnv *env, jclass
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_sendTextMsg(JNIEnv *env, jclass cls, jint chat_id, jstring text)
{
CHAR_REF(text);
jint msg_id = mrmailbox_send_text_msg(get_mrmailbox_t(env, cls), chat_id, textPtr);
CHAR_UNREF(text);
return msg_id;
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_sendMediaMsg(JNIEnv *env, jclass cls, jint chat_id, jint type, jstring file, jstring mime, jint w, jint h, jint ms, jstring author, jstring trackname)
{
mrmsg_t* msg = mrmsg_new();
msg->m_type = type;
CHAR_REF(mime);
mrparam_set(msg->m_param, 'm', mimePtr);
CHAR_UNREF(mime);
CHAR_REF(file);
mrparam_set(msg->m_param, 'f', filePtr);
CHAR_UNREF(file);
if( type == MR_MSG_IMAGE || type == MR_MSG_GIF || type == MR_MSG_VIDEO ) {
mrparam_set_int(msg->m_param, 'w', w);
mrparam_set_int(msg->m_param, 'h', h);
}
if( type == MR_MSG_AUDIO || type == MR_MSG_VOICE || type == MR_MSG_VIDEO ) {
mrparam_set_int(msg->m_param, 'd', ms);
}
if( type == MR_MSG_AUDIO ) {
CHAR_REF(author);
mrparam_set(msg->m_param, 'N', authorPtr);
CHAR_UNREF(author);
CHAR_REF(trackname);
mrparam_set(msg->m_param, 'n', tracknamePtr);
CHAR_UNREF(trackname);
}
jint msg_id = mrmailbox_send_msg(get_mrmailbox_t(env, cls), chat_id, msg);
mrmsg_unref(msg);
return msg_id;
}
/* MrMailbox - handle config */
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfig(JNIEnv *env, jclass cls, jstring key, jstring value /*may be NULL*/)
@@ -617,9 +676,15 @@ JNIEXPORT jlong Java_com_b44t_messenger_MrChatlist_MrChatlistGetChatByIndex(JNIE
}
JNIEXPORT jlong Java_com_b44t_messenger_MrChatlist_MrChatlistGetMsgByIndex(JNIEnv *env, jclass c, jlong hChatlist, jint index)
{
return (jlong)mrchatlist_get_msg_by_index((mrchatlist_t*)hChatlist, index);
}
JNIEXPORT jlong Java_com_b44t_messenger_MrChatlist_MrChatlistGetSummaryByIndex(JNIEnv *env, jclass c, jlong hChatlist, jint index, jlong hChat)
{
return (jlong)mrchatlist_get_summary_by_index((mrchatlist_t*)hChatlist, index, (mrchat_t*)hChat);
return (jlong)mrchatlist_get_summary((mrchatlist_t*)hChatlist, index, (mrchat_t*)hChat);
}
@@ -662,6 +727,13 @@ JNIEXPORT jint Java_com_b44t_messenger_MrChat_getType(JNIEnv *env, jclass cls)
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getArchived(JNIEnv *env, jclass cls)
{
mrchat_t* ths = get_mrchat_t(env, cls); if( ths == NULL ) { return 0; }
return ths->m_archived;
}
JNIEXPORT jstring Java_com_b44t_messenger_MrChat_getName(JNIEnv *env, jclass cls)
{
mrchat_t* ths = get_mrchat_t(env, cls); if( ths == NULL ) { return JSTRING_NEW(NULL); }
@@ -724,12 +796,6 @@ JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatGetDraftReplyToMsgId(JNIEnv
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getFreshMsgCount(JNIEnv *env, jclass cls)
{
return mrchat_get_fresh_msg_count(get_mrchat_t(env, cls));
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatSetDraft(JNIEnv *env, jclass c, jlong hChat, jstring draft /* NULL=delete */, jint replyToMsgId)
{
CHAR_REF(draft);
@@ -739,50 +805,6 @@ JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatSetDraft(JNIEnv *env, jclass
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_sendText(JNIEnv *env, jclass cls, jstring text)
{
mrmsg_t* msg = mrmsg_new();
msg->m_type = MR_MSG_TEXT;
CHAR_REF(text);
msg->m_text = textPtr? strdup(textPtr) : NULL;
CHAR_UNREF(text);
jint msg_id = mrchat_send_msg(get_mrchat_t(env, cls), msg);
mrmsg_unref(msg);
return msg_id;
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_sendMedia(JNIEnv *env, jclass cls, jint type, jstring file, jstring mime, jint w, jint h, jint ms, jstring author, jstring trackname)
{
mrmsg_t* msg = mrmsg_new();
msg->m_type = type;
CHAR_REF(mime);
mrparam_set(msg->m_param, 'm', mimePtr);
CHAR_UNREF(mime);
CHAR_REF(file);
mrparam_set(msg->m_param, 'f', filePtr);
CHAR_UNREF(file);
if( type == MR_MSG_IMAGE || type == MR_MSG_GIF || type == MR_MSG_VIDEO ) {
mrparam_set_int(msg->m_param, 'w', w);
mrparam_set_int(msg->m_param, 'h', h);
}
if( type == MR_MSG_AUDIO || type == MR_MSG_VOICE || type == MR_MSG_VIDEO ) {
mrparam_set_int(msg->m_param, 'd', ms);
}
if( type == MR_MSG_AUDIO ) {
CHAR_REF(author);
mrparam_set(msg->m_param, 'N', authorPtr);
CHAR_UNREF(author);
CHAR_REF(trackname);
mrparam_set(msg->m_param, 'n', tracknamePtr);
CHAR_UNREF(trackname);
}
jint msg_id = mrchat_send_msg(get_mrchat_t(env, cls), msg);
mrmsg_unref(msg);
return msg_id;
}
JNIEXPORT jintArray Java_com_b44t_messenger_MrMailbox_getChatMedia(JNIEnv *env, jclass cls, jint chat_id, jint msg_type, jint or_msg_type)
{
carray* ca = mrmailbox_get_chat_media(get_mrmailbox_t(env, cls), chat_id, msg_type, or_msg_type);
@@ -969,6 +991,12 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMsg_getSummarytext(JNIEnv *env, jobject
}
JNIEXPORT jint Java_com_b44t_messenger_MrMsg_showPadlock(JNIEnv *env, jobject obj)
{
return mrmsg_show_padlock(get_mrmsg_t(env, obj));
}
JNIEXPORT jint Java_com_b44t_messenger_MrMsg_getFilename(JNIEnv *env, jobject obj)
{
return JSTRING_NEW(mrmsg_get_filename(get_mrmsg_t(env, obj)));
+9 -2
View File
@@ -53,7 +53,7 @@
android:supportsRtl="true">
<activity
android:name="com.b44t.ui.LaunchActivity"
android:name=".LaunchActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustPan">
@@ -105,10 +105,17 @@
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity
android:name="com.b44t.ui.WelcomeActivity"
android:name=".WelcomeActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
</activity>
<activity
android:name=".SettingsAdvActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
</activity>
<activity
android:name="com.b44t.messenger.OpenChatReceiver"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
@@ -21,14 +21,13 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.Gravity;
@@ -40,7 +39,7 @@ import android.widget.ImageView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
import java.util.ArrayList;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -49,7 +49,7 @@ import android.widget.LinearLayout;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.R;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
import java.util.ArrayList;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -32,7 +32,7 @@ import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class ActionBarMenu extends LinearLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.content.Context;
import android.graphics.Rect;
@@ -47,9 +47,7 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import java.lang.reflect.Field;
import com.b44t.messenger.Components.LayoutHelper;
public class ActionBarMenuItem extends FrameLayout {
@@ -23,7 +23,7 @@
//Thanks to https://github.com/JakeWharton/ActionBarSherlock/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -44,7 +44,7 @@ import android.widget.ScrollView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
import java.lang.reflect.Field;
import java.util.HashMap;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -21,9 +21,8 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.animation.AnimatorSet;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -60,7 +60,7 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
import java.util.ArrayList;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.ActionBar;
package com.b44t.messenger.ActionBar;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -39,7 +39,7 @@ import android.os.Build;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.ui.Components.ChatAttachAlert;
import com.b44t.messenger.Components.ChatAttachAlert;
public class Theme {
@@ -60,22 +60,17 @@ public class Theme {
public static final int ATTACH_SHEET_TEXT_COLOR = 0xff757575;
public static final int DIALOGS_TITLE_TEXT_COLOR = 0xff000000;
public static final int DIALOGS_MESSAGE_TEXT_COLOR = 0xff8f8f8f;
public static final int DIALOGS_NAME_TEXT_COLOR = 0xff555555;
public static final int DIALOGS_SELF_TEXT_COLOR = 0xff00a60e; // from encrypted chat title: 0xff00a60e, alternative: 0xff3c912e
public static final int DIALOGS_PRINTING_TEXT_COLOR = 0xff4d83b3;
public static final int DIALOGS_DRAFT_TEXT_COLOR = 0xffdd4b39;
public static final int CHATLIST_BACKGROUND_COLOR = 0xffffffff;
public static final int CHATLIST_DEADDROP_BACKGROUND_COLOR = 0xffd3d3d3;
public static final int CHATLIST_TITLE_TEXT_COLOR = 0xff000000;
public static final int CHATLIST_MESSAGE_TEXT_COLOR = 0xff8f8f8f;
public static final int CHATLIST_NAME_TEXT_COLOR = 0xff555555;
public static final int CHATLIST_SELF_TEXT_COLOR = 0xff00a60e; // from encrypted chat title: 0xff00a60e, alternative: 0xff3c912e
public static final int CHATLIST_DRAFT_TEXT_COLOR = 0xffdd4b39;
public static final int CHAT_BOTTOM_OVERLAY_TEXT_COLOR = 0xff7f7f7f;
public static final int CHAT_EMPTY_VIEW_TEXT_COLOR = 0xffffffff;
public static final int STICKERS_SHEET_TITLE_TEXT_COLOR = 0xff212121;
public static final int STICKERS_SHEET_SEND_TEXT_COLOR = 0xff3a8ccf;
public static final int STICKERS_SHEET_ADD_TEXT_COLOR = 0xff3a8ccf;
public static final int STICKERS_SHEET_CLOSE_TEXT_COLOR = 0xff3a8ccf;
public static final int STICKERS_SHEET_REMOVE_TEXT_COLOR = 0xffcd5a5a;
public static final int MSG_SELECTED_BACKGROUND_COLOR = 0x6633b5e5;
public static final int MSG_STICKER_NAME_TEXT_COLOR = 0xffffffff;
public static final int MSG_IN_TIME_N_FWD_TEXT_COLOR = 0xff9ea7b0;
@@ -61,15 +61,11 @@ import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.MimeTypeMap;
import android.widget.AbsListView;
import android.widget.EdgeEffect;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.b44t.ui.Components.ForegroundDetector;
import com.b44t.ui.Components.TypefaceSpan;
import com.b44t.messenger.Components.ForegroundDetector;
import com.b44t.messenger.Components.TypefaceSpan;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -84,9 +80,7 @@ import java.nio.channels.FileChannel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
import java.util.regex.Pattern;
public class AndroidUtilities {
@@ -101,24 +95,6 @@ public class AndroidUtilities {
public static boolean usingHardwareInput;
private static int adjustOwnerClassGuid = 0;
static {
try {
final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final Pattern IP_ADDRESS = Pattern.compile(
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
+ "[0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}"
+ "|[1-9][0-9]|[0-9]))");
final String IRI = "[" + GOOD_IRI_CHAR + "]([" + GOOD_IRI_CHAR + "\\-]{0,61}[" + GOOD_IRI_CHAR + "]){0,1}";
final String GOOD_GTLD_CHAR = "a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
final String GTLD = "[" + GOOD_GTLD_CHAR + "]{2,63}";
final String HOST_NAME = "(" + IRI + "\\.)+" + GTLD;
final Pattern DOMAIN_NAME = Pattern.compile("(" + HOST_NAME + "|" + IP_ADDRESS + ")");
} catch (Exception e) {
}
}
static {
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
leftBaseline = 72;
@@ -24,9 +24,7 @@
package com.b44t.messenger;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.Application;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -40,11 +38,9 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Handler;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import com.b44t.ui.Components.ForegroundDetector;
import com.b44t.ui.SettingsAdvActivity;
import com.b44t.messenger.Components.ForegroundDetector;
import java.io.File;
@@ -207,9 +203,10 @@ public class ApplicationLoader extends Application {
// make sure, the notifications for the "deaddrop" dialog are muted by default
SharedPreferences notificationPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if( notificationPreferences.getInt("notify2_"+MrChat.MR_CHAT_ID_DEADDROP, 666)==666 ) {
if( notificationPreferences.getInt("deaddrop_initialized", 0)!=1 ) {
SharedPreferences.Editor editor = notificationPreferences.edit();
editor.putInt("notify2_"+MrChat.MR_CHAT_ID_DEADDROP, 2);
editor.putInt("deaddrop_initialized", 1);
editor.apply();
}
@@ -223,7 +220,7 @@ public class ApplicationLoader extends Application {
// create other default objects
SharedPreferences mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
fontSize = mainPreferences.getInt("msg_font_size", SettingsAdvActivity.defMsgFontSize());
fontSize = mainPreferences.getInt("msg_font_size", SettingsAdvFragment.defMsgFontSize());
ImageLoader.getInstance();
MediaController.getInstance();
@@ -20,7 +20,7 @@
*
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.content.Context;
import android.database.Cursor;
@@ -32,24 +32,13 @@ import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ListView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.FileLoader;
import com.b44t.messenger.R;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.Utilities;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.AudioCell;
import com.b44t.ui.Components.EmptyTextProgressView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.PickerBottomLayout;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.BaseFragmentAdapter;
import com.b44t.messenger.Cells.AudioCell;
import com.b44t.messenger.Components.EmptyTextProgressView;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.PickerBottomLayout;
import java.io.File;
import java.util.ArrayList;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.app.AlertDialog;
import android.content.Context;
@@ -36,18 +36,12 @@ import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.UserCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BaseFragmentAdapter;
import com.b44t.messenger.Cells.UserCell;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.LayoutHelper;
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Paint;
@@ -38,8 +38,8 @@ import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.R;
import com.b44t.ui.Components.CheckBoxView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.CheckBoxView;
import com.b44t.messenger.Components.LayoutHelper;
public class AudioCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -35,7 +35,7 @@ import android.view.MotionEvent;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.MessageObject;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.ActionBar.Theme;
public class ChatActionCell extends BaseCell {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -58,13 +58,13 @@ import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.MrPoortext;
import com.b44t.messenger.R;
import com.b44t.messenger.TLRPC;
import com.b44t.ui.Components.AvatarDrawable;
import com.b44t.ui.Components.LinkPath;
import com.b44t.ui.Components.SeekBar;
import com.b44t.ui.Components.SeekBarWaveform;
import com.b44t.ui.Components.StaticLayoutEx;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.PhotoViewer;
import com.b44t.messenger.Components.AvatarDrawable;
import com.b44t.messenger.Components.LinkPath;
import com.b44t.messenger.Components.SeekBar;
import com.b44t.messenger.Components.SeekBarWaveform;
import com.b44t.messenger.Components.StaticLayoutEx;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.PhotoViewer;
import java.util.ArrayList;
import java.util.Locale;
@@ -514,7 +514,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
imagePressed = true;
result = true;
}
} else if (currentMessageObject.type != MessageObject.MO_TYPE13_STICKER || currentMessageObject.getInputStickerSet() != null) {
} else if (currentMessageObject.type != MessageObject.MO_TYPE13_STICKER ) {
if (x >= photoImage.getImageX() && x <= photoImage.getImageX() + backgroundWidth && y >= photoImage.getImageY() && y <= photoImage.getImageY() + photoImage.getImageHeight()) {
imagePressed = true;
result = true;
@@ -2008,10 +2008,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
private void measureTime(MessageObject messageObject) {
currentTimeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
currentTimeString = LocaleController.getInstance().getFormatterDay().format((long) (messageObject.messageOwner.date) * 1000);
timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
timeEncrWidth = 0;
if( messageObject.messageOwner.e2ee ) {
if( messageObject.messageOwner.show_padlock) {
timeEncrWidth = Theme.encrOutDrawable.getIntrinsicWidth();
timeWidth += timeEncrWidth;
}
@@ -21,21 +21,20 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Typeface;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.ActionBar.Theme;
public class ChatUnreadCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -39,26 +39,24 @@ import android.text.style.ForegroundColorSpan;
import android.view.MotionEvent;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ContactsController;
import com.b44t.messenger.EmojiInputView;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.MrMsg;
import com.b44t.messenger.MrPoortext;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.Emoji;
import com.b44t.messenger.R;
import com.b44t.messenger.ImageReceiver;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.Components.AvatarDrawable;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.Components.AvatarDrawable;
public class DialogCell extends BaseCell {
public class ChatlistCell extends BaseCell {
private static TextPaint namePaint;
private static TextPaint messagePaint;
private static TextPaint messagePrintingPaint;
private static TextPaint timePaint;
private static TextPaint countPaint;
@@ -67,32 +65,23 @@ public class DialogCell extends BaseCell {
private static Drawable clockDrawable;
private static Drawable errorDrawable;
private static Drawable countDrawable;
private static Drawable countDrawableGrey;
private static Drawable groupDrawable;
private static Drawable muteDrawable;
private static Drawable closeDrawable;
private static Paint linePaint;
private static Paint backPaint;
private long currentDialogId;
private final boolean isDialogCell = true; // if it is no dialog cell, it is a search cell ...
private long currentChatId;
private int unreadCount;
private int lastSendState;
private boolean dialogMuted;
private final MessageObject message = null;
private int index;
private boolean chatMuted;
private ImageReceiver avatarImage;
private AvatarDrawable avatarDrawable;
private final Object user = null;
private final Object chat = null;
public boolean useSeparator = false;
private int nameLeft;
private StaticLayout nameLayout;
private boolean drawNameGroup;
private boolean drawGroupIcon;
private int nameMuteLeft;
private int nameLockLeft;
private int nameLockTop;
@@ -122,37 +111,35 @@ public class DialogCell extends BaseCell {
private int countWidth;
private StaticLayout countLayout;
private int avatarTop = AndroidUtilities.dp(10);
private boolean drawFlag; // draw a flag as eg. "Archived" below the time
private int flagLeft;
private int flagWidth;
private StaticLayout flagLayout;
private boolean isSelected;
private int avatarLeft;
private int avatarTop = AndroidUtilities.dp(10);
private int avatarWH = AndroidUtilities.dp(52);
private MrChat m_mrChat = new MrChat(0);
private MrPoortext m_summary = new MrPoortext(0);
private boolean m_showUnreadCount;
public DialogCell(Context context) {
public ChatlistCell(Context context) {
super(context);
if (namePaint == null) {
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
namePaint.setTextSize(AndroidUtilities.dp(17));
namePaint.setColor(Theme.DIALOGS_TITLE_TEXT_COLOR);
namePaint.setColor(Theme.CHATLIST_TITLE_TEXT_COLOR);
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
messagePaint.setTextSize(AndroidUtilities.dp(16));
messagePaint.setColor(Theme.DIALOGS_MESSAGE_TEXT_COLOR);
messagePaint.linkColor = Theme.DIALOGS_MESSAGE_TEXT_COLOR;
messagePaint.setColor(Theme.CHATLIST_MESSAGE_TEXT_COLOR);
messagePaint.linkColor = Theme.CHATLIST_MESSAGE_TEXT_COLOR;
linePaint = new Paint();
linePaint.setColor(0xffdcdcdc);
backPaint = new Paint();
backPaint.setColor(0x0f000000);
messagePrintingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
messagePrintingPaint.setTextSize(AndroidUtilities.dp(16));
messagePrintingPaint.setColor(Theme.DIALOGS_PRINTING_TEXT_COLOR);
timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
timePaint.setTextSize(AndroidUtilities.dp(13));
timePaint.setColor(0xff999999);
@@ -167,34 +154,32 @@ public class DialogCell extends BaseCell {
clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
errorDrawable = getResources().getDrawable(R.drawable.msg_warning);
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2);
groupDrawable = getResources().getDrawable(R.drawable.list_group);
muteDrawable = getResources().getDrawable(R.drawable.mute_grey);
closeDrawable = getResources().getDrawable(R.drawable.ic_dismiss_deaddrop);
}
setBackgroundResource(R.drawable.list_selector);
avatarImage = new ImageReceiver(this);
avatarImage.setRoundRadius(AndroidUtilities.dp(26));
avatarDrawable = new AvatarDrawable();
}
public void setDialog(MrChat mrChat, MrPoortext mrSummary, int i, boolean showUnreadCount) { // called for the chats overview
public void setChat(MrChat mrChat, MrPoortext mrSummary, int i, boolean showUnreadCount) {
m_mrChat = mrChat;
m_summary = mrSummary;
m_showUnreadCount = showUnreadCount;
currentDialogId = mrChat.getId();
index = i;
currentChatId = mrChat.getId();
if(currentChatId==MrChat.MR_CHAT_ID_DEADDROP) {
setBackgroundColor(Theme.CHATLIST_DEADDROP_BACKGROUND_COLOR);
}
else {
setBackgroundResource(R.drawable.list_selector);
}
update(0);
}
public long getDialogId() {
return currentDialogId;
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
@@ -214,7 +199,7 @@ public class DialogCell extends BaseCell {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (currentDialogId == 0) {
if (currentChatId == 0) {
super.onLayout(changed, left, top, right, bottom);
return;
}
@@ -223,6 +208,7 @@ public class DialogCell extends BaseCell {
}
}
static public boolean deaddropClosePressed;
@Override
public boolean onTouchEvent(MotionEvent event) {
if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) {
@@ -230,102 +216,86 @@ public class DialogCell extends BaseCell {
getBackground().setHotspot(event.getX(), event.getY());
}
}
if( currentChatId==MrChat.MR_CHAT_ID_DEADDROP ) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
float x = event.getX();
deaddropClosePressed = (x < avatarLeft + avatarWH);
}
}
return super.onTouchEvent(event);
}
public void buildLayout() {
String nameString = "";
String timeString = "";
String countString = null;
CharSequence messageString = "";
//CharSequence printingString = null;
/* EDIT BY MR -- we currently do not support stuff as "ist just typing", "uploads an images" etc.
if (isDialogCell) {
printingString = MessagesController.getInstance().printingStrings.get(currentDialogId);
}
*/
TextPaint currentNamePaint = namePaint;
TextPaint currentMessagePaint = messagePaint;
boolean checkMessage = true;
drawNameGroup = false;
drawGroupIcon = false;
{
if (m_mrChat.getType()==MrChat.MR_CHAT_GROUP) { // EDIT BY MR
//if (chat.id < 0 || ChatObject.isChannel(chat) && !chat.megagroup) {
// drawNameBroadcast = true;
// nameLockTop = AndroidUtilities.dp(16.5f);
//} else {
drawNameGroup = true;
nameLockTop = AndroidUtilities.dp(17.5f);
//}
if (m_mrChat.getType()==MrChat.MR_CHAT_GROUP && currentChatId!=MrChat.MR_CHAT_ID_DEADDROP) {
drawGroupIcon = true;
nameLockTop = AndroidUtilities.dp(17.5f);
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + (groupDrawable.getIntrinsicWidth());
} else {
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline) - (groupDrawable.getIntrinsicWidth());
nameLeft = AndroidUtilities.dp(14);
}
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + (groupDrawable.getIntrinsicWidth());
} else {
if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
} else {
nameLeft = AndroidUtilities.dp(14);
}
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline) - (groupDrawable.getIntrinsicWidth());
nameLeft = AndroidUtilities.dp(14);
}
} else {
if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
} else {
nameLeft = AndroidUtilities.dp(14);
}
}
String mess = m_summary.getText2();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
String title = m_summary.getText1();
if( !title.isEmpty() )
{
checkMessage = false;
String mess = m_summary.getText2();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
String title = m_summary.getText1();
if( !title.isEmpty() )
{
int title_meaning = m_summary.getText1Meaning();
int title_color = Theme.DIALOGS_NAME_TEXT_COLOR;
switch( title_meaning ) {
case MrPoortext.MR_TEXT1_SELF: title_color = Theme.DIALOGS_SELF_TEXT_COLOR; break;
case MrPoortext.MR_TEXT1_DRAFT: title_color = Theme.DIALOGS_DRAFT_TEXT_COLOR; break;
}
SpannableStringBuilder stringBuilder = SpannableStringBuilder.valueOf(String.format("%s: %s", title, mess));
stringBuilder.setSpan(new ForegroundColorSpan(title_color), 0, title.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
messageString = Emoji.replaceEmoji(stringBuilder, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
}
else
{
messageString = mess;
}
long timestmp =m_summary.getTimestamp();
if( timestmp!=0 ) {
timeString = LocaleController.stringForMessageListDate(timestmp);
}
else {
timeString = "";
}
drawCheck1 = false;
drawCheck2 = false;
drawClock = false;
drawCount = false;
drawError = false;
switch( m_summary.getState() ) {
case MrMsg.MR_OUT_ERROR: drawError = true; break;
case MrMsg.MR_OUT_PENDING: drawClock = true; break;
case MrMsg.MR_OUT_DELIVERED: drawCheck2 = true; break;
case MrMsg.MR_OUT_MDN_RCVD: drawCheck1 = true; drawCheck2 = true; break;
}
int title_meaning = m_summary.getText1Meaning();
int title_color = Theme.CHATLIST_NAME_TEXT_COLOR;
switch( title_meaning ) {
case MrPoortext.MR_TEXT1_SELF: title_color = Theme.CHATLIST_SELF_TEXT_COLOR; break;
case MrPoortext.MR_TEXT1_DRAFT: title_color = Theme.CHATLIST_DRAFT_TEXT_COLOR; break;
}
SpannableStringBuilder stringBuilder = SpannableStringBuilder.valueOf(String.format("%s: %s", title, mess));
stringBuilder.setSpan(new ForegroundColorSpan(title_color), 0, title.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
messageString = EmojiInputView.replaceEmoji(stringBuilder, false);
}
else
{
messageString = mess;
}
if (unreadCount != 0) {
drawCount = true;
countString = String.format("%d", unreadCount);
} else {
drawCount = false;
long timestmp =m_summary.getTimestamp();
if( timestmp!=0 ) {
timeString = LocaleController.dateForChatlist(timestmp);
}
else {
timeString = "";
}
drawCheck1 = false;
drawCheck2 = false;
drawClock = false;
drawCount = false;
drawFlag = false;
drawError = false;
switch( m_summary.getState() ) {
case MrMsg.MR_OUT_ERROR: drawError = true; break;
case MrMsg.MR_OUT_PENDING: drawClock = true; break;
case MrMsg.MR_OUT_DELIVERED: drawCheck2 = true; break;
case MrMsg.MR_OUT_MDN_RCVD: drawCheck1 = true; drawCheck2 = true; break;
}
int timeWidth = (int) Math.ceil(timePaint.measureText(timeString));
@@ -347,7 +317,7 @@ public class DialogCell extends BaseCell {
nameLeft += timeWidth;
}
if (drawNameGroup) {
if (drawGroupIcon) {
nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth();
}
@@ -383,7 +353,7 @@ public class DialogCell extends BaseCell {
}
}
if (dialogMuted) {
if (chatMuted) {
int w = AndroidUtilities.dp(6) + muteDrawable.getIntrinsicWidth();
nameWidth -= w;
if (LocaleController.isRTL) {
@@ -391,6 +361,7 @@ public class DialogCell extends BaseCell {
}
}
// build name
nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth);
CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace('\n', ' '), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
try {
@@ -399,8 +370,8 @@ public class DialogCell extends BaseCell {
}
// build avatar
int messageWidth = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline + 16);
int avatarLeft;
if (!LocaleController.isRTL) {
messageLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
avatarLeft = AndroidUtilities.dp(9);
@@ -408,7 +379,15 @@ public class DialogCell extends BaseCell {
messageLeft = AndroidUtilities.dp(16);
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(61);
}
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(52), AndroidUtilities.dp(52));
if( currentChatId==MrChat.MR_CHAT_ID_DEADDROP ) {
}
else {
avatarImage.setImageCoords(avatarLeft, avatarTop, avatarWH, avatarWH);
}
// build counter
if (drawError) {
int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8);
messageWidth -= w;
@@ -418,7 +397,30 @@ public class DialogCell extends BaseCell {
errorLeft = AndroidUtilities.dp(16);
messageLeft += w;
}
} else if (countString != null) {
} else if(m_mrChat.getArchived()!=0 || currentChatId==MrChat.MR_CHAT_ID_ARCHIVED_LINK ) {
String str;
TextPaint strPaint;
if( currentChatId==MrChat.MR_CHAT_ID_ARCHIVED_LINK ) {
str = m_mrChat.getName();
strPaint = messagePaint;
}
else {
str = ApplicationLoader.applicationContext.getString(R.string.Archived);
strPaint = timePaint;
}
flagWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(strPaint.measureText(str)));
flagLayout = new StaticLayout(str, strPaint, flagWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
int w = flagWidth + AndroidUtilities.dp(15);
if (!LocaleController.isRTL) {
messageWidth -= w;
flagLeft = getMeasuredWidth() - flagWidth - AndroidUtilities.dp(15);
} else {
flagLeft = AndroidUtilities.dp(15);
}
drawFlag = true;
} else if (unreadCount != 0 && currentChatId!=MrChat.MR_CHAT_ID_DEADDROP) {
String countString = String.format("%d", unreadCount);
countWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(countPaint.measureText(countString)));
countLayout = new StaticLayout(countString, countPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
int w = countWidth + AndroidUtilities.dp(18);
@@ -430,21 +432,8 @@ public class DialogCell extends BaseCell {
messageLeft += w;
}
drawCount = true;
} else {
drawCount = false;
}
if (checkMessage) {
if (messageString == null) {
messageString = "";
}
String mess = messageString.toString();
if (mess.length() > 150) {
mess = mess.substring(0, 150);
}
mess = mess.replace('\n', ' ');
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(17), false);
}
messageWidth = Math.max(AndroidUtilities.dp(12), messageWidth);
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
try {
@@ -459,7 +448,7 @@ public class DialogCell extends BaseCell {
if (nameLayout != null && nameLayout.getLineCount() > 0) {
left = nameLayout.getLineLeft(0);
widthpx = Math.ceil(nameLayout.getLineWidth(0));
if (dialogMuted) {
if (chatMuted) {
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - muteDrawable.getIntrinsicWidth());
}
if (left == 0) {
@@ -486,7 +475,7 @@ public class DialogCell extends BaseCell {
nameLeft -= (nameWidth - widthpx);
}
}
if (dialogMuted) {
if (chatMuted) {
nameMuteLeft = (int) (nameLeft + left + AndroidUtilities.dp(6));
}
}
@@ -502,60 +491,24 @@ public class DialogCell extends BaseCell {
}
}
public void setDialogSelected(boolean value) {
if (isSelected != value) {
invalidate();
}
isSelected = value;
}
public void checkCurrentDialogIndex() {
if (index < MrMailbox.m_currChatlist.getCnt()) { // EDIT BY MR - was: index < getDialogsArray().size()
TLRPC.TL_dialog dialog = MrMailbox.m_currChatlist.get_TLRPC_TL_dialog(index); // EDIT BY MR - was: getDialogsArray().get(index);
final MessageObject newMessageObject = null;
if (currentDialogId != dialog.id ||
message != null && message.getId() != dialog.top_message ||
unreadCount != dialog.unread_count ||
message != newMessageObject ||
message == null && newMessageObject != null ) {
currentDialogId = dialog.id;
update(0);
}
}
}
public void update(int mask) {
if( m_showUnreadCount ) {
unreadCount = m_mrChat.getFreshMsgCount();
unreadCount = MrMailbox.getFreshMsgCount(m_mrChat.getId());
}
if (mask != 0) {
boolean continueUpdate = false;
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_AVATAR) != 0) {
if (chat == null) {
continueUpdate = true;
}
continueUpdate = true;
}
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_NAME) != 0) {
if (chat == null) {
continueUpdate = true;
}
continueUpdate = true;
}
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_CHAT_AVATAR) != 0) {
if (user == null) {
continueUpdate = true;
}
continueUpdate = true;
}
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_CHAT_NAME) != 0) {
if (user == null) {
continueUpdate = true;
}
}
if (!continueUpdate && (mask & MrMailbox.UPDATE_MASK_SEND_STATE) != 0) {
if (message != null && lastSendState != message.messageOwner.send_state) {
lastSendState = message.messageOwner.send_state;
continueUpdate = true;
}
continueUpdate = true;
}
if (!continueUpdate) {
@@ -563,25 +516,15 @@ public class DialogCell extends BaseCell {
}
}
dialogMuted = isDialogCell && MrMailbox.isDialogMuted(currentDialogId);
//user = null;
//chat = null;
/*int lower_id = (int)currentDialogId;
int high_id = (int)(currentDialogId >> 32);
if (lower_id != 0) {
if (high_id == 1) {
chat = MessagesController.getInstance().getChat(lower_id);
} else {
if (lower_id < 0) {
chat = MessagesController.getInstance().getChat(-lower_id);
} else {
user = MessagesController.getInstance().getUser(lower_id);
}
}
}*/
ContactsController.setupAvatar(this, avatarImage, avatarDrawable, null, m_mrChat);
if( currentChatId == MrChat.MR_CHAT_ID_DEADDROP ) {
chatMuted = false; // never draw mute icon, the deaddrop is always muted
}
else {
chatMuted = MrMailbox.isDialogMuted(currentChatId);
ContactsController.setupAvatar(this, avatarImage, new AvatarDrawable(), null, m_mrChat);
}
if (getMeasuredWidth() != 0 || getMeasuredHeight() != 0) {
buildLayout();
@@ -594,21 +537,20 @@ public class DialogCell extends BaseCell {
@Override
protected void onDraw(Canvas canvas) {
if (currentDialogId == 0) {
if( currentChatId == MrChat.MR_CHAT_ID_ARCHIVED_LINK ) {
canvas.save();
canvas.translate(getMeasuredWidth()/2-flagWidth/2, getMeasuredHeight()/2-flagLayout.getHeight()/2);
flagLayout.draw(canvas);
canvas.restore();
return;
}
if (isSelected) {
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), backPaint);
if (currentChatId == 0) {
return;
}
/*
if (drawNameLock) {
setDrawableBounds(lockDrawable, nameLockLeft, nameLockTop);
lockDrawable.draw(canvas);
} else
*/
if (drawNameGroup) {
if (drawGroupIcon) {
setDrawableBounds(groupDrawable, nameLockLeft, nameLockTop);
groupDrawable.draw(canvas);
}
@@ -651,7 +593,7 @@ public class DialogCell extends BaseCell {
}
}
if (dialogMuted) {
if (chatMuted) {
setDrawableBounds(muteDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
muteDrawable.draw(canvas);
}
@@ -659,20 +601,30 @@ public class DialogCell extends BaseCell {
if (drawError) {
setDrawableBounds(errorDrawable, errorLeft, errorTop);
errorDrawable.draw(canvas);
} else if(drawFlag) {
canvas.save();
canvas.translate(flagLeft, countTop + AndroidUtilities.dp(4));
flagLayout.draw(canvas);
canvas.restore();
} else if (drawCount) {
if (dialogMuted) {
setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
countDrawableGrey.draw(canvas);
} else {
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
countDrawable.draw(canvas);
}
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
countDrawable.draw(canvas);
canvas.save();
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
countLayout.draw(canvas);
canvas.restore();
}
if( currentChatId==MrChat.MR_CHAT_ID_DEADDROP ) {
int shrink = AndroidUtilities.dp(12);
setDrawableBounds(closeDrawable, avatarLeft+shrink, avatarTop+shrink, avatarWH-shrink*2, avatarWH-shrink*2);
closeDrawable.draw(canvas);
}
else {
avatarImage.draw(canvas);
}
if (useSeparator) {
if (LocaleController.isRTL) {
canvas.drawLine(0, getMeasuredHeight() - 1, getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, linePaint);
@@ -680,8 +632,6 @@ public class DialogCell extends BaseCell {
canvas.drawLine(AndroidUtilities.dp(AndroidUtilities.leftBaseline), getMeasuredHeight() - 1, getMeasuredWidth(), getMeasuredHeight() - 1, linePaint);
}
}
avatarImage.draw(canvas);
}
@Override
@@ -25,7 +25,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -39,8 +39,7 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class EditTextCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.widget.FrameLayout;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Typeface;
@@ -31,7 +31,7 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class GreySectionCell extends FrameLayout {
private TextView textView;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Typeface;
@@ -31,7 +31,7 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class HeaderCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Rect;
@@ -34,10 +34,10 @@ import android.widget.FrameLayout;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.R;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.CheckBoxView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.PhotoViewer;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.CheckBoxView;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.PhotoViewer;
public class PhotoAttachPhotoCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.text.TextUtils;
@@ -32,7 +32,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class PhotoEditToolCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.os.Build;
@@ -37,8 +37,8 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.R;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.LayoutHelper;
public class PhotoPickerAlbumsCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -33,9 +33,9 @@ import android.widget.FrameLayout;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.messenger.R;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.CheckBoxView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.CheckBoxView;
import com.b44t.messenger.Components.LayoutHelper;
public class PhotoPickerPhotoCell extends FrameLayout {
@@ -20,7 +20,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Bitmap;
@@ -42,8 +42,8 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.ActionBar.Theme;
public class SettingsProfileCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.view.View;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Paint;
@@ -36,9 +36,9 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ImageReceiver;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.CheckBoxView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.CheckBoxView;
import com.b44t.messenger.Components.LayoutHelper;
public class SharedDocumentCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -31,7 +31,7 @@ import android.widget.ImageView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.ActionBar.SimpleTextView;
import com.b44t.messenger.ActionBar.SimpleTextView;
public class TextCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -35,7 +35,7 @@ import android.widget.CheckBox;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class TextCheckCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -32,8 +32,7 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class TextDetailSettingsCell extends FrameLayout {
@@ -20,7 +20,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.util.TypedValue;
@@ -29,8 +29,7 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
public class TextInfoCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.Canvas;
@@ -30,12 +30,10 @@ import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.LayoutHelper;
import static com.b44t.messenger.AndroidUtilities.dp;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.view.Gravity;
@@ -33,11 +33,11 @@ import com.b44t.messenger.ContactsController;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.R;
import com.b44t.ui.Components.AvatarDrawable;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.CheckBoxView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.ActionBar.SimpleTextView;
import com.b44t.messenger.Components.AvatarDrawable;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.CheckBoxView;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.ActionBar.SimpleTextView;
public class UserCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Cells;
package com.b44t.messenger.Cells;
import android.content.Context;
import android.graphics.drawable.Drawable;
@@ -33,8 +33,8 @@ import android.widget.ImageView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.R;
import com.b44t.messenger.TLRPC;
import com.b44t.ui.Components.BackupImageView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BackupImageView;
import com.b44t.messenger.Components.LayoutHelper;
public class WallpaperCell extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.Manifest;
import android.animation.Animator;
@@ -46,7 +46,6 @@ import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.SparseIntArray;
import android.util.TypedValue;
import android.view.Gravity;
@@ -60,45 +59,26 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.BuildConfig;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.MrMsg;
import com.b44t.messenger.NotificationsController;
import com.b44t.messenger.SendMessagesHelper;
import com.b44t.messenger.Utilities;
import com.b44t.messenger.VideoEditedInfo;
import com.b44t.messenger.browser.Browser;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.BackDrawable;
import com.b44t.ui.ActionBar.SimpleTextView;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.ui.Cells.ChatActionCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.ActionBarMenuItem;
import com.b44t.ui.Cells.ChatMessageCell;
import com.b44t.ui.Cells.ChatUnreadCell;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.ChatActivityEnterView;
import com.b44t.messenger.ImageReceiver;
import com.b44t.ui.Components.ChatAttachAlert;
import com.b44t.ui.Components.ChatAvatarContainer;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.NumberTextView;
import com.b44t.ui.Components.RecyclerListView;
import com.b44t.ui.Components.SizeNotifierFrameLayout;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.Components.Browser;
import com.b44t.messenger.aosp.LinearLayoutManager;
import com.b44t.messenger.aosp.RecyclerView;
import com.b44t.messenger.ActionBar.BackDrawable;
import com.b44t.messenger.ActionBar.SimpleTextView;
import com.b44t.messenger.Cells.ChatActionCell;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.ActionBarMenuItem;
import com.b44t.messenger.Cells.ChatMessageCell;
import com.b44t.messenger.Cells.ChatUnreadCell;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.ChatActivityEnterView;
import com.b44t.messenger.Components.ChatAttachAlert;
import com.b44t.messenger.Components.ChatAvatarContainer;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.NumberTextView;
import com.b44t.messenger.Components.RecyclerListView;
import com.b44t.messenger.Components.SizeNotifierFrameLayout;
import com.b44t.messenger.ActionBar.Theme;
import java.io.File;
import java.net.URLDecoder;
@@ -107,13 +87,13 @@ import java.util.Collections;
import java.util.HashMap;
@SuppressWarnings("unchecked")
public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate,
public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ChatlistActivity.ChatlistActivityDelegate,
PhotoViewer.PhotoViewerProvider {
// data
private long dialog_id;
public MrChat m_mrChat = new MrChat(0);
private boolean m_isChatWithDeaddrop, m_isDeaddropInChatlist;
private boolean m_isChatWithDeaddrop /*, m_isDeaddropInChatlist*/;
private int[] m_msglist = {};
// the list view
@@ -180,9 +160,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final static int ID_COPY = 10;
private final static int ID_FORWARD = 11;
private final static int ID_DELETE_MESSAGES = 12;
private final static int ID_LEAVE_GROUP = 13;
private final static int ID_ATTACH = 14;
private final static int ID_SHOW_PROFILE = 15;
private final static int ID_DELETE_CHAT = 16;
private final static int ID_ARCHIVE_CHAT = 17;
private final static int ID_MUTE = 18;
private final static int ID_REPLY = 19;
private final static int ID_INFO = 20;
@@ -207,15 +189,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
m_mrChat = MrMailbox.getChat((int)dialog_id);
m_isChatWithDeaddrop = m_mrChat.getId()==MrChat.MR_CHAT_ID_DEADDROP;
m_isDeaddropInChatlist = false;
/*m_isDeaddropInChatlist = false;
if( m_isChatWithDeaddrop && MrMailbox.getConfigInt("show_deaddrop", 0)!=0 ) {
m_isDeaddropInChatlist = true;
}
}*/
startLoadFromMessageId = arguments.getInt("message_id", 0);
scrollToTopOnResume = arguments.getBoolean("scrollToTopOnResume", false);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedNewMessages);
@@ -341,7 +322,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatActivityEnterView.onDestroy();
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogsNeedReload);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedNewMessages);
@@ -436,9 +416,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
args.putBoolean("onlySelect", true);
args.putString("onlySelectTitle", context.getString(R.string.ForwardToTitle));
args.putString("selectAlertString", context.getString(R.string.ForwardMessagesTo));
DialogsActivity fragment = new DialogsActivity(args);
ChatlistActivity fragment = new ChatlistActivity(args);
fragment.setDelegate(ChatActivity.this);
presentFragment(fragment); // this results in a call to didSelectDialog()
presentFragment(fragment); // this results in a call to didSelectChat()
}
else if( id == ID_SHOW_PROFILE )
{
@@ -456,6 +436,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ProfileActivity fragment = new ProfileActivity(args);
presentFragment(fragment);
}
else if( id == ID_LEAVE_GROUP )
{
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MrMailbox.removeContactFromChat(m_mrChat.getId(), MrContact.MR_CONTACT_ID_SELF);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_CHAT_MEMBERS);
AndroidUtilities.showDoneHint(context);
}
});
builder.setNegativeButton(R.string.Cancel, null);
builder.setMessage(AndroidUtilities.replaceTags(context.getString(R.string.AskLeaveGroup)));
showDialog(builder.create());
}
else if ( id == ID_ARCHIVE_CHAT)
{
int do_archive = m_mrChat.getArchived()==0? 1: 0;
MrMailbox.archiveChat((int)dialog_id, do_archive);
MrMailbox.MrCallback(MrMailbox.MR_EVENT_MSGS_CHANGED, 0, 0);
AndroidUtilities.showDoneHint(context);
if( do_archive == 1 ) {
finishFragment();
}
}
else if ( id == ID_DELETE_CHAT)
{
// as the history may be a mix of messenger-messages and emails, it is not safe to delete it.
@@ -466,7 +471,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(context.getString(R.string.AreYouSureDeleteThisChat));
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if( MrMailbox.deleteChat((int)dialog_id)!=0 ) {
@@ -474,11 +479,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
finishFragment();
}
else {
AndroidUtilities.showErrorHint(getParentActivity()); // normally, there is no reason for deleteChat to fail() as everything is just local
AndroidUtilities.showErrorHint(getParentActivity());
}
}
});
builder.setNegativeButton(context.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
showDialog(builder.create());
} else if (id == ID_MUTE) {
toggleMute();
@@ -497,12 +502,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
String info_str = MrMailbox.getMsgInfo(getFirstSelectedId());
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(info_str);
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
;
}
});
builder.setPositiveButton(R.string.OK, null);
showDialog(builder.create());
actionBar.hideActionMode();
updateVisibleRowsFast();
@@ -544,7 +544,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
if( m_isChatWithDeaddrop && !m_isDeaddropInChatlist ) {
if( m_isChatWithDeaddrop /*&& !m_isDeaddropInChatlist*/ ) {
actionBar.setTitle(context.getString(R.string.Deaddrop));
}
else {
@@ -606,7 +606,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
headerItem.addSubItem(ID_SEARCH, context.getString(R.string.Search), 0);
m_canMute = true;
if( m_isChatWithDeaddrop && !m_isDeaddropInChatlist ) {
if( m_isChatWithDeaddrop /*&& !m_isDeaddropInChatlist*/ ) {
m_canMute = false;
}
@@ -614,15 +614,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
muteMenuEntry = headerItem.addSubItem(ID_MUTE, null, 0);
}
if( !m_isChatWithDeaddrop ) {
headerItem.addSubItem(ID_ATTACH, context.getString(R.string.AttachFiles), 0); // "Attach" means "Attach to chat", not "Attach to message" (which is not possible)
}
//if( !m_isChatWithDeaddrop ) {
//headerItem.addSubItem(ID_ATTACH, context.getString(R.string.AttachFiles), 0); // "Attach" means "Attach to chat", not "Attach to message" (which is not possible)
//}
if( !m_isChatWithDeaddrop || m_isDeaddropInChatlist ) {
if( !m_isChatWithDeaddrop ) {
headerItem.addSubItem(ID_SHOW_PROFILE, context.getString(R.string.ViewProfile), 0);
}
if( !m_isChatWithDeaddrop ) {
if( m_mrChat.getType()== MrChat.MR_CHAT_GROUP ) {
headerItem.addSubItem(ID_LEAVE_GROUP, context.getString(R.string.LeaveGroup), 0);
}
headerItem.addSubItem(ID_ARCHIVE_CHAT, context.getString(m_mrChat.getArchived()==0? R.string.ArchiveChat : R.string.UnarchiveChat), 0);
headerItem.addSubItem(ID_DELETE_CHAT, context.getString(R.string.DeleteChat), 0);
}
@@ -1069,8 +1070,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
//noinspection ResourceType
chatActivityEnterView.setId(ID_CHAT_COMPOSE_PANEL);
chatActivityEnterView.setAllowStickersAndGifs(false, false); // for the moment, we have no stickers
contentView.addView(chatActivityEnterView, contentView.getChildCount() - 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.BOTTOM));
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
@Override
@@ -1091,10 +1090,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onWindowSizeChanged(int size) {
}
@Override
public void onStickersTab(boolean opened) {
}
});
bottomOverlay = new FrameLayout(context);
@@ -1480,7 +1475,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int chatId = MrMailbox.createChatByContactId(fromId);
@@ -1494,7 +1489,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
});
builder.setNegativeButton(context.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
builder.setMessage(AndroidUtilities.replaceTags(String.format(context.getString(R.string.AskStartChatWith), name)));
showDialog(builder.create());
}
@@ -1914,12 +1909,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
else if (id == NotificationCenter.emojiDidLoaded)
{
if (chatListView != null) {
chatListView.invalidateViews();
}
}
else if (id == NotificationCenter.updateInterfaces)
{
int updateMask = (Integer) args[0];
@@ -2355,7 +2344,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void createDeleteMessagesAlert() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.AreYouSureDeleteMessages, selectedMessagesIds.size(), selectedMessagesIds.size()));
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
@@ -2372,11 +2361,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBar.hideActionMode();
updateVisibleRows();
MrMailbox.reloadMainChatlist();
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
showDialog(builder.create());
}
@@ -2438,7 +2426,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
public void didSelectDialog(DialogsActivity dialogsFragment, long fwd_chat_id, boolean param)
public void didSelectChat(ChatlistActivity dialogsFragment, long fwd_chat_id, boolean param)
{
if( selectedMessagesIds.size()>0) {
int ids[] = new int[selectedMessagesIds.size()], i = 0;
@@ -2746,13 +2734,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if( isMailto )
{
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(mContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
createChat(urlFinal);
createChat(urlFinal);
}
});
builder.setNegativeButton(mContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
builder.setMessage(AndroidUtilities.replaceTags(String.format(mContext.getString(R.string.AskStartChatWith), urlTitle)));
showDialog(builder.create());
}
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.Manifest;
import android.animation.ObjectAnimator;
@@ -42,6 +42,7 @@ import android.util.TypedValue;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -51,47 +52,36 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ImageLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.MrMsg;
import com.b44t.messenger.Utilities;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
import com.b44t.ui.ActionBar.BackDrawable;
import com.b44t.ui.Adapters.DialogsAdapter;
import com.b44t.ui.Adapters.DialogsSearchAdapter;
import com.b44t.ui.Cells.UserCell;
import com.b44t.ui.Cells.DialogCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.ActionBarMenuItem;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.EmptyTextProgressView;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.RecyclerListView;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.Cells.GreySectionCell;
import com.b44t.messenger.aosp.LinearLayoutManager;
import com.b44t.messenger.aosp.RecyclerView;
import com.b44t.messenger.ActionBar.BackDrawable;
import com.b44t.messenger.Cells.UserCell;
import com.b44t.messenger.Cells.ChatlistCell;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.ActionBarMenuItem;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.EmptyTextProgressView;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.RecyclerListView;
import com.b44t.messenger.ActionBar.Theme;
import java.util.ArrayList;
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public class ChatlistActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private RecyclerListView listView;
private LinearLayoutManager layoutManager;
private DialogsAdapter dialogsAdapter;
private DialogsSearchAdapter dialogsSearchAdapter;
private ChatlistAdapter chatlistAdapter;
private ChatlistSearchAdapter chatlistSearchAdapter;
private EmptyTextProgressView searchEmptyView;
private LinearLayout emptyView;
private ActionBarMenuItem passcodeItem;
private ImageView floatingButton;
// Floating hiding action as in Telegram - I think this is not useful:
// Floating hiding action as in T'gram - I think this is not useful:
// - it always takes a moment to check if the button is there or not (ot to let it appear)
// - if there is nothing to scroll the floting button does not move away -
// and covers always a part of the last row. This is not better than without moving away.
@@ -113,9 +103,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private boolean searchWas;
private boolean onlySelect;
private String onlySelectTitle = "";
private long openedDialogId;
private DialogsActivityDelegate delegate;
private boolean showArchivedOnly;
private ChatlistActivityDelegate delegate;
ActionBarMenuItem headerItem;
@@ -125,11 +116,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private static final int ID_SETTINGS = 5;
private static final int ID_DEADDROP = 7;
public interface DialogsActivityDelegate {
void didSelectDialog(DialogsActivity fragment, long dialog_id, boolean param);
public interface ChatlistActivityDelegate {
void didSelectChat(ChatlistActivity fragment, long dialog_id, boolean param);
}
public DialogsActivity(Bundle args) {
public ChatlistActivity(Bundle args) {
super(args);
}
@@ -146,10 +137,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
selectAlertString = arguments.getString("selectAlertString");
selectAlertPreviewString = arguments.getString("selectAlertPreviewString");
selectAlertOkButtonString = arguments.getString("selectAlertOkButtonString");
showArchivedOnly = arguments.getBoolean("showArchivedOnly");
}
NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
@@ -168,7 +159,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
super.onFragmentDestroy();
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.dialogsNeedReload);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
@@ -190,85 +180,101 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
});
ActionBarMenu menu = actionBar.createMenu();
if (!onlySelect ) {
passcodeItem = menu.addItem(ID_LOCK_APP, R.drawable.ic_ab_lock_screen);
updatePasscodeButton();
}
final ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
if( headerItem!=null ) {
headerItem.setVisibility(View.GONE);
actionBar.setBackButtonDrawable(new BackDrawable(false));
}
searching = true;
if (listView != null) {
if (!onlySelect) {
floatingButton.setVisibility(View.GONE);
}
}
if( !showArchivedOnly ) {
ActionBarMenu menu = actionBar.createMenu();
if (!onlySelect) {
passcodeItem = menu.addItem(ID_LOCK_APP, R.drawable.ic_ab_lock_screen);
updatePasscodeButton();
}
@Override
public boolean canCollapseSearch() {
return true;
}
@Override
public void onSearchCollapse() {
if( headerItem!=null ) {
headerItem.setVisibility(View.VISIBLE);
actionBar.setBackButtonDrawable(null);
}
searching = false;
searchWas = false;
if (listView != null) {
searchEmptyView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
if (!onlySelect) {
floatingButton.setVisibility(View.VISIBLE);
floatingHidden = true;
floatingButton.setTranslationY(AndroidUtilities.dp(100));
hideFloatingButton(false);
final ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchExpand() {
if (headerItem != null) {
headerItem.setVisibility(View.GONE);
actionBar.setBackButtonDrawable(new BackDrawable(false));
}
if (listView.getAdapter() != dialogsAdapter) {
listView.setAdapter(dialogsAdapter);
dialogsAdapter.notifyDataSetChanged();
}
}
updatePasscodeButton();
}
@Override
public void onTextChanged(EditText editText) {
String text = editText.getText().toString();
if (text.length() != 0 ) {
// text entered
searchWas = true;
if (searchEmptyView != null && listView.getEmptyView() != searchEmptyView) {
emptyView.setVisibility(View.GONE);
searchEmptyView.showTextView();
listView.setEmptyView(searchEmptyView);
}
if (dialogsSearchAdapter != null ) {
if( listView.getAdapter() != dialogsSearchAdapter ) {
listView.setAdapter(dialogsSearchAdapter);
searching = true;
if (listView != null) {
if (floatingButton!=null) {
floatingButton.setVisibility(View.GONE);
}
dialogsSearchAdapter.searchDialogs(text);
dialogsSearchAdapter.notifyDataSetChanged();
}
updatePasscodeButton();
}
@Override
public boolean canCollapseSearch() {
return true;
}
@Override
public void onSearchCollapse() {
if (headerItem != null) {
headerItem.setVisibility(View.VISIBLE);
actionBar.setBackButtonDrawable(null);
}
searching = false;
searchWas = false;
if (listView != null) {
searchEmptyView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
if (floatingButton!=null) {
floatingButton.setVisibility(View.VISIBLE);
floatingHidden = true;
floatingButton.setTranslationY(AndroidUtilities.dp(100));
hideFloatingButton(false);
}
if (listView.getAdapter() != chatlistAdapter) {
listView.setAdapter(chatlistAdapter);
chatlistAdapter.reloadChatlist();
chatlistAdapter.notifyDataSetChanged();
}
}
updatePasscodeButton();
}
@Override
public void onTextChanged(EditText editText) {
String text = editText.getText().toString();
if (text.length() != 0) {
// text entered
searchWas = true;
if (searchEmptyView != null && listView.getEmptyView() != searchEmptyView) {
emptyView.setVisibility(View.GONE);
searchEmptyView.showTextView();
listView.setEmptyView(searchEmptyView);
}
if (chatlistSearchAdapter != null) {
if (listView.getAdapter() != chatlistSearchAdapter) {
listView.setAdapter(chatlistSearchAdapter);
}
chatlistSearchAdapter.doSearch(text);
chatlistSearchAdapter.notifyDataSetChanged();
}
} else if (listView.getAdapter() == chatlistSearchAdapter) {
// empty text
listView.setAdapter(chatlistAdapter);
chatlistAdapter.reloadChatlist();
chatlistAdapter.notifyDataSetChanged();
}
}
else if( listView.getAdapter()==dialogsSearchAdapter ) {
// empty text
listView.setAdapter(dialogsAdapter);
dialogsAdapter.notifyDataSetChanged();
}
});
item.getSearchField().setHint(ApplicationLoader.applicationContext.getString(R.string.Search));
headerItem = menu.addItem(0, R.drawable.ic_ab_other);
headerItem.addSubItem(ID_NEW_CHAT, ApplicationLoader.applicationContext.getString(R.string.NewChat), 0);
headerItem.addSubItem(ID_NEW_GROUP, ApplicationLoader.applicationContext.getString(R.string.NewGroup), 0);
if(!onlySelect) {
headerItem.addSubItem(ID_DEADDROP, ApplicationLoader.applicationContext.getString(R.string.Deaddrop), 0);
headerItem.addSubItem(ID_SETTINGS, ApplicationLoader.applicationContext.getString(R.string.Settings), 0);
}
});
item.getSearchField().setHint(ApplicationLoader.applicationContext.getString(R.string.Search));
if (onlySelect) {
}
if( showArchivedOnly ) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(ApplicationLoader.applicationContext.getString(R.string.ArchivedChats));
}
else if (onlySelect) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(onlySelectTitle);
} else {
@@ -276,17 +282,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
actionBar.setAllowOverlayTitle(true);
headerItem = menu.addItem(0, R.drawable.ic_ab_other);
headerItem.addSubItem(ID_NEW_CHAT, ApplicationLoader.applicationContext.getString(R.string.NewChat), 0);
headerItem.addSubItem(ID_NEW_GROUP, ApplicationLoader.applicationContext.getString(R.string.NewGroup), 0);
headerItem.addSubItem(ID_DEADDROP, ApplicationLoader.applicationContext.getString(R.string.Deaddrop), 0);
headerItem.addSubItem(ID_SETTINGS, ApplicationLoader.applicationContext.getString(R.string.Settings), 0);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
if (onlySelect) {
if (onlySelect || showArchivedOnly) {
finishFragment();
}
} else if (id == ID_LOCK_APP) {
@@ -330,7 +330,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
args.putInt("chat_id", MrChat.MR_CHAT_ID_DEADDROP);
presentFragment(new ChatActivity(args));
} else if (id == ID_SETTINGS) {
presentFragment(new SettingsActivity());
presentFragment(new SettingsFragment());
}
}
}
@@ -363,36 +363,79 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
// handle single click
long dialog_id = 0;
long chat_id = 0;
int message_id = 0;
RecyclerView.Adapter adapter = listView.getAdapter();
if (adapter == dialogsAdapter) {
MrChat mrChat = dialogsAdapter.getItem(position);
if (adapter == chatlistAdapter) {
MrChat mrChat = chatlistAdapter.getChatByIndex(position);
if (mrChat == null) {
return;
}
dialog_id = mrChat.getId();
} else if (adapter == dialogsSearchAdapter) {
Object obj = dialogsSearchAdapter.getItem(position);
chat_id = mrChat.getId();
} else if (adapter == chatlistSearchAdapter) {
Object obj = chatlistSearchAdapter.getItem(position);
if( obj instanceof MrChat ) {
dialog_id = ((MrChat)obj).getId();
chat_id = ((MrChat)obj).getId();
}
else if( obj instanceof MrMsg) {
MrMsg mrMsg = (MrMsg)obj;
dialog_id = mrMsg.getChatId();
chat_id = mrMsg.getChatId();
message_id = mrMsg.getId();
}
}
if (dialog_id == 0) {
if (chat_id == 0) {
return;
}
if (onlySelect) {
didSelectResult(dialog_id, true, false);
} else {
/* select a chat */
didSelectResult(chat_id, true, false);
} else if( chat_id == MrChat.MR_CHAT_ID_DEADDROP ) {
/* start new chat */
final MrMsg msg = chatlistAdapter.getMsgByIndex(position);
if( ChatlistCell.deaddropClosePressed ) {
MrMailbox.marknoticedContact(msg.getFromId());
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
else {
MrContact contact = MrMailbox.getContact(msg.getFromId());
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int belonging_chat_id = MrMailbox.createChatByContactId(msg.getFromId());
if( belonging_chat_id != 0 ) {
Bundle args = new Bundle();
args.putInt("chat_id", belonging_chat_id);
presentFragment(new ChatActivity(args), false);
}
}
});
builder.setNegativeButton(R.string.NotNow, null);
builder.setNeutralButton(R.string.Never, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MrMailbox.blockContact(msg.getFromId(), 1);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
}
});
builder.setMessage(AndroidUtilities.replaceTags(String.format(context.getString(R.string.AskStartChatWith), contact.getNameNAddr())));
showDialog(builder.create());
}
} else if( chat_id == MrChat.MR_CHAT_ID_ARCHIVED_LINK ) {
Bundle args = new Bundle();
args.putInt("chat_id", (int)dialog_id);
args.putBoolean("showArchivedOnly", true);
args.putBoolean("onlySelect", onlySelect);
args.putString("onlySelectTitle", onlySelectTitle);
args.putString("selectAlertString", selectAlertString);
args.putString("selectAlertPreviewString", selectAlertPreviewString);
args.putString("selectAlertOkButtonString", selectAlertOkButtonString);
presentFragment(new ChatlistActivity(args));
} else {
/* open exiting chat */
Bundle args = new Bundle();
args.putInt("chat_id", (int)chat_id);
if (message_id != 0) {
args.putInt("message_id", message_id);
}
@@ -402,6 +445,70 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
});
listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
@Override
public boolean onItemClick(View view, int position) {
RecyclerView.Adapter adapter = listView.getAdapter();
MrChat tempChat = null;
if (adapter == chatlistAdapter) {
tempChat = chatlistAdapter.getChatByIndex(position);
}
else if( adapter == chatlistSearchAdapter ) {
Object obj = chatlistSearchAdapter.getItem(position);
if( obj instanceof MrChat ) {
tempChat = ((MrChat)obj);
}
else if( obj instanceof MrMsg ) {
MrMsg mrMsg = (MrMsg) obj;
tempChat = MrMailbox.getChat(mrMsg.getChatId());
}
}
if( tempChat!=null ) {
final MrChat mrChat = tempChat;
if (mrChat != null && mrChat.getId()>MrChat.MR_CHAT_ID_LAST_SPECIAL) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[]{
context.getString(mrChat.getArchived()==0? R.string.ArchiveChat : R.string.UnarchiveChat),
context.getString(R.string.DeleteChat)
};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int clickedEntry) {
if( clickedEntry==0 ) {
MrMailbox.archiveChat(mrChat.getId(), mrChat.getArchived() == 0 ? 1 : 0);
MrMailbox.MrCallback(MrMailbox.MR_EVENT_MSGS_CHANGED, 0, 0);
AndroidUtilities.showDoneHint(context);
}
else if( clickedEntry==1 ) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(context.getString(R.string.AreYouSureDeleteThisChat));
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if( MrMailbox.deleteChat(mrChat.getId())!=0 ) {
MrMailbox.MrCallback(MrMailbox.MR_EVENT_MSGS_CHANGED, 0, 0);
AndroidUtilities.showDoneHint(context);
}
else {
AndroidUtilities.showErrorHint(context);
}
}
});
builder.setNegativeButton(R.string.Cancel, null);
showDialog(builder.create());
}
}
});
showDialog(builder.create());
return true; // do haptical feedback
}
}
return false;
}
});
searchEmptyView = new EmptyTextProgressView(context);
searchEmptyView.setVisibility(View.GONE);
searchEmptyView.setShowAtCenter(true);
@@ -437,33 +544,35 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
textView.setLineSpacing(AndroidUtilities.dp(2), 1);
emptyView.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
floatingButton = new ImageView(context);
floatingButton.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
floatingButton.setBackgroundResource(R.drawable.floating_states);
floatingButton.setImageResource(R.drawable.floating_pencil);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
if(!onlySelect && !showArchivedOnly) {
floatingButton = new ImageView(context);
floatingButton.setVisibility(View.VISIBLE);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
floatingButton.setBackgroundResource(R.drawable.floating_states);
floatingButton.setImageResource(R.drawable.floating_pencil);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
frameLayout.addView(floatingButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));
floatingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("do_what", ContactsActivity.SELECT_CONTACT_FOR_NEW_CHAT);
presentFragment(new ContactsActivity(args));
}
});
}
frameLayout.addView(floatingButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));
floatingButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putInt("do_what", ContactsActivity.SELECT_CONTACT_FOR_NEW_CHAT);
presentFragment(new ContactsActivity(args));
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@@ -514,9 +623,17 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
});
dialogsAdapter = new DialogsAdapter(context);
listView.setAdapter(dialogsAdapter);
dialogsSearchAdapter = new DialogsSearchAdapter(context);
int listflags = 0;
if( showArchivedOnly ) {
listflags = MrMailbox.MR_GCL_ARCHIVED_ONLY;
}
else if( onlySelect ) {
listflags = MrMailbox.MR_GCL_NO_SPECIALS;
}
chatlistAdapter = new ChatlistAdapter(context, listflags);
listView.setAdapter(chatlistAdapter);
chatlistSearchAdapter = new ChatlistSearchAdapter(context);
searchEmptyView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
@@ -527,11 +644,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override
public void onResume() {
super.onResume();
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
if (chatlistAdapter != null) {
chatlistAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
if (chatlistSearchAdapter != null) {
chatlistSearchAdapter.notifyDataSetChanged();
}
if (checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
checkPermission = false;
@@ -588,14 +705,14 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (!pm.isIgnoringBatteryOptimizations(ApplicationLoader.applicationContext.getPackageName())) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(AndroidUtilities.replaceTags(ApplicationLoader.applicationContext.getString(R.string.PermissionBattery)));
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
askForIgnoreBatteryOptimization();
}
});
builder.setCancelable(false);
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
builder.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
askForOtherPermissons();
@@ -648,7 +765,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (!onlySelect && floatingButton != null) {
if (floatingButton != null) {
floatingButton.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
@@ -689,18 +806,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@SuppressWarnings("unchecked")
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.dialogsNeedReload) {
if (dialogsAdapter != null) {
dialogsAdapter.notifyDataSetChanged();
/* EDIT BY MR
if (dialogsAdapter.isDataSetChanged()) {
dialogsAdapter.notifyDataSetChanged();
} else {
updateVisibleRows(MrMailbox.UPDATE_MASK_NEW_MESSAGE);
}
*/
if (chatlistAdapter != null) {
chatlistAdapter.reloadChatlist();
chatlistAdapter.notifyDataSetChanged();
}
if (dialogsSearchAdapter != null) {
dialogsSearchAdapter.notifyDataSetChanged();
if (chatlistSearchAdapter != null) {
chatlistSearchAdapter.searchAgain();
chatlistSearchAdapter.notifyDataSetChanged();
}
if (listView != null) {
try {
@@ -714,8 +826,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
} catch (Exception e) {
}
}
} else if (id == NotificationCenter.emojiDidLoaded) {
updateVisibleRows(0);
} else if (id == NotificationCenter.updateInterfaces) {
updateVisibleRows((Integer) args[0]);
} else if (id == NotificationCenter.contactsDidLoaded) {
@@ -741,7 +851,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
private void hideFloatingButton(boolean hide) {
if (floatingHidden == hide) {
if (floatingButton == null || floatingHidden == hide) {
return;
}
floatingHidden = hide;
@@ -758,11 +868,12 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof DialogCell) {
if (listView.getAdapter() != dialogsSearchAdapter) {
DialogCell cell = (DialogCell) child;
if (child instanceof ChatlistCell) {
if (listView.getAdapter() != chatlistSearchAdapter) {
ChatlistCell cell = (ChatlistCell) child;
if ((mask & MrMailbox.UPDATE_MASK_NEW_MESSAGE) != 0) {
cell.checkCurrentDialogIndex();
//cell.checkCurrentChatlistIndex();
cell.update(mask);
} else if ((mask & MrMailbox.UPDATE_MASK_SELECT_DIALOG) != 0) {
;
} else {
@@ -775,12 +886,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}
public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) {
delegate = dialogsActivityDelegate;
}
public boolean isMainDialogList() {
return delegate == null;
public void setDelegate(ChatlistActivityDelegate chatlistActivityDelegate) {
delegate = chatlistActivityDelegate;
}
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
@@ -802,15 +909,249 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
didSelectResult(dialog_id, false, false);
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
showDialog(builder.create());
} else {
if (delegate != null) {
delegate.didSelectDialog(DialogsActivity.this, dialog_id, param);
delegate.didSelectChat(ChatlistActivity.this, dialog_id, param);
delegate = null;
} else {
finishFragment();
}
}
}
private class ChatlistAdapter extends RecyclerView.Adapter {
private Context mContext;
private int m_listflags;
private MrChatlist m_chatlist = new MrChatlist(0);
private class Holder extends RecyclerView.ViewHolder {
public Holder(View itemView) {
super(itemView);
}
}
public void reloadChatlist() {
m_chatlist = MrMailbox.getChatlist(m_listflags, null);
}
public ChatlistAdapter(Context context, int listflags) {
mContext = context;
m_listflags = listflags;
reloadChatlist();
}
@Override
public int getItemCount() {
return m_chatlist.getCnt();
}
public MrChat getChatByIndex(int i) {
return m_chatlist.getChatByIndex(i);
}
public MrMsg getMsgByIndex(int i) {
return m_chatlist.getMsgByIndex(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = new ChatlistCell(mContext);
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
return new ChatlistAdapter.Holder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
if (viewHolder.getItemViewType() == 0) {
ChatlistCell cell = (ChatlistCell) viewHolder.itemView;
cell.useSeparator = (i != getItemCount() - 1);
MrChat mrChat = getChatByIndex(i);
MrPoortext mrSummary = m_chatlist.getSummaryByIndex(i, mrChat);
cell.setChat(mrChat, mrSummary, i, true);
}
}
@Override
public int getItemViewType(int i) {
return 0;
}
}
private class ChatlistSearchAdapter extends RecyclerView.Adapter {
private Context mContext;
private static final int ROWTYPE_HEADLINE = 0;
private static final int ROWTYPE_CHAT = 1;
private static final int ROWTYPE_MSG = 2;
int rowChatsHeadline = -1;
int rowFirstChat = -1, rowLastChat = -1;
int rowMsgsHeadline = -1;
int rowFirstMsg = -1, rowLastMsg = -1;
int rowCount = 0;
MrChatlist m_chatlist = new MrChatlist(0);
int m_chatlistCnt = 0;
int[] m_msgIds = {};
public String m_lastQuery;
private class Holder extends RecyclerView.ViewHolder {
public Holder(View itemView) {
super(itemView);
}
}
public ChatlistSearchAdapter(Context context) {
mContext = context;
}
public void searchAgain()
{
doSearch(m_lastQuery);
}
public void doSearch(String query) {
m_lastQuery = query;
rowCount = 0;
m_chatlist = MrMailbox.getChatlist(0, query);
m_chatlistCnt = m_chatlist.getCnt();
if( m_chatlistCnt>0 ) {
rowChatsHeadline = rowCount++;
rowFirstChat = rowCount;
rowCount += m_chatlistCnt;
rowLastChat = rowCount-1;
}
else {
rowChatsHeadline = -1;
rowFirstChat = -1;
rowLastChat = -1;
}
m_msgIds = MrMailbox.searchMsgs(0, query);
if( m_msgIds.length>0 ) {
rowMsgsHeadline = rowCount++;
rowFirstMsg = rowCount;
rowCount += m_msgIds.length;
rowLastMsg = rowCount-1;
}
else {
rowMsgsHeadline = -1;
rowFirstMsg = -1;
rowLastMsg = -1;
}
}
@Override
public int getItemCount() {
return rowCount;
}
public Object getItem(int i) {
if( i>=rowFirstChat && i<=rowLastChat ) {
return m_chatlist.getChatByIndex(i-rowFirstChat);
}
else if( i>=rowFirstMsg && i<=rowLastMsg ) {
return MrMailbox.getMsg(m_msgIds[i-rowFirstMsg]);
}
return null;
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view;
switch( viewType ) {
case ROWTYPE_CHAT:
case ROWTYPE_MSG:
view = new ChatlistCell(mContext);
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
break;
default:
view = new GreySectionCell(mContext);
break;
}
return new Holder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i)
{
switch (viewHolder.getItemViewType() )
{
case ROWTYPE_CHAT: {
int j = i - rowFirstChat;
if( j >= 0 && j < m_chatlistCnt ) {
ChatlistCell cell = (ChatlistCell) viewHolder.itemView;
cell.useSeparator = (j != m_chatlistCnt - 1);
MrChat mrChat = m_chatlist.getChatByIndex(j);
MrPoortext mrSummary = m_chatlist.getSummaryByIndex(j, mrChat);
cell.setChat(mrChat, mrSummary, -1,
true /*always show unread count*/);
}
}
break;
case ROWTYPE_MSG: {
int j = i - rowFirstMsg;
if( j >= 0 && j < m_msgIds.length ) {
ChatlistCell cell = (ChatlistCell) viewHolder.itemView;
cell.useSeparator = (j != m_msgIds.length - 1);
MrMsg mrMsg = MrMailbox.getMsg(m_msgIds[j]);
MrChat mrChat = MrMailbox.getChat(mrMsg.getChatId());
MrPoortext mrSummary = mrMsg.getSummary(mrChat);
cell.setChat(mrChat, mrSummary, -1,
mrMsg.getState()==MrMsg.MR_IN_FRESH /*show unread count only if the message itself is unread*/ );
}
}
break;
case ROWTYPE_HEADLINE: {
GreySectionCell headlineCell = (GreySectionCell) viewHolder.itemView;
if (i == rowChatsHeadline) {
headlineCell.setText(mContext.getResources().getQuantityString(R.plurals.Chats, m_chatlistCnt, m_chatlistCnt));
} else if (i == rowMsgsHeadline) {
headlineCell.setText(mContext.getResources().getQuantityString(R.plurals.messages, m_msgIds.length, m_msgIds.length));
}
}
break;
}
}
@Override
public int getItemViewType(int i) {
if( i>=rowFirstChat && i<=rowLastChat ) {
return ROWTYPE_CHAT;
}
else if( i>=rowFirstMsg && i<=rowLastMsg ) {
return ROWTYPE_MSG;
}
return ROWTYPE_HEADLINE;
}
}
}
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.Manifest;
import android.app.Activity;
@@ -40,11 +40,11 @@ import com.b44t.messenger.MediaController;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.FileLoader;
import com.b44t.messenger.UserConfig;
import com.b44t.ui.LaunchActivity;
import com.b44t.ui.PhotoAlbumPickerActivity;
import com.b44t.ui.PhotoCropActivity;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.PhotoViewer;
import com.b44t.messenger.LaunchActivity;
import com.b44t.messenger.PhotoAlbumPickerActivity;
import com.b44t.messenger.PhotoCropActivity;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.PhotoViewer;
import java.io.File;
import java.util.ArrayList;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Bitmap;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Adapters;
package com.b44t.messenger.Components;
import android.database.DataSetObserver;
import android.view.View;
@@ -21,14 +21,14 @@
******************************************************************************/
package com.b44t.messenger.browser;
package com.b44t.messenger.Components;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.b44t.ui.LaunchActivity;
import com.b44t.messenger.LaunchActivity;
public class Browser {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.Manifest;
import android.animation.Animator;
@@ -40,7 +40,6 @@ import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.TextWatcher;
@@ -61,7 +60,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.Emoji;
import com.b44t.messenger.EmojiInputView;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.MrContact;
@@ -72,11 +71,10 @@ import com.b44t.messenger.R;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.ChatActivity;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.ChatActivity;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate /*, StickersAlert.StickersAlertDelegate*/ {
@@ -86,7 +84,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
void needSendTyping();
void onTextChanged(CharSequence text, boolean bigChange);
void onWindowSizeChanged(int size);
void onStickersTab(boolean opened);
}
private class SeekBarWaveformView extends View {
@@ -225,7 +222,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
private EditTextCaption messageEditText;
private ImageView sendButton;
private ImageView emojiButton;
private EmojiView emojiView;
private EmojiInputView emojiView;
private TextView recordTimeText;
private ImageView audioRecordButton;
private FrameLayout recordPanel;
@@ -424,7 +421,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
NotificationCenter.getInstance().addObserver(this, NotificationCenter.recordProgressChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidSent);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioRouteChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidReset);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioProgressDidChanged);
@@ -570,7 +566,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
for (int i = 0; i < spans.length; i++) {
editable.removeSpan(spans[i]);
}
Emoji.replaceEmoji(editable, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
EmojiInputView.replaceEmoji(editable, false);
processChange = false;
}
}
@@ -594,7 +590,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
ImageView imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setImageResource(R.drawable.delete_reply);
imageView.setImageResource(R.drawable.dismiss_recording);
recordedAudioPanel.addView(imageView, LayoutHelper.createFrame(48, 48));
imageView.setOnClickListener(new OnClickListener() {
@Override
@@ -799,24 +795,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return false;
}
public void setAllowStickersAndGifs(boolean value, boolean value2) {
if ((allowStickers != value || allowGifs != value2) && emojiView != null) {
if (emojiView.getVisibility() == VISIBLE) {
hidePopup(false);
}
sizeNotifierLayout.removeView(emojiView);
emojiView = null;
}
allowStickers = value;
allowGifs = value2;
}
public void setOpenGifsTabFirst() {
createEmojiView();
emojiView.loadGifRecent();
emojiView.switchToGifRecent();
}
public boolean isTopViewVisible() {
return false;
}
@@ -838,13 +816,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.recordProgressChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioDidSent);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioRouteChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioDidReset);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioProgressDidChanged);
if (emojiView != null) {
emojiView.onDestroy();
}
if (mWakeLock != null) {
try {
mWakeLock.release();
@@ -1331,9 +1305,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (emojiView != null) {
return;
}
emojiView = new EmojiView(allowStickers, allowGifs, parentActivity);
emojiView = new EmojiInputView(parentActivity);
emojiView.setVisibility(GONE);
emojiView.setListener(new EmojiView.Listener() {
emojiView.setListener(new EmojiInputView.Listener() {
public boolean onBackspace() {
if (messageEditText.length() == 0) {
return false;
@@ -1349,7 +1323,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
try {
innerTextChange = 2;
CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
CharSequence localCharSequence = EmojiInputView.replaceEmoji(symbol, false);
messageEditText.setText(messageEditText.getText().insert(i, localCharSequence));
int j = i + localCharSequence.length();
messageEditText.setSelection(j, j);
@@ -1360,47 +1334,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
}
/*public void onStickerSelected(TLRPC.Document sticker) {
ChatActivityEnterView.this.onStickerSelected(sticker);
}*/
@Override
public void onStickersSettingsClick() {
if (parentFragment != null) {
//parentFragment.presentFragment(new StickersActivity()); -- EDIT BY MR
}
}
@Override
public void onGifSelected(TLRPC.Document gif) {
SendMessagesHelper.getInstance().sendSticker(gif, dialog_id);
if ((int) dialog_id == 0) {
//MessagesController.getInstance().saveGif(gif);
}
if (delegate != null) {
delegate.onMessageSend(null);
}
}
@Override
public void onGifTab(boolean opened) {
if (!AndroidUtilities.usingHardwareInput) {
if (opened) {
if (messageEditText.length() == 0) {
messageEditText.setText("@gif ");
messageEditText.setSelection(messageEditText.length());
}
} else if (messageEditText.getText().toString().equals("@gif ")) {
messageEditText.setText("");
}
}
}
@Override
public void onStickersTab(boolean opened) {
delegate.onStickersTab(opened);
}
@Override
public void onClearEmojiRecent() {
if (parentFragment == null || parentActivity == null) {
@@ -1408,13 +1341,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
builder.setMessage(ApplicationLoader.applicationContext.getString(R.string.ClearRecentEmoji));
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.ClearButton).toUpperCase(), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.ClearButton, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
emojiView.clearRecentEmoji();
emojiView.clearRecent();
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
parentFragment.showDialog(builder.create());
}
});
@@ -1422,14 +1355,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
sizeNotifierLayout.addView(emojiView);
}
/*@Override
public void onStickerSelected(TLRPC.Document sticker) {
SendMessagesHelper.getInstance().sendSticker(sticker, dialog_id);
if (delegate != null) {
delegate.onMessageSend(null);
}
}*/
private void showPopup(int show, int contentType /*0=emojiView, 1=botKeyboardView*/ ) {
if (show == 1) {
if (contentType == 0 && emojiView == null) {
@@ -1531,17 +1456,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return emojiView != null && emojiView.getVisibility() == VISIBLE;
}
public boolean isKeyboardVisible() {
return keyboardVisible;
}
public void addRecentGif(MediaController.SearchImage searchImage) {
if (emojiView == null) {
return;
}
emojiView.addRecentGif(searchImage);
}
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
if (height > AndroidUtilities.dp(50) && keyboardVisible) {
@@ -1612,11 +1526,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.emojiDidLoaded) {
if (emojiView != null) {
emojiView.invalidateViews();
}
} else if (id == NotificationCenter.recordProgressChanged) {
if (id == NotificationCenter.recordProgressChanged) {
long t = (Long) args[0];
Long time = t / 1000;
int ms = (int) (t % 1000L) / 10;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.Manifest;
import android.animation.Animator;
@@ -49,19 +49,18 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MediaController;
import com.b44t.messenger.MessageObject;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.aosp.LinearLayoutManager;
import com.b44t.messenger.R;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.aosp.RecyclerView;
import com.b44t.messenger.TLRPC;
import com.b44t.ui.ActionBar.BottomSheet;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.Cells.PhotoAttachPhotoCell;
import com.b44t.ui.ChatActivity;
import com.b44t.ui.PhotoViewer;
import com.b44t.messenger.ActionBar.BottomSheet;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.Cells.PhotoAttachPhotoCell;
import com.b44t.messenger.ChatActivity;
import com.b44t.messenger.PhotoViewer;
import java.util.ArrayList;
import java.util.HashMap;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.os.Build;
@@ -34,11 +34,11 @@ import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ContactsController;
import com.b44t.messenger.MrChat;
import com.b44t.messenger.MrMailbox;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.SimpleTextView;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.ChatActivity;
import com.b44t.ui.ProfileActivity;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.SimpleTextView;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.ChatActivity;
import com.b44t.messenger.ProfileActivity;
public class ChatAvatarContainer extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.animation.ObjectAnimator;
import android.content.Context;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Bitmap;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -20,7 +20,7 @@
*
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.util.TypedValue;
@@ -32,7 +32,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
public class EmptyTextProgressView extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.annotation.SuppressLint;
import android.app.Activity;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.graphics.Path;
import android.text.StaticLayout;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.animation.Animator;
import android.animation.ObjectAnimator;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -61,13 +61,12 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.ActionBar.Theme;
import java.util.ArrayList;
import java.util.Locale;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Bitmap;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -49,15 +49,14 @@ import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.support.widget.LinearLayoutManager;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.aosp.LinearLayoutManager;
import com.b44t.messenger.aosp.RecyclerView;
import com.b44t.messenger.DispatchQueue;
import com.b44t.messenger.R;
import com.b44t.messenger.Utilities;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.Cells.PhotoEditToolCell;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.Cells.PhotoEditToolCell;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Typeface;
@@ -33,9 +33,8 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.ActionBar.Theme;
public class PickerBottomLayout extends FrameLayout {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
public class Point {
public float x;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.animation.ObjectAnimator;
import android.content.Context;
@@ -34,7 +34,7 @@ import android.graphics.PorterDuffXfermode;
import android.view.View;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.ActionBar.Theme;
public class RadioButton extends View {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
public class Rect {
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.content.res.TypedArray;
@@ -34,7 +34,7 @@ import android.view.ViewConfiguration;
import android.view.ViewGroup;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.support.widget.RecyclerView;
import com.b44t.messenger.aosp.RecyclerView;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.hardware.SensorManager;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
public class Size {
public float width;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Rect;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.os.Build;
import android.text.Layout;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.graphics.Paint;
import android.graphics.Typeface;
@@ -21,17 +21,15 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.R;
public class VideoSeekBarView extends View {
@@ -21,9 +21,8 @@
******************************************************************************/
package com.b44t.ui.Components;
package com.b44t.messenger.Components;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -20,7 +20,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.content.Context;
import android.content.Intent;
@@ -36,16 +36,11 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Cells.HeaderCell;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Cells.HeaderCell;
import com.b44t.messenger.Components.LayoutHelper;
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@@ -23,7 +23,7 @@
// this file also contains the GroupCreateActivity functionality
package com.b44t.ui;
package com.b44t.messenger;
import android.app.Activity;
import android.app.AlertDialog;
@@ -45,6 +45,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AbsListView;
import android.widget.AdapterView;
@@ -54,24 +55,14 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.ContactsController;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.Utilities;
import com.b44t.messenger.TLRPC;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.ContactsAdapter;
import com.b44t.ui.Cells.UserCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.ActionBarMenuItem;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.ChipSpan;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BaseFragmentAdapter;
import com.b44t.messenger.Cells.UserCell;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.ActionBarMenuItem;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.ChipSpan;
import com.b44t.messenger.Components.LayoutHelper;
import java.util.ArrayList;
import java.util.HashMap;
@@ -428,7 +419,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int belonging_chat_id = MrMailbox.createChatByContactId(user.id);
@@ -439,7 +430,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
}
});
builder.setNegativeButton(context.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
builder.setMessage(AndroidUtilities.replaceTags(String.format(context.getString(R.string.AskStartChatWith), name)));
showDialog(builder.create());
}
@@ -639,4 +630,85 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
userSelectEditText.setSelection(ssb.length());
return span;
}
private class ContactsAdapter extends BaseFragmentAdapter {
private Context mContext;
private HashMap<Integer, ?> checkedMap;
private boolean scrolling;
private String lastQuery;
private int[] contactIds;
public ContactsAdapter(Context context) {
mContext = context;
contactIds = MrMailbox.getKnownContacts(null);
}
public void setCheckedMap(HashMap<Integer, ?> map) {
checkedMap = map;
}
public void setIsScrolling(boolean value) {
scrolling = value;
}
public void search(String query) {
contactIds = MrMailbox.getKnownContacts(query);
lastQuery = query;
}
public void searchAgain() {
contactIds = MrMailbox.getKnownContacts(lastQuery);
}
@Override
public Object getItem(int curr_user_index) {
if(curr_user_index>=0 && curr_user_index<contactIds.length) {
TLRPC.User u = new TLRPC.User();
u.id = contactIds[curr_user_index];
return u;
}
return null;
}
@Override
public boolean isEnabled(int row) {
return true;
}
@Override
public int getCount() {
return contactIds.length;
}
@Override
public View getView(int curr_user_index, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = new UserCell(mContext, 1, 1);
((UserCell) convertView).setStatusColors(0xffa8a8a8);
}
if(curr_user_index>=0 && curr_user_index<contactIds.length) {
int curr_user_id = contactIds[curr_user_index];
MrContact mrContact = MrMailbox.getContact(curr_user_id);
((UserCell) convertView).setData(mrContact, 0);
if (checkedMap != null) {
((UserCell) convertView).setChecked(checkedMap.containsKey(curr_user_id), !scrolling);
}
}
return convertView;
}
@Override
public int getItemViewType(int position) {
return 0;
}
@Override
public int getViewTypeCount() {
return 1;
}
}
}
@@ -42,10 +42,9 @@ import android.graphics.Shader;
import android.net.Uri;
import android.os.Build;
import android.provider.ContactsContract;
import android.util.Log;
import android.view.View;
import com.b44t.ui.Components.AvatarDrawable;
import com.b44t.messenger.Components.AvatarDrawable;
import java.io.InputStream;
import java.util.HashMap;
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.animation.Animator;
import android.animation.AnimatorSet;
@@ -43,19 +43,15 @@ import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.LocaleController;
import com.b44t.messenger.R;
import com.b44t.ui.ActionBar.BackDrawable;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Cells.SharedDocumentCell;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.NumberTextView;
import com.b44t.messenger.ActionBar.BackDrawable;
import com.b44t.messenger.ActionBar.Theme;
import com.b44t.messenger.Components.BaseFragmentAdapter;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Cells.SharedDocumentCell;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.NumberTextView;
import java.io.BufferedReader;
import java.io.File;
@@ -1,491 +0,0 @@
/*******************************************************************************
*
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Locale;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
public class Emoji {
private static HashMap<CharSequence, DrawableInfo> rects = new HashMap<>();
private static int drawImgSize;
private static int bigImgSize;
private static boolean inited = false;
private static Paint placeholderPaint;
private static final int splitCount = 4;
private static Bitmap emojiBmp[][] = new Bitmap[5][splitCount];
private static boolean loadingEmoji[][] = new boolean[5][splitCount];
private static final int[][] cols = {
{11, 11, 11, 11},
{6, 6, 6, 6},
{9, 9, 9, 9},
{9, 9, 9, 9},
{8, 8, 8, 7}
};
static {
int emojiFullSize;
if (AndroidUtilities.density <= 1.0f) {
emojiFullSize = 32;
} else if (AndroidUtilities.density <= 1.5f) {
emojiFullSize = 48;
} else if (AndroidUtilities.density <= 2.0f) {
emojiFullSize = 64;
} else {
emojiFullSize = 64;
}
drawImgSize = AndroidUtilities.dp(20);
bigImgSize = AndroidUtilities.dp(32);
for (int j = 0; j < EmojiData.data.length; j++) {
int count2 = (int) Math.ceil(EmojiData.data[j].length / (float) splitCount);
int position;
for (int i = 0; i < EmojiData.data[j].length; i++) {
int page = i / count2;
position = i - page * count2;
Rect rect = new Rect((position % cols[j][page]) * emojiFullSize, (position / cols[j][page]) * emojiFullSize, (position % cols[j][page] + 1) * emojiFullSize, (position / cols[j][page] + 1) * emojiFullSize);
rects.put(EmojiData.data[j][i], new DrawableInfo(rect, (byte) j, (byte) page));
}
}
placeholderPaint = new Paint();
placeholderPaint.setColor(0x00000000);
}
/*private static void loadEmoji(final int page, final int page2) {
try {
float scale;
int imageResize = 1;
if (AndroidUtilities.density <= 1.0f) {
scale = 2.0f;
imageResize = 2;
} else if (AndroidUtilities.density <= 1.5f) {
scale = 3.0f;
imageResize = 2;
} else if (AndroidUtilities.density <= 2.0f) {
scale = 2.0f;
} else {
scale = 2.0f;
}
String imageName;
File imageFile;
try {
for (int a = 4; a < 6; a++) {
imageName = String.format(Locale.US, "v%d_emoji%.01fx_%d.jpg", a, scale, page);
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (imageFile.exists()) {
imageFile.delete();
}
imageName = String.format(Locale.US, "v%d_emoji%.01fx_a_%d.jpg", a, scale, page);
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (imageFile.exists()) {
imageFile.delete();
}
}
} catch (Exception e) {
}
imageName = String.format(Locale.US, "v7_emoji%.01fx_%d_%d.jpg", scale, page, page2);
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (!imageFile.exists()) {
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
AndroidUtilities.copyFile(is, imageFile);
is.close();
}
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeFile(imageFile.getAbsolutePath(), opts);
int width = opts.outWidth / imageResize;
int height = opts.outHeight / imageResize;
int stride = width * 4;
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, width, height, stride);
imageName = String.format(Locale.US, "v7_emoji%.01fx_a_%d_%d.jpg", scale, page, page2);
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
if (!imageFile.exists()) {
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
AndroidUtilities.copyFile(is, imageFile);
is.close();
}
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, width, height, stride);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
emojiBmp[page][page2] = bitmap;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.emojiDidLoaded);
}
});
} catch (Throwable x) {
//Log.i("DeltaChat", "Error loading emoji", x);
}
}*/
/*
public static void invalidateAll(View view) {
if (view instanceof ViewGroup) {
ViewGroup g = (ViewGroup) view;
for (int i = 0; i < g.getChildCount(); i++) {
invalidateAll(g.getChildAt(i));
}
} else if (view instanceof TextView) {
view.invalidate();
}
}
*/
public static String fixEmoji(String emoji) {
char ch;
int lenght = emoji.length();
for (int a = 0; a < lenght; a++) {
ch = emoji.charAt(a);
if (ch >= 0xD83C && ch <= 0xD83E) {
if (ch == 0xD83C && a < lenght - 1) {
ch = emoji.charAt(a + 1);
if (ch == 0xDE2F || ch == 0xDC04 || ch == 0xDE1A || ch == 0xDD7F) {
emoji = emoji.substring(0, a + 2) + "\uFE0F" + emoji.substring(a + 2);
lenght++;
a += 2;
} else {
a++;
}
} else {
a++;
}
} else if (ch == 0x20E3) {
return emoji;
} else if (ch >= 0x203C && ch <= 0x3299) {
if (EmojiData.emojiToFE0FMap.containsKey(ch)) {
emoji = emoji.substring(0, a + 1) + "\uFE0F" + emoji.substring(a + 1);
lenght++;
a++;
}
}
}
return emoji;
}
/*public static EmojiDrawable getEmojiDrawable(CharSequence code) {
DrawableInfo info = rects.get(code);
if (info == null) {
//Log.i("DeltaChat", "No drawable for emoji " + code);
return null;
}
EmojiDrawable ed = new EmojiDrawable(info);
ed.setBounds(0, 0, drawImgSize, drawImgSize);
return ed;
}*/
/*
public static Drawable getEmojiBigDrawable(String code) {
EmojiDrawable ed = getEmojiDrawable(code);
if (ed == null) {
return null;
}
ed.setBounds(0, 0, bigImgSize, bigImgSize);
ed.fullSize = true;
return ed;
}
*/
/*public static class EmojiDrawable extends Drawable {
private DrawableInfo info;
private boolean fullSize = false;
private static Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
private static Rect rect = new Rect();
public EmojiDrawable(DrawableInfo i) {
info = i;
}
public DrawableInfo getDrawableInfo() {
return info;
}
public Rect getDrawRect() {
Rect original = getBounds();
int cX = original.centerX(), cY = original.centerY();
rect.left = cX - (fullSize ? bigImgSize : drawImgSize) / 2;
rect.right = cX + (fullSize ? bigImgSize : drawImgSize) / 2;
rect.top = cY - (fullSize ? bigImgSize : drawImgSize) / 2;
rect.bottom = cY + (fullSize ? bigImgSize : drawImgSize) / 2;
return rect;
}
@Override
public void draw(Canvas canvas) {
if (emojiBmp[info.page][info.page2] == null) {
if (loadingEmoji[info.page][info.page2]) {
return;
}
loadingEmoji[info.page][info.page2] = true;
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public void run() {
loadEmoji(info.page, info.page2);
loadingEmoji[info.page][info.page2] = false;
}
});
canvas.drawRect(getBounds(), placeholderPaint);
return;
}
Rect b;
if (fullSize) {
b = getDrawRect();
} else {
b = getBounds();
}
//if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) {
canvas.drawBitmap(emojiBmp[info.page][info.page2], info.rect, b, paint);
//}
}
@Override
public int getOpacity() {
return PixelFormat.TRANSPARENT;
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
}*/
private static class DrawableInfo {
public Rect rect;
public byte page;
public byte page2;
public DrawableInfo(Rect r, byte p, byte p2) {
rect = r;
page = p;
page2 = p2;
}
}
/*
private static boolean inArray(char c, char[] a) {
for (char cc : a) {
if (cc == c) {
return true;
}
}
return false;
}
*/
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, int size, boolean createNew) {
if (cs == null || cs.length() == 0) {
return cs;
}
//SpannableStringLight.isFieldsAvailable();
//SpannableStringLight s = new SpannableStringLight(cs.toString());
Spannable s;
if (!createNew && cs instanceof Spannable) {
s = (Spannable) cs;
} else {
s = Spannable.Factory.getInstance().newSpannable(cs.toString());
}
/* Telegram-FOSS - Disable emoji replacement, falling back to native emojis. */
// long buf = 0;
// int emojiCount = 0;
// char c;
// int startIndex = -1;
// int startLength = 0;
// int previousGoodIndex = 0;
// StringBuilder emojiCode = new StringBuilder(16);
// boolean nextIsSkinTone;
// EmojiDrawable drawable;
// EmojiSpan span;
// int length = cs.length();
// boolean doneEmoji = false;
// //s.setSpansCount(emojiCount);
//
// try {
// for (int i = 0; i < length; i++) {
// c = cs.charAt(i);
// if (c >= 0xD83C && c <= 0xD83E || (buf != 0 && (buf & 0xFFFFFFFF00000000L) == 0 && (buf & 0xFFFF) == 0xD83C && (c >= 0xDDE6 && c <= 0xDDFF))) {
// if (startIndex == -1) {
// startIndex = i;
// }
// emojiCode.append(c);
// startLength++;
// buf <<= 16;
// buf |= c;
// } else if (buf > 0 && (c & 0xF000) == 0xD000) {
// emojiCode.append(c);
// startLength++;
// buf = 0;
// doneEmoji = true;
// } else if (c == 0x20E3) {
// if (i > 0) {
// char c2 = cs.charAt(previousGoodIndex);
// if ((c2 >= '0' && c2 <= '9') || c2 == '#' || c2 == '*') {
// startIndex = previousGoodIndex;
// startLength = i - previousGoodIndex + 1;
// emojiCode.append(c2);
// emojiCode.append(c);
// doneEmoji = true;
// }
// }
// } else if ((c == 0x00A9 || c == 0x00AE || c >= 0x203C && c <= 0x3299) && EmojiData.dataCharsMap.containsKey(c)) {
// if (startIndex == -1) {
// startIndex = i;
// }
// startLength++;
// emojiCode.append(c);
// doneEmoji = true;
// } else if (startIndex != -1) {
// emojiCode.setLength(0);
// startIndex = -1;
// startLength = 0;
// doneEmoji = false;
// }
// previousGoodIndex = i;
// for (int a = 0; a < 3; a++) {
// if (i + 1 < length) {
// c = cs.charAt(i + 1);
// if (a == 1) {
// if (c == 0x200D) {
// emojiCode.append(c);
// i++;
// startLength++;
// doneEmoji = false;
// }
// } else {
// if (c >= 0xFE00 && c <= 0xFE0F) {
// i++;
// startLength++;
// }
// }
// }
// }
// if (doneEmoji) {
// if (i + 2 < length) {
// if (cs.charAt(i + 1) == 0xD83C && cs.charAt(i + 2) >= 0xDFFB && cs.charAt(i + 2) <= 0xDFFF) {
// emojiCode.append(cs.subSequence(i + 1, i + 3));
// startLength += 2;
// i += 2;
// }
// }
// drawable = Emoji.getEmojiDrawable(emojiCode.subSequence(0, emojiCode.length()));
// if (drawable != null) {
// span = new EmojiSpan(drawable, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
// s.setSpan(span, startIndex, startIndex + startLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// emojiCount++;
// }
// startLength = 0;
// startIndex = -1;
// emojiCode.setLength(0);
// doneEmoji = false;
// }
// if (emojiCount >= 50) { //654 new
// break;
// }
// }
// } catch (Exception e) {
//
// return cs;
// }
return s;
}
/*
public static class EmojiSpan extends ImageSpan {
private Paint.FontMetricsInt fontMetrics = null;
private int size = AndroidUtilities.dp(20);
public EmojiSpan(EmojiDrawable d, int verticalAlignment, int s, Paint.FontMetricsInt original) {
super(d, verticalAlignment);
fontMetrics = original;
if (original != null) {
size = Math.abs(fontMetrics.descent) + Math.abs(fontMetrics.ascent);
if (size == 0) {
size = AndroidUtilities.dp(20);
}
}
}
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
if (fm == null) {
fm = new Paint.FontMetricsInt();
}
if (fontMetrics == null) {
int sz = super.getSize(paint, text, start, end, fm);
int offset = AndroidUtilities.dp(8);
int w = AndroidUtilities.dp(10);
fm.top = -w - offset;
fm.bottom = w - offset;
fm.ascent = -w - offset;
fm.leading = 0;
fm.descent = w - offset;
return sz;
} else {
if (fm != null) {
fm.ascent = fontMetrics.ascent;
fm.descent = fontMetrics.descent;
fm.top = fontMetrics.top;
fm.bottom = fontMetrics.bottom;
}
if (getDrawable() != null) {
getDrawable().setBounds(0, 0, size, size);
}
return size;
}
}
}
*/
}
@@ -1,364 +0,0 @@
/*******************************************************************************
*
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import java.util.HashMap;
public class EmojiData {
public static final char[] emojiToFE0F = {
0x2B50, 0x2600, 0x26C5, 0x2601, 0x26A1, 0x2744, 0x26C4, 0x2614, 0x2708, 0x26F5,
0x2693, 0x26FD, 0x26F2, 0x26FA, 0x26EA, 0x2615, 0x26BD, 0x26BE, 0x26F3, 0x231A,
0x260E, 0x231B, 0x2709, 0x2702, 0x2712, 0x270F, 0x2648, 0x2649, 0x264A, 0x264B,
0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, 0x2653, 0x2734, 0x3299,
0x3297, 0x26D4, 0x2B55, 0x2668, 0x2757, 0x203C, 0x2049, 0x303D, 0x26A0, 0x267B,
0x2747, 0x2733, 0x24C2, 0x267F, 0x25B6, 0x25C0, 0x27A1, 0x2B05, 0x2B06, 0x2B07,
0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194, 0x21AA, 0x21A9, 0x2934, 0x2935,
0x2139, 0x2714, 0x2716, 0x2611, 0x26AA, 0x26AB, 0x25AA, 0x25AB, 0x2B1B, 0x2B1C,
0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666, 0x263A, 0x2639,
0x270C, 0x261D, 0x2764
};
//0xD83CDE2F, 0xD83CDC04, 0xD83CDE1A, 0xD83CDD7F
public static final char[] dataChars = {
0x262E, 0x271D, 0x262A, 0x2638, 0x2721, 0x262F, 0x2626, 0x26CE, 0x2648, 0x2649,
0x264A, 0x264B, 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, 0x2653,
0x269B, 0x2622, 0x2623, 0x2734, 0x3299, 0x3297, 0x26D4, 0x274C, 0x2B55, 0x2668,
0x2757, 0x2755, 0x2753, 0x2754, 0x203C, 0x2049, 0x269C, 0x303D, 0x26A0, 0x267B,
0x2747, 0x2733, 0x274E, 0x2705, 0x27BF, 0x24C2, 0x267F, 0x25B6, 0x23F8, 0x23EF,
0x23F9, 0x23FA, 0x23ED, 0x23EE, 0x23E9, 0x23EA, 0x25C0, 0x23EB, 0x23EC, 0x27A1,
0x2B05, 0x2B06, 0x2B07, 0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194, 0x21AA,
0x21A9, 0x2934, 0x2935, 0x2139, 0x3030, 0x27B0, 0x2714, 0x2795, 0x2796, 0x2797,
0x2716, 0x00A9, 0x00AE, 0x2122, 0x2611, 0x26AA, 0x26AB, 0x25AA, 0x25AB, 0x2B1B,
0x2B1C, 0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666, 0x263A,
0x2639, 0x270A, 0x270C, 0x270B, 0x261D, 0x270D, 0x26D1, 0x2764, 0x2763, 0x2615,
0x26BD, 0x26BE, 0x26F3, 0x26F7, 0x26F8, 0x26F9, 0x231A, 0x2328, 0x260E, 0x23F1,
0x23F2, 0x23F0, 0x23F3, 0x231B, 0x2696, 0x2692, 0x26CF, 0x2699, 0x26D3, 0x2694,
0x2620, 0x26B0, 0x26B1, 0x2697, 0x26F1, 0x2709, 0x2702, 0x2712, 0x270F, 0x2708,
0x26F5, 0x26F4, 0x2693, 0x26FD, 0x26F2, 0x26F0, 0x26FA, 0x26EA, 0x26E9, 0x2618,
0x2B50, 0x2728, 0x2604, 0x2600, 0x26C5, 0x2601, 0x26C8, 0x26A1, 0x2744, 0x2603,
0x26C4, 0x2602, 0x2614
};
public static final String[] emojiColored = {
"🙌", "👏", "👋", "👍", "👎", "👊", "", "", "👌", "",
"👐", "💪", "🙏", "", "👆", "👇", "👈", "👉", "🖕", "🖐",
"🤘", "🖖", "", "💅", "👂", "👃", "👶", "👦", "👧", "👨",
"👩", "👱", "👴", "👵", "👲", "👳", "👮", "👷", "💂", "🎅",
"👼", "👸", "👰", "🚶", "🏃", "💃", "🙇", "💁", "🙅", "🙆",
"🙋", "🙎", "🙍", "💇", "💆", "🚣", "🏊", "🏄", "🛀", "",
"🏋", "🚴", "🚵", "🏇",
};
public static final String[][] dataColored = {
new String[]{
"😀", "😬", "😁", "😂", "😃", "😄", "😅", "😆", "😇", "😉", "😊",
"🙂", "🙃", "", "😋", "😌", "😍", "😘", "😗", "😙", "😚",
"😜", "😝", "😛", "🤑", "🤓", "😎", "🤗", "😏", "😶", "😐",
"😑", "😒", "🙄", "🤔", "😳", "😞", "😟", "😠", "😡", "😔",
"😕", "🙁", "", "😣", "😖", "😫", "😩", "😤", "😮", "😱",
"😨", "😰", "😯", "😦", "😧", "😢", "😥", "😪", "😓", "😭",
"😵", "😲", "🤐", "😷", "🤒", "🤕", "😴", "💤", "💩", "😈",
"👿", "👹", "👺", "💀", "👻", "👽", "🤖", "😺", "😸", "😹",
"😻", "😼", "😽", "🙀", "😿", "😾", "🙌",
"👏", "👋",
"👍",
"👎", "👊",
"", "",
"👌",
"", "👐",
"💪", "🙏",
"",
"👆", "👇",
"👈", "👉",
"🖕",
"🖐", "🤘",
"🖖", "",
"💅",
"👄", "👅", "👂", "👃",
"👁", "👀", "👤", "👥", "🗣", "👶",
"👦",
"👧", "👨",
"👩", "👱",
"👴",
"👵", "👲",
"👳", "👮",
"👷",
"💂", "🕵", "🎅",
"👼",
"👸", "👰",
"🚶", "🏃",
"💃",
"👯", "👫", "👬", "👭", "🙇",
"💁", "🙅",
"🙆", "🙋",
"🙎",
"🙍", "💇",
"💆", "💑", "👩‍❤‍👩",
"👨‍❤‍👨", "💏", "👩‍❤‍💋‍👩", "👨‍❤‍💋‍👨", "👪", "👨‍👩‍👧", "👨‍👩‍👧‍👦", "👨‍👩‍👦‍👦", "👨‍👩‍👧‍👧", "👩‍👩‍👦",
"👩‍👩‍👧", "👩‍👩‍👧‍👦", "👩‍👩‍👦‍👦", "👩‍👩‍👧‍👧", "👨‍👨‍👦", "👨‍👨‍👧", "👨‍👨‍👧‍👦", "👨‍👨‍👦‍👦", "👨‍👨‍👧‍👧", "👚",
"👕", "👖", "👔", "👗", "👙", "👘", "💄", "💋", "👣", "👠",
"👡", "👢", "👞", "👟", "👒", "🎩", "🎓", "👑", "", "🎒",
"👝", "👛", "👜", "💼", "👓", "🕶", "💍", "🌂", "", "💛",
"💚", "💙", "💜", "💔", "", "💕", "💞", "💓", "💗", "💖",
"💘", "💝",
},
null,
new String[]{
"🍏", "🍎", "🍐", "🍊", "🍋", "🍌", "🍉", "🍇", "🍓", "🍈", "🍒",
"🍑", "🍍", "🍅", "🍆", "🌶", "🌽", "🍠", "🍯", "🍞", "🧀",
"🍗", "🍖", "🍤", "🍳", "🍔", "🍟", "🌭", "🍕", "🍝", "🌮",
"🌯", "🍜", "🍲", "🍥", "🍣", "🍱", "🍛", "🍙", "🍚", "🍘",
"🍢", "🍡", "🍧", "🍨", "🍦", "🍰", "🎂", "🍮", "🍬", "🍭",
"🍫", "🍿", "🍩", "🍪", "🍺", "🍻", "🍷", "🍸", "🍹", "🍾",
"🍶", "🍵", "", "🍼", "🍴", "🍽", "", "🏀", "🏈", "",
"🎾", "🏐", "🏉", "🎱", "", "🏌", "🏓", "🏸", "🏒", "🏑",
"🏏", "🎿", "", "🏂", "", "🏹", "🎣", "🚣",
"🏊", "🏄",
"🛀",
"", "🏋",
"🚴", "🚵",
"🏇",
"🕴", "🏆", "🎽", "🏅", "🎖", "🎗", "🏵", "🎫", "🎟",
"🎭", "🎨", "🎪", "🎤", "🎧", "🎼", "🎹", "🎷", "🎺", "🎸",
"🎻", "🎬", "🎮", "👾", "🎯", "🎲", "🎰", "🎳", "", "📱",
"📲", "💻", "", "🖥", "🖨", "🖱", "🖲", "🕹", "🗜", "💽",
"💾", "💿", "📀", "📼", "📷", "📸", "📹", "🎥", "📽", "🎞",
"📞", "", "📟", "🎛", "", "", "", "🕰", "", "",
"📡", "🔋", "🔌", "💡", "🔦", "🕯", "🗑", "🛢", "💸", "💵",
"💴", "💶", "💷", "💰", "💳", "💎", "", "🔧", "🔨", "",
"🛠", "", "🔩", "", "", "🔫", "💣", "🔪", "🗡", "",
"🛡", "🚬", "", "", "", "🏺", "🔮", "📿", "💈", "",
"🔭", "🔬", "🕳", "💊", "💉", "🌡", "🏷", "🔖", "🚽", "🚿",
"🛁", "🔑", "🗝", "🛋", "🛌", "🛏", "🚪", "🛎", "🖼", "🗺",
"", "🗿", "🛍", "🎈", "🎏", "🎀", "🎁", "🎊", "🎉", "🎎",
"🎐", "🎌", "🏮", "", "📩", "📨", "📧", "💌", "📮", "📪",
"📫", "📬", "📭", "📦", "📯", "📥", "📤", "📜", "📃", "📑",
"📊", "📈", "📉", "📄", "📅", "📆", "🗓", "📇", "🗃", "🗳",
"🗄", "📋", "🗒", "📁", "📂", "🗂", "🗞", "📰", "📓", "📕",
"📗", "📘", "📙", "📔", "📒", "📚", "📖", "🔗", "📎", "🖇",
"", "📐", "📏", "📌", "📍", "🚩", "🏳", "🏴", "🔐", "🔒",
"🔓", "🔏", "🖊", "🖋", "", "📝", "", "🖍", "🖌", "🔍",
"🔎",
},
null,
null
};
public static final String[][] data = {
new String[]{
"😀", "😬", "😁", "😂", "😃", "😄", "😅", "😆", "😇", "😉", "😊",
"🙂", "🙃", "", "😋", "😌", "😍", "😘", "😗", "😙", "😚",
"😜", "😝", "😛", "🤑", "🤓", "😎", "🤗", "😏", "😶", "😐",
"😑", "😒", "🙄", "🤔", "😳", "😞", "😟", "😠", "😡", "😔",
"😕", "🙁", "", "😣", "😖", "😫", "😩", "😤", "😮", "😱",
"😨", "😰", "😯", "😦", "😧", "😢", "😥", "😪", "😓", "😭",
"😵", "😲", "🤐", "😷", "🤒", "🤕", "😴", "💤", "💩", "😈",
"👿", "👹", "👺", "💀", "👻", "👽", "🤖", "😺", "😸", "😹",
"😻", "😼", "😽", "🙀", "😿", "😾", "🙌", "🙌🏻", "🙌🏼", "🙌🏽",
"🙌🏾", "🙌🏿", "👏", "👏🏻", "👏🏼", "👏🏽", "👏🏾", "👏🏿", "👋", "👋🏻",
"👋🏼", "👋🏽", "👋🏾", "👋🏿", "👍", "👍🏻", "👍🏼", "👍🏽", "👍🏾", "👍🏿",
"👎", "👎🏻", "👎🏼", "👎🏽", "👎🏾", "👎🏿", "👊", "👊🏻", "👊🏼", "👊🏽",
"👊🏾", "👊🏿", "", "✊🏻", "✊🏼", "✊🏽", "✊🏾", "✊🏿", "", "✌🏻",
"✌🏼", "✌🏽", "✌🏾", "✌🏿", "👌", "👌🏻", "👌🏼", "👌🏽", "👌🏾", "👌🏿",
"", "✋🏻", "✋🏼", "✋🏽", "✋🏾", "✋🏿", "👐", "👐🏻", "👐🏼", "👐🏽",
"👐🏾", "👐🏿", "💪", "💪🏻", "💪🏼", "💪🏽", "💪🏾", "💪🏿", "🙏", "🙏🏻",
"🙏🏼", "🙏🏽", "🙏🏾", "🙏🏿", "", "☝🏻", "☝🏼", "☝🏽", "☝🏾", "☝🏿",
"👆", "👆🏻", "👆🏼", "👆🏽", "👆🏾", "👆🏿", "👇", "👇🏻", "👇🏼", "👇🏽",
"👇🏾", "👇🏿", "👈", "👈🏻", "👈🏼", "👈🏽", "👈🏾", "👈🏿", "👉", "👉🏻",
"👉🏼", "👉🏽", "👉🏾", "👉🏿", "🖕", "🖕🏻", "🖕🏼", "🖕🏽", "🖕🏾", "🖕🏿",
"🖐", "🖐🏻", "🖐🏼", "🖐🏽", "🖐🏾", "🖐🏿", "🤘", "🤘🏻", "🤘🏼", "🤘🏽",
"🤘🏾", "🤘🏿", "🖖", "🖖🏻", "🖖🏼", "🖖🏽", "🖖🏾", "🖖🏿", "", "✍🏻",
"✍🏼", "✍🏽", "✍🏾", "✍🏿", "💅", "💅🏻", "💅🏼", "💅🏽", "💅🏾", "💅🏿",
"👄", "👅", "👂", "👂🏻", "👂🏼", "👂🏽", "👂🏾", "👂🏿", "👃", "👃🏻",
"👃🏼", "👃🏽", "👃🏾", "👃🏿", "👁", "👀", "👤", "👥", "🗣", "👶",
"👶🏻", "👶🏼", "👶🏽", "👶🏾", "👶🏿", "👦", "👦🏻", "👦🏼", "👦🏽", "👦🏾",
"👦🏿", "👧", "👧🏻", "👧🏼", "👧🏽", "👧🏾", "👧🏿", "👨", "👨🏻", "👨🏼",
"👨🏽", "👨🏾", "👨🏿", "👩", "👩🏻", "👩🏼", "👩🏽", "👩🏾", "👩🏿", "👱",
"👱🏻", "👱🏼", "👱🏽", "👱🏾", "👱🏿", "👴", "👴🏻", "👴🏼", "👴🏽", "👴🏾",
"👴🏿", "👵", "👵🏻", "👵🏼", "👵🏽", "👵🏾", "👵🏿", "👲", "👲🏻", "👲🏼",
"👲🏽", "👲🏾", "👲🏿", "👳", "👳🏻", "👳🏼", "👳🏽", "👳🏾", "👳🏿", "👮",
"👮🏻", "👮🏼", "👮🏽", "👮🏾", "👮🏿", "👷", "👷🏻", "👷🏼", "👷🏽", "👷🏾",
"👷🏿", "💂", "💂🏻", "💂🏼", "💂🏽", "💂🏾", "💂🏿", "🕵", "🎅", "🎅🏻",
"🎅🏼", "🎅🏽", "🎅🏾", "🎅🏿", "👼", "👼🏻", "👼🏼", "👼🏽", "👼🏾", "👼🏿",
"👸", "👸🏻", "👸🏼", "👸🏽", "👸🏾", "👸🏿", "👰", "👰🏻", "👰🏼", "👰🏽",
"👰🏾", "👰🏿", "🚶", "🚶🏻", "🚶🏼", "🚶🏽", "🚶🏾", "🚶🏿", "🏃", "🏃🏻",
"🏃🏼", "🏃🏽", "🏃🏾", "🏃🏿", "💃", "💃🏻", "💃🏼", "💃🏽", "💃🏾", "💃🏿",
"👯", "👫", "👬", "👭", "🙇", "🙇🏻", "🙇🏼", "🙇🏽", "🙇🏾", "🙇🏿",
"💁", "💁🏻", "💁🏼", "💁🏽", "💁🏾", "💁🏿", "🙅", "🙅🏻", "🙅🏼", "🙅🏽",
"🙅🏾", "🙅🏿", "🙆", "🙆🏻", "🙆🏼", "🙆🏽", "🙆🏾", "🙆🏿", "🙋", "🙋🏻",
"🙋🏼", "🙋🏽", "🙋🏾", "🙋🏿", "🙎", "🙎🏻", "🙎🏼", "🙎🏽", "🙎🏾", "🙎🏿",
"🙍", "🙍🏻", "🙍🏼", "🙍🏽", "🙍🏾", "🙍🏿", "💇", "💇🏻", "💇🏼", "💇🏽",
"💇🏾", "💇🏿", "💆", "💆🏻", "💆🏼", "💆🏽", "💆🏾", "💆🏿", "💑", "👩‍❤‍👩",
"👨‍❤‍👨", "💏", "👩‍❤‍💋‍👩", "👨‍❤‍💋‍👨", "👪", "👨‍👩‍👧", "👨‍👩‍👧‍👦", "👨‍👩‍👦‍👦", "👨‍👩‍👧‍👧", "👩‍👩‍👦",
"👩‍👩‍👧", "👩‍👩‍👧‍👦", "👩‍👩‍👦‍👦", "👩‍👩‍👧‍👧", "👨‍👨‍👦", "👨‍👨‍👧", "👨‍👨‍👧‍👦", "👨‍👨‍👦‍👦", "👨‍👨‍👧‍👧", "👚",
"👕", "👖", "👔", "👗", "👙", "👘", "💄", "💋", "👣", "👠",
"👡", "👢", "👞", "👟", "👒", "🎩", "🎓", "👑", "", "🎒",
"👝", "👛", "👜", "💼", "👓", "🕶", "💍", "🌂", "", "💛",
"💚", "💙", "💜", "💔", "", "💕", "💞", "💓", "💗", "💖",
"💘", "💝"
},
new String[]{
"🐶", "🐱", "🐭", "🐹", "🐰", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮",
"🐷", "🐽", "🐸", "🐙", "🐵", "🙈", "🙉", "🙊", "🐒", "🐔",
"🐧", "🐦", "🐤", "🐣", "🐥", "🐺", "🐗", "🐴", "🦄", "🐝",
"🐛", "🐌", "🐞", "🐜", "🕷", "🦂", "🦀", "🐍", "🐢", "🐠",
"🐟", "🐡", "🐬", "🐳", "🐋", "🐊", "🐆", "🐅", "🐃", "🐂",
"🐄", "🐪", "🐫", "🐘", "🐐", "🐏", "🐑", "🐎", "🐖", "🐀",
"🐁", "🐓", "🦃", "🕊", "🐕", "🐩", "🐈", "🐇", "🐿", "🐾",
"🐉", "🐲", "🌵", "🎄", "🌲", "🌳", "🌴", "🌱", "🌿", "",
"🍀", "🎍", "🎋", "🍃", "🍂", "🍁", "🌾", "🌺", "🌻", "🌹",
"🌷", "🌼", "🌸", "💐", "🍄", "🌰", "🎃", "🐚", "🕸", "🌎",
"🌍", "🌏", "🌕", "🌖", "🌗", "🌘", "🌑", "🌒", "🌓", "🌔",
"🌚", "🌝", "🌛", "🌜", "🌞", "🌙", "", "🌟", "💫", "",
"", "", "🌤", "", "🌥", "🌦", "", "🌧", "", "🌩",
"", "🔥", "💥", "", "🌨", "", "", "🌬", "💨", "🌪",
"🌫", "", "", "💧", "💦", "🌊"
},
new String[]{
"🍏", "🍎", "🍐", "🍊", "🍋", "🍌", "🍉", "🍇", "🍓", "🍈", "🍒",
"🍑", "🍍", "🍅", "🍆", "🌶", "🌽", "🍠", "🍯", "🍞", "🧀",
"🍗", "🍖", "🍤", "🍳", "🍔", "🍟", "🌭", "🍕", "🍝", "🌮",
"🌯", "🍜", "🍲", "🍥", "🍣", "🍱", "🍛", "🍙", "🍚", "🍘",
"🍢", "🍡", "🍧", "🍨", "🍦", "🍰", "🎂", "🍮", "🍬", "🍭",
"🍫", "🍿", "🍩", "🍪", "🍺", "🍻", "🍷", "🍸", "🍹", "🍾",
"🍶", "🍵", "", "🍼", "🍴", "🍽", "", "🏀", "🏈", "",
"🎾", "🏐", "🏉", "🎱", "", "🏌", "🏓", "🏸", "🏒", "🏑",
"🏏", "🎿", "", "🏂", "", "🏹", "🎣", "🚣", "🚣🏻", "🚣🏼",
"🚣🏽", "🚣🏾", "🚣🏿", "🏊", "🏊🏻", "🏊🏼", "🏊🏽", "🏊🏾", "🏊🏿", "🏄",
"🏄🏻", "🏄🏼", "🏄🏽", "🏄🏾", "🏄🏿", "🛀", "🛀🏻", "🛀🏼", "🛀🏽", "🛀🏾",
"🛀🏿", "", "⛹🏻", "⛹🏼", "⛹🏽", "⛹🏾", "⛹🏿", "🏋", "🏋🏻", "🏋🏼",
"🏋🏽", "🏋🏾", "🏋🏿", "🚴", "🚴🏻", "🚴🏼", "🚴🏽", "🚴🏾", "🚴🏿", "🚵",
"🚵🏻", "🚵🏼", "🚵🏽", "🚵🏾", "🚵🏿", "🏇", "🏇🏻", "🏇🏼", "🏇🏽", "🏇🏾",
"🏇🏿", "🕴", "🏆", "🎽", "🏅", "🎖", "🎗", "🏵", "🎫", "🎟",
"🎭", "🎨", "🎪", "🎤", "🎧", "🎼", "🎹", "🎷", "🎺", "🎸",
"🎻", "🎬", "🎮", "👾", "🎯", "🎲", "🎰", "🎳", "", "📱",
"📲", "💻", "", "🖥", "🖨", "🖱", "🖲", "🕹", "🗜", "💽",
"💾", "💿", "📀", "📼", "📷", "📸", "📹", "🎥", "📽", "🎞",
"📞", "", "📟", "🎛", "", "", "", "🕰", "", "",
"📡", "🔋", "🔌", "💡", "🔦", "🕯", "🗑", "🛢", "💸", "💵",
"💴", "💶", "💷", "💰", "💳", "💎", "", "🔧", "🔨", "",
"🛠", "", "🔩", "", "", "🔫", "💣", "🔪", "🗡", "",
"🛡", "🚬", "", "", "", "🏺", "🔮", "📿", "💈", "",
"🔭", "🔬", "🕳", "💊", "💉", "🌡", "🏷", "🔖", "🚽", "🚿",
"🛁", "🔑", "🗝", "🛋", "🛌", "🛏", "🚪", "🛎", "🖼", "🗺",
"", "🗿", "🛍", "🎈", "🎏", "🎀", "🎁", "🎊", "🎉", "🎎",
"🎐", "🎌", "🏮", "", "📩", "📨", "📧", "💌", "📮", "📪",
"📫", "📬", "📭", "📦", "📯", "📥", "📤", "📜", "📃", "📑",
"📊", "📈", "📉", "📄", "📅", "📆", "🗓", "📇", "🗃", "🗳",
"🗄", "📋", "🗒", "📁", "📂", "🗂", "🗞", "📰", "📓", "📕",
"📗", "📘", "📙", "📔", "📒", "📚", "📖", "🔗", "📎", "🖇",
"", "📐", "📏", "📌", "📍", "🚩", "🏳", "🏴", "🔐", "🔒",
"🔓", "🔏", "🖊", "🖋", "", "📝", "", "🖍", "🖌", "🔍",
"🔎"
},
new String[]{
"🚗", "🚕", "🚙", "🚌", "🚎", "🏎", "🚓", "🚑", "🚒", "🚐", "🚚",
"🚛", "🚜", "🏍", "🚲", "🚨", "🚔", "🚍", "🚘", "🚖", "🚡",
"🚠", "🚟", "🚃", "🚋", "🚝", "🚄", "🚅", "🚈", "🚞", "🚂",
"🚆", "🚇", "🚊", "🚉", "🚁", "🛩", "", "🛫", "🛬", "",
"🛥", "🚤", "", "🛳", "🚀", "🛰", "💺", "", "🚧", "",
"🚏", "🚦", "🚥", "🏁", "🚢", "🎡", "🎢", "🎠", "🏗", "🌁",
"🗼", "🏭", "", "🎑", "", "🏔", "🗻", "🌋", "🗾", "🏕",
"", "🏞", "🛣", "🛤", "🌅", "🌄", "🏜", "🏖", "🏝", "🌇",
"🌆", "🏙", "🌃", "🌉", "🌌", "🌠", "🎇", "🎆", "🌈", "🏘",
"🏰", "🏯", "🏟", "🗽", "🏠", "🏡", "🏚", "🏢", "🏬", "🏣",
"🏤", "🏥", "🏦", "🏨", "🏪", "🏫", "🏩", "💒", "🏛", "",
"🕌", "🕍", "🕋", "", "🇦🇺", "🇦🇹", "🇦🇿", "🇦🇽", "🇦🇱", "🇩🇿",
"🇦🇸", "🇦🇮", "🇦🇴", "🇦🇩", "🇦🇶", "🇦🇬", "🇦🇷", "🇦🇲", "🇦🇼", "🇦🇫",
"🇧🇸", "🇧🇩", "🇧🇧", "🇧🇭", "🇧🇾", "🇧🇿", "🇧🇪", "🇧🇯", "🇧🇲", "🇧🇬",
"🇧🇴", "🇧🇶", "🇧🇦", "🇧🇼", "🇧🇷", "🇮🇴", "🇧🇳", "🇧🇫", "🇧🇮", "🇧🇹",
"🇻🇺", "🇻🇦", "🇬🇧", "🇭🇺", "🇻🇪", "🇻🇬", "🇻🇮", "🇹🇱", "🇻🇳", "🇬🇦",
"🇭🇹", "🇬🇾", "🇬🇲", "🇬🇭", "🇬🇵", "🇬🇹", "🇬🇳", "🇬🇼", "🇩🇪", "🇬🇬",
"🇬🇮", "🇭🇳", "🇭🇰", "🇬🇩", "🇬🇱", "🇬🇷", "🇬🇪", "🇬🇺", "🇩🇰", "🇯🇪",
"🇩🇯", "🇩🇲", "🇩🇴", "🇪🇺", "🇪🇬", "🇿🇲", "🇪🇭", "🇿🇼", "🇮🇱", "🇮🇳",
"🇮🇩", "🇯🇴", "🇮🇶", "🇮🇷", "🇮🇪", "🇮🇸", "🇪🇸", "🇮🇹", "🇾🇪", "🇨🇻",
"🇰🇿", "🇰🇾", "🇰🇭", "🇨🇲", "🇨🇦", "🇮🇨", "🇶🇦", "🇰🇪", "🇨🇾", "🇰🇬",
"🇰🇮", "🇨🇳", "🇰🇵", "🇨🇨", "🇨🇴", "🇰🇲", "🇨🇬", "🇨🇩", "🇽🇰", "🇨🇷",
"🇨🇮", "🇨🇺", "🇰🇼", "🇨🇼", "🇱🇦", "🇱🇻", "🇱🇸", "🇱🇷", "🇱🇧", "🇱🇾",
"🇱🇹", "🇱🇮", "🇱🇺", "🇲🇺", "🇲🇷", "🇲🇬", "🇾🇹", "🇲🇴", "🇲🇰", "🇲🇼",
"🇲🇾", "🇲🇱", "🇲🇻", "🇲🇹", "🇲🇦", "🇲🇶", "🇲🇭", "🇲🇽", "🇫🇲", "🇲🇿",
"🇲🇩", "🇲🇨", "🇲🇳", "🇲🇸", "🇲🇲", "🇳🇦", "🇳🇷", "🇳🇵", "🇳🇪", "🇳🇬",
"🇳🇱", "🇳🇮", "🇳🇺", "🇳🇿", "🇳🇨", "🇳🇴", "🇮🇲", "🇳🇫", "🇨🇽", "🇸🇭",
"🇨🇰", "🇹🇨", "🇦🇪", "🇴🇲", "🇵🇰", "🇵🇼", "🇵🇸", "🇵🇦", "🇵🇬", "🇵🇾",
"🇵🇪", "🇵🇳", "🇵🇱", "🇵🇹", "🇵🇷", "🇰🇷", "🇷🇪", "🇷🇺", "🇷🇼", "🇷🇴",
"🇸🇻", "🇼🇸", "🇸🇲", "🇸🇹", "🇸🇦", "🇸🇿", "🇲🇵", "🇸🇨", "🇧🇱", "🇵🇲",
"🇸🇳", "🇻🇨", "🇰🇳", "🇱🇨", "🇷🇸", "🇸🇬", "🇸🇽", "🇸🇾", "🇸🇰", "🇸🇮",
"🇺🇸", "🇸🇧", "🇸🇴", "🇸🇩", "🇸🇷", "🇸🇱", "🇹🇯", "🇹🇭", "🇹🇼", "🇹🇿",
"🇹🇬", "🇹🇰", "🇹🇴", "🇹🇹", "🇹🇻", "🇹🇳", "🇹🇲", "🇹🇷", "🇺🇬", "🇺🇿",
"🇺🇦", "🇼🇫", "🇺🇾", "🇫🇴", "🇫🇯", "🇵🇭", "🇫🇮", "🇫🇰", "🇫🇷", "🇬🇫",
"🇵🇫", "🇹🇫", "🇭🇷", "🇨🇫", "🇹🇩", "🇲🇪", "🇨🇿", "🇨🇱", "🇨🇭", "🇸🇪",
"🇱🇰", "🇪🇨", "🇬🇶", "🇪🇷", "🇪🇪", "🇪🇹", "🇿🇦", "🇬🇸", "🇸🇸", "🇯🇲",
"🇯🇵"
},
new String[]{
"💟", "", "", "", "🕉", "", "", "🔯", "🕎", "", "",
"🛐", "", "", "", "", "", "", "", "", "",
"", "", "", "", "🆔", "", "🈳", "🈹", "", "",
"📴", "📳", "🈶", "🈚", "🈸", "🈺", "🈷", "", "🆚", "🉑",
"💮", "🉐", "", "", "🈴", "🈵", "🈲", "🅰", "🅱", "🆎",
"🆑", "🅾", "🆘", "", "📛", "🚫", "", "", "💢", "",
"🚷", "🚯", "🚳", "🚱", "🔞", "📵", "", "", "", "",
"", "", "💯", "🔅", "🔆", "🔱", "", "", "", "🚸",
"🔰", "", "🈯", "💹", "", "", "", "", "💠", "🌀",
"", "🌐", "", "🏧", "🈂", "🛂", "🛃", "🛄", "🛅", "",
"🚭", "🚾", "🅿", "🚰", "🚹", "🚺", "🚼", "🚻", "🚮", "🎦",
"📶", "🈁", "🆖", "🆗", "🆙", "🆒", "🆕", "🆓", "0⃣", "1⃣",
"2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟", "🔢",
"", "", "", "", "", "", "", "", "", "🔀",
"🔁", "🔂", "", "🔼", "🔽", "", "", "", "", "",
"", "", "", "", "", "", "", "🔄", "", "",
"", "", "#⃣", "*⃣", "", "🔤", "🔡", "🔠", "🔣", "🎵",
"🎶", "", "", "", "🔃", "", "", "", "", "💲",
"💱", "©", "®", "", "🔚", "🔙", "🔛", "🔝", "🔜", "",
"🔘", "", "", "🔴", "🔵", "🔸", "🔹", "🔶", "🔷", "🔺",
"", "", "", "", "🔻", "", "", "", "", "🔲",
"🔳", "🔈", "🔉", "🔊", "🔇", "📣", "📢", "🔔", "🔕", "🃏",
"🀄", "", "", "", "", "🎴", "👁‍🗨", "💭", "🗯", "💬",
"🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙",
"🕚", "🕛", "🕜", "🕝", "🕞", "🕟", "🕠", "🕡", "🕢", "🕣",
"🕤", "🕥", "🕦", "🕧"
}
};
public static final HashMap<Character, Boolean> emojiToFE0FMap = new HashMap<>(emojiToFE0F.length);
public static final HashMap<Character, Boolean> dataCharsMap = new HashMap<>(dataChars.length);
public static final HashMap<String, Boolean> emojiColoredMap = new HashMap<>(emojiColored.length);
static {
for (int a = 0; a < emojiToFE0F.length; a++) {
emojiToFE0FMap.put(emojiToFE0F[a], true);
}
for (int a = 0; a < dataChars.length; a++) {
dataCharsMap.put(dataChars[a], true);
}
for (int a = 0; a < emojiColored.length; a++) {
//Disable colored emoji.
//emojiColoredMap.put(emojiColored[a], true);
}
dataColored[1] = data[1];
dataColored[3] = data[3];
dataColored[4] = data[4];
}
}
@@ -0,0 +1,629 @@
/*******************************************************************************
*
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Spannable;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.PagerSlidingTabStrip;
import com.amulyakhare.textdrawable.TextDrawable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
public class EmojiInputView extends FrameLayout {
public interface Listener {
boolean onBackspace();
void onEmojiSelected(String emoji);
void onClearEmojiRecent();
}
private static final String[][] predefinedEmojis = {
new String[]{
"😀", "😬", "😁", "😂", "😃", "😄", "😅", "😆", "😇", "😉", "😊", "🙂", "🙃", "", "😋",
"😌", "😍", "😘", "😗", "😙", "😚", "😜", "😝", "😛", "🤑", "🤓", "😎", "🤗", "😏", "😶",
"😐", "😑", "😒", "🙄", "🤔", "😳", "😞", "😟", "😠", "😡", "😔", "😕", "🙁", "", "😣",
"😖", "😫", "😩", "😤", "😮", "😱", "😨", "😰", "😯", "😦", "😧", "😢", "😥", "😪", "😓",
"😭", "😵", "😲", "🤐", "😷", "🤒", "🤕", "😴", "💤", "💩", "😈", "👿", "👹", "👺", "💀",
"👻", "👽", "🤖", "😺", "😸", "😹", "😻", "😼", "😽", "🙀", "😿", "😾", "🙌", "👏", "👋",
"👍", "👎", "👊", "", "", "👌", "", "👐", "💪", "🙏", "", "👆", "👇", "👈", "👉", "🖕", "🖐",
"🤘", "🖖", "", "💅", "👄", "👅", "👂", "👃", "👁", "👀", "👤", "👥", "🗣", "👶", "👦", "👧",
"👨", "👩", "👱", "👴", "👵", "👲", "👳", "👮", "👷", "💂", "🕵", "🎅", "👼", "👸", "👰", "🚶",
"🏃", "💃", "👯", "👫", "👬", "👭", "🙇", "💁", "🙅", "🙆", "🙋", "🙎", "🙍", "💇", "💆", "💑",
"👩‍❤‍👩", "👨‍❤‍👨", "💏", "👩‍❤‍💋‍👩", "👨‍❤‍💋‍👨", "👪", "👨‍👩‍👧", "👨‍👩‍👧‍👦", "👨‍👩‍👦‍👦", "👨‍👩‍👧‍👧",
"👩‍👩‍👦", "👩‍👩‍👧", "👩‍👩‍👧‍👦", "👩‍👩‍👦‍👦", "👩‍👩‍👧‍👧", "👨‍👨‍👦", "👨‍👨‍👧", "👨‍👨‍👧‍👦", "👨‍👨‍👦‍👦",
"👨‍👨‍👧‍👧", "👚", "👕", "👖", "👔", "👗", "👙", "👘", "💄", "💋", "👣", "👠", "👡", "👢", "👞",
"👟", "👒", "🎩", "🎓", "👑", "", "🎒", "👝", "👛", "👜", "💼", "👓", "🕶", "💍", "🌂", "",
"💛", "💚", "💙", "💜", "💔", "", "💕", "💞", "💓", "💗", "💖", "💘", "💝",
},
new String[]{
"🐶", "🐱", "🐭", "🐹", "🐰", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐽", "🐸", "🐙",
"🐵", "🙈", "🙉", "🙊", "🐒", "🐔", "🐧", "🐦", "🐤", "🐣", "🐥", "🐺", "🐗", "🐴", "🦄", "🐝",
"🐛", "🐌", "🐞", "🐜", "🕷", "🦂", "🦀", "🐍", "🐢", "🐠", "🐟", "🐡", "🐬", "🐳", "🐋",
"🐊", "🐆", "🐅", "🐃", "🐂", "🐄", "🐪", "🐫", "🐘", "🐐", "🐏", "🐑", "🐎", "🐖", "🐀",
"🐁", "🐓", "🦃", "🕊", "🐕", "🐩", "🐈", "🐇", "🐿", "🐾", "🐉", "🐲", "🌵", "🎄", "🌲", "🌳",
"🌴", "🌱", "🌿", "", "🍀", "🎍", "🎋", "🍃", "🍂", "🍁", "🌾", "🌺", "🌻", "🌹", "🌷", "🌼",
"🌸", "💐", "🍄", "🌰", "🎃", "🐚", "🕸", "🌎", "🌍", "🌏", "🌕", "🌖", "🌗", "🌘", "🌑", "🌒",
"🌓", "🌔", "🌚", "🌝", "🌛", "🌜", "🌞", "🌙", "", "🌟", "💫", "", "", "", "🌤", "",
"🌥", "🌦", "", "🌧", "", "🌩", "", "🔥", "💥", "", "🌨", "", "", "🌬", "💨", "🌪",
"🌫", "", "", "💧", "💦", "🌊"
},
new String[]{
"🍏", "🍎", "🍐", "🍊", "🍋", "🍌", "🍉", "🍇", "🍓", "🍈", "🍒", "🍑", "🍍", "🍅", "🍆", "🌶",
"🌽", "🍠", "🍯", "🍞", "🧀", "🍗", "🍖", "🍤", "🍳", "🍔", "🍟", "🌭", "🍕", "🍝", "🌮", "🌯",
"🍜", "🍲", "🍥", "🍣", "🍱", "🍛", "🍙", "🍚", "🍘", "🍢", "🍡", "🍧", "🍨", "🍦", "🍰", "🎂",
"🍮", "🍬", "🍭", "🍫", "🍿", "🍩", "🍪", "🍺", "🍻", "🍷", "🍸", "🍹", "🍾", "🍶", "🍵", "",
"🍼", "🍴", "🍽", "", "🏀", "🏈", "", "🎾", "🏐", "🏉", "🎱", "", "🏌", "🏓", "🏸", "🏒",
"🏑", "🏏", "🎿", "", "🏂", "", "🏹", "🎣", "🚣", "🏊", "🏄", "🛀", "", "🏋", "🚴", "🚵",
"🏇", "🕴", "🏆", "🎽", "🏅", "🎖", "🎗", "🏵", "🎫", "🎟", "🎭", "🎨", "🎪", "🎤", "🎧", "🎼",
"🎹", "🎷", "🎺", "🎸", "🎻", "🎬", "🎮", "👾", "🎯", "🎲", "🎰", "🎳", "", "📱", "📲", "💻",
"", "🖥", "🖨", "🖱", "🖲", "🕹", "🗜", "💽", "💾", "💿", "📀", "📼", "📷", "📸", "📹", "🎥",
"📽", "🎞", "📞", "", "📟", "🎛", "", "", "", "🕰", "", "", "📡", "🔋", "🔌", "💡",
"🔦", "🕯", "🗑", "🛢", "💸", "💵", "💴", "💶", "💷", "💰", "💳", "💎", "", "🔧", "🔨", "",
"🛠", "", "🔩", "", "", "🔫", "💣", "🔪", "🗡", "", "🛡", "🚬", "", "", "", "🏺",
"🔮", "📿", "💈", "", "🔭", "🔬", "🕳", "💊", "💉", "🌡", "🏷", "🔖", "🚽", "🚿", "🛁", "🔑",
"🗝", "🛋", "🛌", "🛏", "🚪", "🛎", "🖼", "🗺", "", "🗿", "🛍", "🎈", "🎏", "🎀", "🎁",
"🎊", "🎉", "🎎", "🎐", "🎌", "🏮", "", "📩", "📨", "📧", "💌", "📮", "📪", "📫", "📬", "📭",
"📦", "📯", "📥", "📤", "📜", "📃", "📑", "📊", "📈", "📉", "📄", "📅", "📆", "🗓", "📇", "🗃",
"🗳", "🗄", "📋", "🗒", "📁", "📂", "🗂", "🗞", "📰", "📓", "📕", "📗", "📘", "📙", "📔", "📒",
"📚", "📖", "🔗", "📎", "🖇", "", "📐", "📏", "📌", "📍", "🚩", "🏳", "🏴", "🔐", "🔒", "🔓",
"🔏", "🖊", "🖋", "", "📝", "", "🖍", "🖌", "🔍", "🔎",
},
new String[]{
"🚗", "🚕", "🚙", "🚌", "🚎", "🏎", "🚓", "🚑", "🚒", "🚐", "🚚", "🚛", "🚜", "🏍", "🚲",
"🚨", "🚔", "🚍", "🚘", "🚖", "🚡", "🚠", "🚟", "🚃", "🚋", "🚝", "🚄", "🚅", "🚈", "🚞", "🚂",
"🚆", "🚇", "🚊", "🚉", "🚁", "🛩", "", "🛫", "🛬", "", "🛥", "🚤", "", "🛳", "🚀", "🛰",
"💺", "", "🚧", "", "🚏", "🚦", "🚥", "🏁", "🚢", "🎡", "🎢", "🎠", "🏗", "🌁", "🗼", "🏭",
"", "🎑", "", "🏔", "🗻", "🌋", "🗾", "🏕", "", "🏞", "🛣", "🛤", "🌅", "🌄", "🏜",
"🏖", "🏝", "🌇", "🌆", "🏙", "🌃", "🌉", "🌌", "🌠", "🎇", "🎆", "🌈", "🏘", "🏰", "🏯", "🏟",
"🗽", "🏠", "🏡", "🏚", "🏢", "🏬", "🏣", "🏤", "🏥", "🏦", "🏨", "🏪", "🏫", "🏩", "💒", "🏛",
"", "🕌", "🕍", "🕋", "", "🇦🇺", "🇦🇹", "🇦🇿", "🇦🇽", "🇦🇱", "🇩🇿", "🇦🇸", "🇦🇮",
"🇦🇴", "🇦🇩", "🇦🇶", "🇦🇬", "🇦🇷", "🇦🇲", "🇦🇼", "🇦🇫", "🇧🇸", "🇧🇩", "🇧🇧", "🇧🇭",
"🇧🇾", "🇧🇿", "🇧🇪", "🇧🇯", "🇧🇲", "🇧🇬", "🇧🇴", "🇧🇶", "🇧🇦", "🇧🇼", "🇧🇷", "🇮🇴",
"🇧🇳", "🇧🇫", "🇧🇮", "🇧🇹", "🇻🇺", "🇻🇦", "🇬🇧", "🇭🇺", "🇻🇪", "🇻🇬", "🇻🇮", "🇹🇱",
"🇻🇳", "🇬🇦", "🇭🇹", "🇬🇾", "🇬🇲", "🇬🇭", "🇬🇵", "🇬🇹", "🇬🇳", "🇬🇼", "🇩🇪", "🇬🇬",
"🇬🇮", "🇭🇳", "🇭🇰", "🇬🇩", "🇬🇱", "🇬🇷", "🇬🇪", "🇬🇺", "🇩🇰", "🇯🇪", "🇩🇯", "🇩🇲",
"🇩🇴", "🇪🇺", "🇪🇬", "🇿🇲", "🇪🇭", "🇿🇼", "🇮🇱", "🇮🇳", "🇮🇩", "🇯🇴", "🇮🇶", "🇮🇷",
"🇮🇪", "🇮🇸", "🇪🇸", "🇮🇹", "🇾🇪", "🇨🇻", "🇰🇿", "🇰🇾", "🇰🇭", "🇨🇲", "🇨🇦", "🇮🇨",
"🇶🇦", "🇰🇪", "🇨🇾", "🇰🇬", "🇰🇮", "🇨🇳", "🇰🇵", "🇨🇨", "🇨🇴", "🇰🇲", "🇨🇬", "🇨🇩",
"🇽🇰", "🇨🇷", "🇨🇮", "🇨🇺", "🇰🇼", "🇨🇼", "🇱🇦", "🇱🇻", "🇱🇸", "🇱🇷", "🇱🇧", "🇱🇾",
"🇱🇹", "🇱🇮", "🇱🇺", "🇲🇺", "🇲🇷", "🇲🇬", "🇾🇹", "🇲🇴", "🇲🇰", "🇲🇼", "🇲🇾", "🇲🇱",
"🇲🇻", "🇲🇹", "🇲🇦", "🇲🇶", "🇲🇭", "🇲🇽", "🇫🇲", "🇲🇿", "🇲🇩", "🇲🇨", "🇲🇳", "🇲🇸",
"🇲🇲", "🇳🇦", "🇳🇷", "🇳🇵", "🇳🇪", "🇳🇬", "🇳🇱", "🇳🇮", "🇳🇺", "🇳🇿", "🇳🇨", "🇳🇴",
"🇮🇲", "🇳🇫", "🇨🇽", "🇸🇭", "🇨🇰", "🇹🇨", "🇦🇪", "🇴🇲", "🇵🇰", "🇵🇼", "🇵🇸", "🇵🇦",
"🇵🇬", "🇵🇾", "🇵🇪", "🇵🇳", "🇵🇱", "🇵🇹", "🇵🇷", "🇰🇷", "🇷🇪", "🇷🇺", "🇷🇼", "🇷🇴",
"🇸🇻", "🇼🇸", "🇸🇲", "🇸🇹", "🇸🇦", "🇸🇿", "🇲🇵", "🇸🇨", "🇧🇱", "🇵🇲", "🇸🇳", "🇻🇨",
"🇰🇳", "🇱🇨", "🇷🇸", "🇸🇬", "🇸🇽", "🇸🇾", "🇸🇰", "🇸🇮", "🇺🇸", "🇸🇧", "🇸🇴", "🇸🇩",
"🇸🇷", "🇸🇱", "🇹🇯", "🇹🇭", "🇹🇼", "🇹🇿", "🇹🇬", "🇹🇰", "🇹🇴", "🇹🇹", "🇹🇻", "🇹🇳",
"🇹🇲", "🇹🇷", "🇺🇬", "🇺🇿", "🇺🇦", "🇼🇫", "🇺🇾", "🇫🇴", "🇫🇯", "🇵🇭", "🇫🇮", "🇫🇰",
"🇫🇷", "🇬🇫", "🇵🇫", "🇹🇫", "🇭🇷", "🇨🇫", "🇹🇩", "🇲🇪", "🇨🇿", "🇨🇱", "🇨🇭", "🇸🇪",
"🇱🇰", "🇪🇨", "🇬🇶", "🇪🇷", "🇪🇪", "🇪🇹", "🇿🇦", "🇬🇸", "🇸🇸", "🇯🇲", "🇯🇵"
},
new String[]{
"💟", "", "", "", "🕉", "", "", "🔯", "🕎", "", "", "🛐", "", "", "", "", "",
"", "", "", "", "", "", "", "", "🆔", "", "🈳", "🈹", "", "", "📴", "📳", "🈶",
"🈚", "🈸", "🈺", "🈷", "", "🆚", "🉑", "💮", "🉐", "", "", "🈴", "🈵", "🈲", "🅰", "🅱",
"🆎", "🆑", "🅾", "🆘", "", "📛", "🚫", "", "", "💢", "", "🚷", "🚯", "🚳", "🚱", "🔞",
"📵", "", "", "", "", "", "", "💯", "🔅", "🔆", "🔱", "", "", "", "🚸", "🔰", "",
"🈯", "💹", "", "", "", "", "💠", "🌀", "", "🌐", "", "🏧", "🈂", "🛂", "🛃", "🛄",
"🛅", "", "🚭", "🚾", "🅿", "🚰", "🚹", "🚺", "🚼", "🚻", "🚮", "🎦", "📶", "🈁", "🆖", "🆗",
"🆙", "🆒", "🆕", "🆓", "0⃣", "1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟", "🔢", "",
"", "", "", "", "", "", "", "", "🔀", "🔁", "🔂", "", "🔼", "🔽", "", "", "",
"", "", "", "", "", "", "", "", "", "🔄", "", "", "", "", "#⃣", "*⃣", "",
"🔤", "🔡", "🔠", "🔣", "🎵", "🎶", "", "", "", "🔃", "", "", "", "", "💲", "💱",
"©", "®", "", "🔚", "🔙", "🔛", "🔝", "🔜", "", "🔘", "", "", "🔴", "🔵", "🔸", "🔹",
"🔶", "🔷", "🔺", "", "", "", "", "🔻", "", "", "", "", "🔲", "🔳", "🔈", "🔉", "🔊",
"🔇", "📣", "📢", "🔔", "🔕", "🃏", "🀄", "", "", "", "", "🎴", "👁‍🗨", "💭", "🗯", "💬",
"🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚", "🕛", "🕜", "🕝", "🕞", "🕟",
"🕠", "🕡", "🕢", "🕣", "🕤", "🕥", "🕦", "🕧"
}
};
private ArrayList<EmojiGridAdapter> adapters = new ArrayList<>();
private HashMap<String, Integer> recentUsageCounts = new HashMap<>();
private ArrayList<String> recentChars = new ArrayList<>();
private Listener listener;
private ViewPager pager;
private FrameLayout recentsWrap;
private ArrayList<GridView> views = new ArrayList<>();
private ImageView backspaceButton;
private LinearLayout pagerSlidingTabStripContainer;
private int oldWidth;
private int lastNotifyWidth;
private boolean backspacePressed;
private boolean backspaceOnce;
public EmojiInputView(final Context context) {
super(context);
for (int i = 0; i < predefinedEmojis.length + 1/*add one for the recent page*/; i++) {
GridView gridView = new GridView(context);
gridView.setColumnWidth(AndroidUtilities.dp(45));
gridView.setNumColumns(-1);
views.add(gridView);
EmojiGridAdapter emojiGridAdapter = new EmojiGridAdapter(i - 1); // -1: recent, >=0: predefined
gridView.setAdapter(emojiGridAdapter);
adapters.add(emojiGridAdapter);
}
setBackgroundColor(0xfff5f6f7);
pager = new ViewPager(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(ev);
}
};
pager.setAdapter(new EmojiPagerAdapter());
pagerSlidingTabStripContainer = new LinearLayout(context) {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
return super.onInterceptTouchEvent(ev);
}
};
pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL);
pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7);
addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48));
PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context);
pagerSlidingTabStrip.setViewPager(pager);
pagerSlidingTabStrip.setShouldExpand(true);
pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2));
pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1));
pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2);
pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7);
pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f));
FrameLayout frameLayout = new FrameLayout(context);
pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48));
backspaceButton = new ImageView(context) {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
backspacePressed = true;
backspaceOnce = false;
postBackspaceRunnable(350);
} else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) {
backspacePressed = false;
if (!backspaceOnce) {
if (listener != null && listener.onBackspace()) {
backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
}
}
}
super.onTouchEvent(event);
return true;
}
};
backspaceButton.setImageResource(R.drawable.ic_smiles_backspace);
backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace);
backspaceButton.setScaleType(ImageView.ScaleType.CENTER);
frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48));
View view = new View(context);
view.setBackgroundColor(0xffe2e5e7);
frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.START | Gravity.BOTTOM));
recentsWrap = new FrameLayout(context);
recentsWrap.addView(views.get(0));
TextView textView = new TextView(context);
textView.setText(context.getString(R.string.NoRecentEmoji));
textView.setTextSize(18);
textView.setTextColor(0xff888888);
textView.setGravity(Gravity.CENTER);
recentsWrap.addView(textView);
views.get(0).setEmptyView(textView);
addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START | Gravity.TOP, 0, 48, 0, 0));
loadRecentUsageCounts();
sortRecentEmoji();
adapters.get(0).notifyDataSetChanged();
// normally, we open the emoji-input-keyboard with the most recent page (index 0)
// if there are no most recent emojis, open the first page (index 1) which contains smilies then
if( recentChars.size() == 0 ) {
pager.setCurrentItem(1);
}
}
private void postBackspaceRunnable(final int time) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
if (!backspacePressed) {
return;
}
if (listener != null && listener.onBackspace()) {
backspaceButton.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
}
backspaceOnce = true;
postBackspaceRunnable(Math.max(50, time - 100));
}
}, time);
}
public void clearRecent() {
recentUsageCounts.clear();
recentChars.clear();
saveRecentUsageCounts();
adapters.get(0).notifyDataSetChanged();
}
private void saveRecentUsageCounts() {
SharedPreferences preferences = getContext().getSharedPreferences("emoji", Activity.MODE_PRIVATE);
StringBuilder stringBuilder = new StringBuilder();
for (HashMap.Entry<String, Integer> entry : recentUsageCounts.entrySet()) {
if (stringBuilder.length() != 0) {
stringBuilder.append(",");
}
stringBuilder.append(entry.getKey());
stringBuilder.append("=");
stringBuilder.append(entry.getValue());
}
preferences.edit().putString("emojis", stringBuilder.toString()).apply();
}
public void loadRecentUsageCounts() {
SharedPreferences preferences = getContext().getSharedPreferences("emoji", Activity.MODE_PRIVATE);
String str;
try {
recentUsageCounts.clear();
str = preferences.getString("emojis", "");
if (str.length() > 0) {
String[] args = str.split(",");
for (String arg : args) {
String[] args2 = arg.split("=");
recentUsageCounts.put(args2[0], Utilities.parseInt(args2[1]));
}
}
} catch (Exception e) {
}
}
private void sortRecentEmoji() {
recentChars.clear();
for (HashMap.Entry<String, Integer> entry : recentUsageCounts.entrySet()) {
recentChars.add(entry.getKey());
}
Collections.sort(recentChars, new Comparator<String>() {
@Override
public int compare(String lhs, String rhs) {
Integer count1 = recentUsageCounts.get(lhs);
Integer count2 = recentUsageCounts.get(rhs);
if (count1 == null) {
count1 = 0;
}
if (count2 == null) {
count2 = 0;
}
if (count1 > count2) {
return -1;
} else if (count1 < count2) {
return 1;
}
return 0;
}
});
while (recentChars.size() > 50) {
recentChars.remove(recentChars.size() - 1);
}
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) pagerSlidingTabStripContainer.getLayoutParams();
layoutParams.width = View.MeasureSpec.getSize(widthMeasureSpec);
if (layoutParams.width != oldWidth) {
pagerSlidingTabStripContainer.setLayoutParams(layoutParams);
oldWidth = layoutParams.width;
}
super.onMeasure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
if (lastNotifyWidth != right - left) {
lastNotifyWidth = right - left;
}
super.onLayout(changed, left, top, right, bottom);
}
public void setListener(Listener value) {
listener = value;
}
public void invalidateViews() {
for (GridView gridView : views) {
if (gridView != null) {
gridView.invalidateViews();
}
}
}
@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
if (visibility != GONE) {
sortRecentEmoji();
adapters.get(0).notifyDataSetChanged();
}
}
private class SingleEmojiView extends ImageView {
public SingleEmojiView(Context context) {
super(context);
setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
sendEmoji();
}
});
setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (pager.getCurrentItem() == 0) {
listener.onClearEmojiRecent();
}
return false;
}
});
setBackgroundResource(R.drawable.list_selector);
setScaleType(ImageView.ScaleType.CENTER);
}
private void sendEmoji() {
String code = (String) getTag();
Integer count = recentUsageCounts.get(code);
if (count == null) {
count = 0;
}
if (count == 0 && recentUsageCounts.size() > 50) {
for (int a = recentChars.size() - 1; a >= 0; a--) {
String emoji = recentChars.get(a);
recentUsageCounts.remove(emoji);
recentChars.remove(a);
if (recentUsageCounts.size() <= 50) {
break;
}
}
}
recentUsageCounts.put(code, ++count);
if (pager.getCurrentItem() != 0) {
sortRecentEmoji();
adapters.get(0).notifyDataSetChanged();
views.get(0).invalidateViews();
}
saveRecentUsageCounts();
if (listener != null) {
listener.onEmojiSelected(fixEmoji(code));
}
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(widthMeasureSpec));
}
}
private class EmojiGridAdapter extends BaseAdapter {
private int emojiPage; // -1: recent, >= 0: predefined from predefinedEmojis
public EmojiGridAdapter(int page) {
emojiPage = page;
}
public int getCount() {
int ret = emojiPage == -1? recentChars.size() : predefinedEmojis[emojiPage].length;
return ret;
}
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int i, View view, ViewGroup paramViewGroup) {
SingleEmojiView imageView = (SingleEmojiView) view;
if (imageView == null) {
imageView = new SingleEmojiView(getContext());
}
String code;
String coloredCode;
if (emojiPage == -1) {
coloredCode = code = recentChars.get(i);
} else {
coloredCode = code = predefinedEmojis[emojiPage][i];
}
// Draw native Emojis using TextDrawable, not imageView.setImageDrawable(Emoji.getEmojiBigDrawable(code)). See:
// https://github.com/Jamesits/Moegram/commit/8e52c6222cf00bc9a86d52fed4c06558f48c345c
// and https://github.com/amulyakhare/TextDrawable
imageView.setTag(code);
int bigImgSize;
bigImgSize = AndroidUtilities.dp(32);
imageView.setImageDrawable(TextDrawable.builder().beginConfig().textColor(Color.BLACK).fontSize(bigImgSize).endConfig().buildRect(coloredCode, Color.TRANSPARENT));
return imageView;
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (observer != null) {
super.unregisterDataSetObserver(observer);
}
}
}
private class EmojiPagerAdapter extends PagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
public void destroyItem(ViewGroup viewGroup, int position, Object object) {
View view;
if (position == 0) {
view = recentsWrap;
} else {
view = views.get(position);
}
viewGroup.removeView(view);
}
public int getCount() {
return views.size();
}
public int getPageIconResId(int position) {
int[] icons = {
R.drawable.ic_emoji_recent,
R.drawable.ic_emoji_smile,
R.drawable.ic_emoji_flower,
R.drawable.ic_emoji_bell,
R.drawable.ic_emoji_car,
R.drawable.ic_emoji_symbol};
return icons[position>=0 && position<icons.length? position : 0];
}
public Object instantiateItem(ViewGroup viewGroup, int position) {
View view;
if (position == 0) {
view = recentsWrap;
} else {
view = views.get(position);
}
viewGroup.addView(view);
return view;
}
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
if (observer != null) {
super.unregisterDataSetObserver(observer);
}
}
}
private static final char[] insertVariationSelector = {
0x2B50, 0x2600, 0x26C5, 0x2601, 0x26A1, 0x2744, 0x26C4, 0x2614, 0x2708, 0x26F5, 0x2693,
0x26FD, 0x26F2, 0x26FA, 0x26EA, 0x2615, 0x26BD, 0x26BE, 0x26F3, 0x231A, 0x260E, 0x231B,
0x2709, 0x2702, 0x2712, 0x270F, 0x2648, 0x2649, 0x264A, 0x264B, 0x264C, 0x264D, 0x264E,
0x264F, 0x2650, 0x2651, 0x2652, 0x2653, 0x2734, 0x3299, 0x3297, 0x26D4, 0x2B55, 0x2668,
0x2757, 0x203C, 0x2049, 0x303D, 0x26A0, 0x267B, 0x2747, 0x2733, 0x24C2, 0x267F, 0x25B6,
0x25C0, 0x27A1, 0x2B05, 0x2B06, 0x2B07, 0x2197, 0x2198, 0x2199, 0x2196, 0x2195, 0x2194,
0x21AA, 0x21A9, 0x2934, 0x2935, 0x2139, 0x2714, 0x2716, 0x2611, 0x26AA, 0x26AB, 0x25AA,
0x25AB, 0x2B1B, 0x2B1C, 0x25FC, 0x25FB, 0x25FE, 0x25FD, 0x2660, 0x2663, 0x2665, 0x2666,
0x263A, 0x2639, 0x270C, 0x261D, 0x2764
};
private static final HashMap<Character, Boolean> insertVariationSelectorMap = new HashMap<>(insertVariationSelector.length);
static {
for (int a = 0; a < insertVariationSelector.length; a++) {
insertVariationSelectorMap.put(insertVariationSelector[a], true);
}
}
private static String fixEmoji(String emoji) {
char ch;
int lenght = emoji.length();
for (int a = 0; a < lenght; a++) {
ch = emoji.charAt(a);
if (ch >= 0xD83C && ch <= 0xD83E) {
if (ch == 0xD83C && a < lenght - 1) {
ch = emoji.charAt(a + 1);
if (ch == 0xDE2F || ch == 0xDC04 || ch == 0xDE1A || ch == 0xDD7F) {
emoji = emoji.substring(0, a + 2) + "\uFE0F"/*VARIATION SELECTOR-16*/ + emoji.substring(a + 2);
lenght++;
a += 2;
} else {
a++;
}
} else {
a++;
}
} else if (ch == 0x20E3 /*COMBINING ENCLOSING KEYCAP*/) {
return emoji;
} if (insertVariationSelectorMap.containsKey(ch)) {
emoji = emoji.substring(0, a + 1) + "\uFE0F"/*VARIATION SELECTOR-16*/ + emoji.substring(a + 1);
lenght++;
a++;
}
}
return emoji;
}
public static CharSequence replaceEmoji(CharSequence cs, boolean createNew) {
if (cs == null || cs.length() == 0) {
return cs;
}
Spannable s;
if (!createNew && cs instanceof Spannable) {
s = (Spannable) cs;
} else {
s = Spannable.Factory.getInstance().newSpannable(cs.toString());
}
return s;
}
}
@@ -1,106 +0,0 @@
/*******************************************************************************
*
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see http://www.gnu.org/licenses/ .
*
******************************************************************************/
package com.b44t.messenger;
import com.b44t.messenger.time.FastDateFormat;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.util.Locale;
public class FileLog {
private OutputStreamWriter streamWriter = null;
private FastDateFormat dateFormat = null;
private DispatchQueue logQueue = null;
private File currentFile = null;
private static volatile FileLog Instance = null;
public static FileLog getInstance() {
FileLog localInstance = Instance;
if (localInstance == null) {
synchronized (FileLog.class) {
localInstance = Instance;
if (localInstance == null) {
Instance = localInstance = new FileLog();
}
}
}
return localInstance;
}
public FileLog() {
dateFormat = FastDateFormat.getInstance("yyyyMMdd_HHmmss", Locale.US);
try {
File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null);
if (sdCard == null) {
return;
}
File dir = new File(sdCard.getAbsolutePath() + "/logs");
dir.mkdirs();
currentFile = new File(dir, dateFormat.format(System.currentTimeMillis()) + ".txt");
} catch (Exception e) {
e.printStackTrace();
}
try {
logQueue = new DispatchQueue("logQueue");
currentFile.createNewFile();
FileOutputStream stream = new FileOutputStream(currentFile);
streamWriter = new OutputStreamWriter(stream);
streamWriter.write("-----start log " + dateFormat.format(System.currentTimeMillis()) + "-----\n");
streamWriter.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void log(final String what, final String tag, final String message)
{
if (getInstance().streamWriter != null) {
getInstance().logQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
getInstance().streamWriter.write(getInstance().dateFormat.format(System.currentTimeMillis()) + " " + what + "/" + tag + ": " + message + "\n");
getInstance().streamWriter.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
public static void e(final String tag, final String message) {
log("E", tag, message);
}
public static void w(final String tag, final String message) {
log("W", tag, message);
}
public static void i(final String tag, final String message) {
log("I", tag, message);
}
}
@@ -21,7 +21,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.content.Context;
import android.content.Intent;
@@ -39,18 +39,13 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.MrContact;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.ui.Adapters.BaseFragmentAdapter;
import com.b44t.ui.Cells.GreySectionCell;
import com.b44t.ui.Cells.UserCell;
import com.b44t.ui.ActionBar.ActionBar;
import com.b44t.ui.ActionBar.ActionBarMenu;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.messenger.Components.BaseFragmentAdapter;
import com.b44t.messenger.Cells.GreySectionCell;
import com.b44t.messenger.Cells.UserCell;
import com.b44t.messenger.ActionBar.ActionBar;
import com.b44t.messenger.ActionBar.ActionBarMenu;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.LayoutHelper;
import java.util.ArrayList;
@@ -38,7 +38,7 @@ import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import com.b44t.ui.Components.AnimatedFileDrawable;
import com.b44t.messenger.Components.AnimatedFileDrawable;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -46,8 +46,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.HashMap;
@@ -29,7 +29,6 @@ import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
@@ -39,7 +38,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import com.b44t.ui.Components.AnimatedFileDrawable;
import com.b44t.messenger.Components.AnimatedFileDrawable;
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
@@ -21,10 +21,9 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
@@ -49,21 +48,11 @@ import android.view.Window;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.b44t.messenger.AndroidUtilities;
import com.b44t.messenger.ContactsController;
import com.b44t.messenger.ImageLoader;
import com.b44t.messenger.KeepAliveService;
import com.b44t.messenger.MrMailbox;
import com.b44t.messenger.SendMessagesHelper;
import com.b44t.messenger.ApplicationLoader;
import com.b44t.messenger.NotificationCenter;
import com.b44t.messenger.R;
import com.b44t.messenger.UserConfig;
import com.b44t.ui.ActionBar.ActionBarLayout;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.Components.LayoutHelper;
import com.b44t.ui.Components.PasscodeView;
import com.b44t.ui.ActionBar.Theme;
import com.b44t.messenger.ActionBar.ActionBarLayout;
import com.b44t.messenger.ActionBar.BaseFragment;
import com.b44t.messenger.Components.LayoutHelper;
import com.b44t.messenger.Components.PasscodeView;
import com.b44t.messenger.ActionBar.Theme;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -71,7 +60,7 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate {
public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, ChatlistActivity.ChatlistActivityDelegate {
private boolean finished;
private String videoPath;
@@ -154,9 +143,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if ( MrMailbox.isConfigured()==0 ) {
Bundle args = new Bundle();
args.putBoolean("fromIntro", true);
actionBarLayout.addFragmentToStack(new SettingsAccountActivity(args));
actionBarLayout.addFragmentToStack(new SettingsAccountFragment(args));
} else {
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
actionBarLayout.addFragmentToStack(new ChatlistActivity(null));
}
try {
@@ -174,7 +163,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
break;
case "settings": {
SettingsActivity settings = new SettingsActivity();
SettingsFragment settings = new SettingsFragment();
actionBarLayout.addFragmentToStack(settings);
settings.restoreSelfArgs(savedInstanceState);
break;
@@ -577,7 +566,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
{
final String createChatWithFinal = createChatWith;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int chatId = MrMailbox.createChatByContactId(MrMailbox.createContact("", createChatWithFinal));
@@ -591,7 +580,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
builder.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.AskStartChatWith), createChatWith)));
builder.show();
}
@@ -619,10 +608,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
args.putString("selectAlertString", ApplicationLoader.applicationContext.getString(R.string.SendMessagesTo));
args.putString("selectAlertPreviewString", sendingText /*may be NULL*/);
args.putString("selectAlertOkButtonString", ApplicationLoader.applicationContext.getString(R.string.Send));
DialogsActivity fragment = new DialogsActivity(args);
ChatlistActivity fragment = new ChatlistActivity(args);
fragment.setDelegate(this);
boolean removeLast;
removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
removeLast = actionBarLayout.fragmentsStack.size() > 1 && actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1) instanceof ChatlistActivity;
actionBarLayout.presentFragment(fragment, removeLast, true, true);
pushOpened = true;
if (PhotoViewer.getInstance().isVisible()) {
@@ -630,14 +619,14 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else {
didSelectDialog(null, dialogId, false);
didSelectChat(null, dialogId, false);
}
}
if (!pushOpened && !isNew)
{
if (actionBarLayout.fragmentsStack.isEmpty()) {
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
actionBarLayout.addFragmentToStack(new ChatlistActivity(null));
}
actionBarLayout.showLastFragment();
}
@@ -653,7 +642,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
@Override
public void didSelectDialog(DialogsActivity dialogsFragment, long dialog_id, boolean param) {
public void didSelectChat(ChatlistActivity dialogsFragment, long dialog_id, boolean param) {
if (dialog_id != 0) {
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true);
@@ -786,7 +775,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(msg.trim());
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() {
builder.setPositiveButton(R.string.PermissionOpenSettings, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
@@ -800,7 +789,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
}
});
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
builder.setNegativeButton(R.string.Cancel, null);
builder.show();
return;
}
@@ -830,7 +819,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
protected void onDestroy() {
MrMailbox.log_i("DeltaChat", "*** LaunchActivity.onDestroy()");
PhotoViewer.getInstance().destroyPhotoViewer();
StickerPreviewViewer.getInstance().destroy();
try {
if (visibleDialog != null) {
visibleDialog.dismiss();
@@ -955,7 +943,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (lastFragment instanceof ChatActivity && args != null) {
outState.putBundle("args", args);
outState.putString("fragment", "chat");
} else if (lastFragment instanceof SettingsActivity) {
} else if (lastFragment instanceof SettingsFragment) {
outState.putString("fragment", "settings");
} else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
outState.putBundle("args", args);
@@ -20,7 +20,7 @@
******************************************************************************/
package com.b44t.ui;
package com.b44t.messenger;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -1,7 +1,6 @@
/*******************************************************************************
*
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -23,47 +22,61 @@
package com.b44t.messenger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.os.Build;
import android.text.format.DateFormat;
import android.view.View;
import com.b44t.messenger.time.FastDateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class LocaleController {
public static boolean isRTL = false;
public FastDateFormat formatterDay;
public FastDateFormat formatterWeek;
public FastDateFormat formatterMonth;
public FastDateFormat formatterYear;
public FastDateFormat formatterMonthYear;
public FastDateFormat chatDate;
public FastDateFormat chatFullDate;
private String formattersCreatedFor = "";
private class TimeZoneChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.applicationHandler.post(new Runnable() {
@Override
public void run() {
if (!formatterMonth.getTimeZone().equals(TimeZone.getDefault())) {
LocaleController.getInstance().recreateFormatters();
}
}
});
private SimpleDateFormat getFormatter(int resId)
{
// do not cache the instances as SimpleDateFormat is not thread safe
try {
return new SimpleDateFormat(ApplicationLoader.applicationContext.getString(resId), Locale.getDefault());
}
catch (Exception e) {
// a fallback if the translated resource contains bad data
return new SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.US);
}
}
private SimpleDateFormat getFormatterChatDate()
{
return getFormatter(R.string.chatDate);
}
private SimpleDateFormat getFormatterChatFullDate()
{
return getFormatter(R.string.chatFullDate);
}
private SimpleDateFormat getFormatterWeek()
{
return getFormatter(R.string.formatterWeek);
}
private SimpleDateFormat getFormatterMonth()
{
return getFormatter(R.string.formatterMonth);
}
public SimpleDateFormat getFormatterYear()
{
return getFormatter(R.string.formatterYear);
}
public SimpleDateFormat getFormatterDay()
{
boolean is24HourFormat = DateFormat.is24HourFormat(ApplicationLoader.applicationContext);
return getFormatter(is24HourFormat? R.string.formatterDay24H : R.string.formatterDay12H);
}
private static volatile LocaleController Instance = null;
@@ -81,15 +94,7 @@ public class LocaleController {
}
public LocaleController() {
recreateFormatters();
try {
IntentFilter timezoneFilter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
ApplicationLoader.applicationContext.registerReceiver(new TimeZoneChangedReceiver(), timezoneFilter);
} catch (Exception e) {
}
checkRTL();
}
public void rebuildUiParts()
@@ -109,8 +114,8 @@ public class LocaleController {
// - the permanent notification (Waiting for messages ...) - notfifications are not re-translated after a locale change. This cannot be done without listening to the language-change-envent.
// - some formatters and other cached values, maybe this can be done in other ways, however, it's just working.
Locale newLocale = Locale.getDefault();
if( newLocale!=null && !newLocale.getDisplayName().equals(formattersCreatedFor) ) { // onDeviceConfigurationChange() is also called on screen orientation changes; do not rebuild the locale stuff in these cases
recreateFormatters();
if( newLocale!=null ) { // onDeviceConfigurationChange() is also called on screen orientation changes; do not rebuild the locale stuff in these cases
checkRTL();
rebuildUiParts(); // this is really needed, see comment in rebuildUiParts()
}
}
@@ -124,32 +129,16 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (year == dateYear) {
return getInstance().chatDate.format(date * 1000);
return getInstance().getFormatterChatDate().format(date * 1000);
}
return getInstance().chatFullDate.format(date * 1000);
return getInstance().getFormatterChatFullDate().format(date * 1000);
} catch (Exception e) {
}
return "LOC_ERR: formatDateChat";
}
private FastDateFormat createFormatter(Locale locale, String format, String defaultFormat) {
if (format == null || format.length() == 0) {
format = defaultFormat;
}
FastDateFormat formatter;
try {
formatter = FastDateFormat.getInstance(format, locale);
} catch (Exception e) {
format = defaultFormat;
formatter = FastDateFormat.getInstance(format, locale);
}
return formatter;
}
private void recreateFormatters() {
Locale locale = Locale.getDefault();
private void checkRTL() {
isRTL = false;
if (Build.VERSION.SDK_INT >= 17) {
// ViewCompat.getLayoutDirection() can also be used, however, this function always returns LTR for SDK < 17, too, but requires a additinal view handle
@@ -158,21 +147,9 @@ public class LocaleController {
isRTL = true;
}
}
boolean is24HourFormat = DateFormat.is24HourFormat(ApplicationLoader.applicationContext);
formatterMonth = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.formatterMonth), "dd MMM");
formatterYear = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.formatterYear), "dd.MM.yyyy");
chatDate = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.chatDate), "d MMMM");
chatFullDate = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.chatFullDate), "d MMMM yyyy");
formatterWeek = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.formatterWeek), "EEE");
formatterMonthYear = createFormatter(locale, ApplicationLoader.applicationContext.getString(R.string.formatterMonthYear), "MMMM yyyy");
formatterDay = createFormatter(locale, is24HourFormat ? ApplicationLoader.applicationContext.getString(R.string.formatterDay24H) : ApplicationLoader.applicationContext.getString(R.string.formatterDay12H), is24HourFormat ? "HH:mm" : "h:mm a");
formattersCreatedFor = locale.getDisplayName();
}
public static String stringForMessageListDate(long date) {
public static String dateForChatlist(long date) {
try {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
@@ -182,15 +159,15 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (year != dateYear) {
return getInstance().formatterYear.format(new Date(date * 1000));
return getInstance().getFormatterYear().format(new Date(date * 1000));
} else {
int dayDiff = dateDay - day;
if(dayDiff == 0 || dayDiff == -1 && (int)(System.currentTimeMillis() / 1000) - date < 60 * 60 * 8) {
return getInstance().formatterDay.format(new Date(date * 1000));
return getInstance().getFormatterDay().format(new Date(date * 1000));
} else if(dayDiff > -7 && dayDiff <= -1) {
return getInstance().formatterWeek.format(new Date(date * 1000));
return getInstance().getFormatterWeek().format(new Date(date * 1000));
} else {
return getInstance().formatterMonth.format(new Date(date * 1000));
return getInstance().getFormatterMonth().format(new Date(date * 1000));
}
}
} catch (Exception e) {

Some files were not shown because too many files have changed in this diff Show More