Compare commits
151 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 930facc457 | |||
| 5a428458b5 | |||
| fa12c90f23 | |||
| 2e16ccb041 | |||
| df7dda0e96 | |||
| 28c86b4784 | |||
| 175a4ddf95 | |||
| e4b24b0d99 | |||
| 989fcd9564 | |||
| 4877ef1407 | |||
| c1487e3f74 | |||
| 6d4650bba9 | |||
| fb6f02696d | |||
| 8ed4abebb7 | |||
| f90de9c0de | |||
| 206d2a58d2 | |||
| 6001d2fb3a | |||
| 1ceab73dfe | |||
| dc38b949a8 | |||
| 96b740d4da | |||
| 1455f7849b | |||
| 7f14a4da90 | |||
| 0d04064969 | |||
| 37fbda3126 | |||
| 023e62fbd4 | |||
| b818007398 | |||
| 7c1bb82dd4 | |||
| e3a6fa4cac | |||
| 6e6aa88b3a | |||
| c266bd6eba | |||
| e383c2b79a | |||
| 56a5b23d98 | |||
| 10eb41aca7 | |||
| a0a50e3433 | |||
| 07449e9018 | |||
| 5027373b54 | |||
| 1d1e08fc15 | |||
| 6eabf32464 | |||
| acb4a2e5a0 | |||
| ba1b5211a2 | |||
| eb8d248fd9 | |||
| f248a86ce2 | |||
| 8e9b55958d | |||
| 6decd0ee76 | |||
| 16384c12c2 | |||
| 9be5c50e31 | |||
| 46421d8821 | |||
| 13cb356aef | |||
| b210b72460 | |||
| 6aa63f48e1 | |||
| eaba4a4ab7 | |||
| fbc61bce2a | |||
| 5c98e34966 | |||
| 9b461d372d | |||
| b57a81c7c2 | |||
| 7cf41805ec | |||
| 59efa059fd | |||
| e462d66746 | |||
| cd0c3f533a | |||
| 0027b17ef9 | |||
| 9ee5325f29 | |||
| ac433edcf8 | |||
| f71e7e58e1 | |||
| 4af1e9263a | |||
| 01d3a75faa | |||
| d015ab4e93 | |||
| abcf3600a6 | |||
| ac6c497721 | |||
| 2dafecc665 | |||
| 3a48f0a04a | |||
| 1caf3a8956 | |||
| ba1dd07b01 | |||
| 695a97276f | |||
| 0d50753754 | |||
| e357786980 | |||
| 54ab0ba860 | |||
| 44675fffe5 | |||
| e5c6fb0e50 | |||
| 82666fb5f0 | |||
| 9ab86ca310 | |||
| 7153b4c7be | |||
| e73f4f30cb | |||
| e365a20d6e | |||
| 4a9f9eefd2 | |||
| 2ff632bb87 | |||
| f5be0708be | |||
| 92908ab673 | |||
| c20f8699f3 | |||
| 81e60a3916 | |||
| 4f8e25a6c0 | |||
| 4038088c5f | |||
| bc972faf2a | |||
| 0720fec295 | |||
| fba37c7c12 | |||
| debaa48e58 | |||
| c4a63657cd | |||
| a723783c01 | |||
| 26a922e16a | |||
| 9a20d33d55 | |||
| 3abe9946d4 | |||
| dcf4857b6e | |||
| 701ae43bd6 | |||
| cb67d0a45b | |||
| 1684bc3acc | |||
| ee32ef2f09 | |||
| c9ed86a81a | |||
| 8421e85229 | |||
| 0b2eead1be | |||
| 0d30d4a4f3 | |||
| ac55638e46 | |||
| e57c45da71 | |||
| 4b93e2e57c | |||
| 2bab5a65f4 | |||
| 66f379f80b | |||
| 4a8749349f | |||
| 54fe2accb6 | |||
| ec21b57106 | |||
| 9e62523b6d | |||
| 2b69ba5716 | |||
| dadfecf8f3 | |||
| e5695194d5 | |||
| e1c192ddd3 | |||
| ee5e6cb125 | |||
| 5ca9bbff28 | |||
| 1761335092 | |||
| b87e135b3c | |||
| c1154a87cc | |||
| a683880f7e | |||
| 23acff2a87 | |||
| 484d723c75 | |||
| ecab439d0a | |||
| d02732c16d | |||
| f55106612c | |||
| efde505eb5 | |||
| 7ae296dcac | |||
| 8a20f439c0 | |||
| 57a8251313 | |||
| 6039a4e6b1 | |||
| ea59519c09 | |||
| 84e7345607 | |||
| 4357817faf | |||
| fb4f378b86 | |||
| ee081b3037 | |||
| 33d3d92f62 | |||
| 9ba8659536 | |||
| 3c14d32e19 | |||
| 6cb866233b | |||
| e98bffdacc | |||
| 96400768b5 | |||
| dd8474cecf | |||
| 7b98265a2a |
@@ -1,11 +1,73 @@
|
||||
# Delta Chat Changelog
|
||||
|
||||
## 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
|
||||
|
||||
* Backup export and import function
|
||||
* Query password before export
|
||||
* Move replies from normal E-Mail-Clients to the "Chats" folder
|
||||
* Improve helping MUAs on showing chat threads
|
||||
* Improve onboarding
|
||||
* Add URL to default footer
|
||||
* Test a different approach for battery saving in this release
|
||||
* Update French, Italian, German, Polish, Portuguese, Russian and Ukrainian translations
|
||||
|
||||
## v0.9.4
|
||||
2017-08-23
|
||||
|
||||
* Introduce an editable "Status" field that is shown eg. in email footers
|
||||
* Editable and synchronized group images
|
||||
* Show the subject of messages that cannot be decrypted
|
||||
* Do not send "Read receipts" when decryption fails
|
||||
* Do not request "Read receipts" from normal MUAs as there are too many MUAs responding with weird, non-standard formats
|
||||
* Deleting a chat always deletes all messages from the device permanently
|
||||
* Ignore messages from mailing lists
|
||||
* Do not spread the original authors name nor address on forwarding
|
||||
* Encrypt mails send to SMTP and to IMAP the same way
|
||||
* Improve showing HTML-mails
|
||||
* Cleanup Android code
|
||||
* Remove badge counter on app restart
|
||||
* Add Ukrainian translation
|
||||
* Add Telugu translation
|
||||
* Add Catalan translation
|
||||
* Update German, Spanish, French, Hungarian, Italian, Polish, Portuguese and Russian translations
|
||||
|
||||
## v0.9.3
|
||||
2017-07-13
|
||||
|
||||
* Introduce "Read receipts" and avoid social pressure to leave it activated
|
||||
* Improve encryption dialog in profile
|
||||
* Fix marking messages as "seen" when opening the contact requests
|
||||
* Ignore signature.asc files of signed-only messages
|
||||
* Update Polish, Portuguese and Russian translations
|
||||
|
||||
## v0.9.2
|
||||
2017-06-28
|
||||
|
||||
* Encrypt group chats
|
||||
* Cryptographically sign messages
|
||||
* Validate signatures of incoming messages ("Info" shows the state)
|
||||
* Show a little lock beside end-to-end-encrypted messages with a validated signature
|
||||
* If end-to-end-encryption is available on sending time, guarantee the message not to be sent without end-to-end-encryption later
|
||||
* Show special characters in HTML-mails
|
||||
* Help MUAs on showing chat threads
|
||||
* Show attachments from multipart/alternative structures
|
||||
* Upgrade from Autocrypt Level 0 to Level 1; as the levels are not compatible, encryption on mixed setups does not happen
|
||||
* Update Polish, Portuguese, Spanish and French translations
|
||||
|
||||
## v0.9.1
|
||||
2017-06-04
|
||||
|
||||
* Profile: Improve encryption state dialog
|
||||
* Improved video quality of short clips
|
||||
* Make "Encrytion" dialog localizable
|
||||
* Make encryption-dialog localizable
|
||||
* Update Russian translation
|
||||
|
||||
## v0.9.0
|
||||
|
||||
@@ -48,7 +48,10 @@ android {
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file("config/debug.keystore")
|
||||
def debugKeystore = file("config/debug.keystore")
|
||||
if (debugKeystore.exists()) {
|
||||
storeFile debugKeystore
|
||||
}
|
||||
}
|
||||
|
||||
release {
|
||||
@@ -76,7 +79,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig.versionCode = 40
|
||||
defaultConfig.versionCode = 45
|
||||
|
||||
sourceSets.main {
|
||||
jniLibs.srcDir 'libs'
|
||||
@@ -118,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.1" // do NOT forget to increase defaultConfig.versionCode!
|
||||
versionName "0.9.6" // do NOT forget to increase defaultConfig.versionCode!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1311,6 +1311,7 @@ LOCAL_MODULE := sqlite
|
||||
LOCAL_CFLAGS := -w -std=c11 -Os -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0
|
||||
LOCAL_CFLAGS += -DSQLITE_OMIT_LOAD_EXTENSION
|
||||
LOCAL_CFLAGS += -DSQLITE_MAX_MMAP_SIZE=0 -DSQLITE_OMIT_WAL # HACK: the defines are used to skip the pointer reference to mmap set in aSyscall[] - mmap seems to be a #define that cannot be used this way on Android - otherwise we get the error: 'mmap' undeclared here (not in a function)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
./messenger-backend/libs/sqlite/sqlite3.c
|
||||
@@ -1636,8 +1637,7 @@ LOCAL_SRC_FILES += \
|
||||
./messenger-backend/src/mrchatlist.c \
|
||||
./messenger-backend/src/mrcmdline.c \
|
||||
./messenger-backend/src/mrcontact.c \
|
||||
./messenger-backend/src/mre2ee.c \
|
||||
./messenger-backend/src/mre2ee_driver_openssl.c \
|
||||
./messenger-backend/src/mrdehtml.c \
|
||||
./messenger-backend/src/mrimap.c \
|
||||
./messenger-backend/src/mrjob.c \
|
||||
./messenger-backend/src/mrkey.c \
|
||||
@@ -1645,12 +1645,16 @@ LOCAL_SRC_FILES += \
|
||||
./messenger-backend/src/mrloginparam.c \
|
||||
./messenger-backend/src/mrmailbox.c \
|
||||
./messenger-backend/src/mrmailbox_configure.c \
|
||||
./messenger-backend/src/mrmailbox_e2ee.c \
|
||||
./messenger-backend/src/mrmailbox_imex.c \
|
||||
./messenger-backend/src/mrmailbox_log.c \
|
||||
./messenger-backend/src/mrmailbox_tools.c \
|
||||
./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 \
|
||||
./messenger-backend/src/mrsaxparser.c \
|
||||
./messenger-backend/src/mrsimplify.c \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_PLATFORM := android-9
|
||||
APP_PLATFORM := android-14
|
||||
APP_ABI := armeabi armeabi-v7a x86
|
||||
NDK_TOOLCHAIN_VERSION := 4.9
|
||||
APP_STL := gnustl_static
|
||||
|
||||
@@ -363,15 +363,19 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_getChatIdByContactId(JNIEnv *en
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_markseenMsg(JNIEnv *env, jclass cls, jint msg_id)
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_markseenMsgs(JNIEnv *env, jclass cls, jintArray msg_ids)
|
||||
{
|
||||
return (jint)mrmailbox_markseen_msg(get_mrmailbox_t(env, cls), msg_id);
|
||||
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);
|
||||
free(msg_ids_ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_markseenChat(JNIEnv *env, jclass cls, jint chat_id)
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_marknoticedChat(JNIEnv *env, jclass cls, jint chat_id)
|
||||
{
|
||||
return (jlong)mrmailbox_markseen_chat(get_mrmailbox_t(env, cls), chat_id);
|
||||
return (jlong)mrmailbox_marknoticed_chat(get_mrmailbox_t(env, cls), chat_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,6 +421,15 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_setChatName(JNIEnv *env, jclass
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_setChatImage(JNIEnv *env, jclass cls, jint chat_id, jstring image/*NULL=delete*/)
|
||||
{
|
||||
CHAR_REF(image);
|
||||
jint ret = (jint)mrmailbox_set_chat_image(get_mrmailbox_t(env, cls), chat_id, imagePtr/*CHAR_REF() preserves NULL*/);
|
||||
CHAR_UNREF(image);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_deleteChat(JNIEnv *env, jclass cls, jint chat_id)
|
||||
{
|
||||
mrmailbox_delete_chat(get_mrmailbox_t(env, cls), chat_id);
|
||||
@@ -460,11 +473,11 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_forwardMsgs(JNIEnv *env, jclass
|
||||
|
||||
/* MrMailbox - handle config */
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfig(JNIEnv *env, jclass cls, jstring key, jstring value)
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfig(JNIEnv *env, jclass cls, jstring key, jstring value /*may be NULL*/)
|
||||
{
|
||||
CHAR_REF(key);
|
||||
CHAR_REF(value);
|
||||
mrmailbox_set_config(get_mrmailbox_t(env, cls), keyPtr, valuePtr);
|
||||
mrmailbox_set_config(get_mrmailbox_t(env, cls), keyPtr, valuePtr /*is NULL if value is NULL, CHAR_REF() handles this*/);
|
||||
CHAR_UNREF(key);
|
||||
CHAR_UNREF(value);
|
||||
}
|
||||
@@ -478,16 +491,19 @@ JNIEXPORT void Java_com_b44t_messenger_MrMailbox_setConfigInt(JNIEnv *env, jclas
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getConfig(JNIEnv *env, jclass cls, jstring key, jstring def)
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getConfig(JNIEnv *env, jclass cls, jstring key, jstring def/*may be NULL*/)
|
||||
{
|
||||
CHAR_REF(key);
|
||||
CHAR_REF(def);
|
||||
char* temp = mrmailbox_get_config(get_mrmailbox_t(env, cls), keyPtr, defPtr);
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
char* temp = mrmailbox_get_config(get_mrmailbox_t(env, cls), keyPtr, defPtr /*is NULL if value is NULL, CHAR_REF() handles this*/);
|
||||
jstring ret = NULL;
|
||||
if( temp ) {
|
||||
ret = JSTRING_NEW(temp);
|
||||
}
|
||||
free(temp);
|
||||
CHAR_UNREF(key);
|
||||
CHAR_UNREF(def);
|
||||
return ret;
|
||||
return ret; /* returns NULL only if key is unset and "def" is NULL */
|
||||
}
|
||||
|
||||
|
||||
@@ -531,20 +547,34 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_cmdline(JNIEnv *env, jclass
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_importStuff(JNIEnv *env, jclass cls, jint what, jstring dir)
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_imex(JNIEnv *env, jclass cls, jint what, jstring dir)
|
||||
{
|
||||
CHAR_REF(dir);
|
||||
jint ret = mrmailbox_import(get_mrmailbox_t(env, cls), what, dirPtr);
|
||||
mrmailbox_imex(get_mrmailbox_t(env, cls), what, dirPtr, "");
|
||||
CHAR_UNREF(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_exportStuff(JNIEnv *env, jclass cls, jint what, jstring dir)
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_checkPassword(JNIEnv *env, jclass cls, jstring pw)
|
||||
{
|
||||
CHAR_REF(pw);
|
||||
jint r = mrmailbox_check_password(get_mrmailbox_t(env, cls), pwPtr);
|
||||
CHAR_UNREF(pw);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_imexHasBackup(JNIEnv *env, jclass cls, jstring dir)
|
||||
{
|
||||
CHAR_REF(dir);
|
||||
mrmailbox_export(get_mrmailbox_t(env, cls), what, dirPtr);
|
||||
jstring ret = NULL;
|
||||
char* temp = mrmailbox_imex_has_backup(get_mrmailbox_t(env, cls), dirPtr);
|
||||
if( temp ) {
|
||||
ret = JSTRING_NEW(temp);
|
||||
free(temp);
|
||||
}
|
||||
CHAR_UNREF(dir);
|
||||
return ret; /* may be NULL! */
|
||||
}
|
||||
|
||||
|
||||
@@ -648,6 +678,21 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrChat_getSubtitle(JNIEnv *env, jclass
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getParam(JNIEnv *env, jclass cls, jint key, jstring def)
|
||||
{
|
||||
mrchat_t* ths = get_mrchat_t(env, cls);
|
||||
jstring ret = NULL;
|
||||
CHAR_REF(def);
|
||||
char* temp = mrparam_get(ths? ths->m_param:NULL, key, defPtr);
|
||||
if( temp ) {
|
||||
ret = JSTRING_NEW(temp);
|
||||
free(temp);
|
||||
}
|
||||
CHAR_UNREF(def);
|
||||
return ret; /* returns NULL only if key is unset and "def" is NULL */
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getParamInt(JNIEnv *env, jclass cls, jint key, jint def)
|
||||
{
|
||||
mrchat_t* ths = get_mrchat_t(env, cls);
|
||||
@@ -679,15 +724,9 @@ JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatGetDraftReplyToMsgId(JNIEnv
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatGetTotalMsgCount(JNIEnv *env, jclass c, jlong hChat)
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getFreshMsgCount(JNIEnv *env, jclass cls)
|
||||
{
|
||||
return mrchat_get_total_msg_count((mrchat_t*)hChat);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_MrChat_MrChatGetUnseenCount(JNIEnv *env, jclass c, jlong hChat)
|
||||
{
|
||||
return mrchat_get_unseen_count((mrchat_t*)hChat);
|
||||
return mrchat_get_fresh_msg_count(get_mrchat_t(env, cls));
|
||||
}
|
||||
|
||||
|
||||
@@ -773,9 +812,9 @@ JNIEXPORT jintArray Java_com_b44t_messenger_MrMailbox_searchMsgs(JNIEnv *env, jc
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jintArray Java_com_b44t_messenger_MrMailbox_getUnseenMsgs(JNIEnv *env, jclass cls)
|
||||
JNIEXPORT jintArray Java_com_b44t_messenger_MrMailbox_getFreshMsgs(JNIEnv *env, jclass cls)
|
||||
{
|
||||
carray* ca = mrmailbox_get_unseen_msgs(get_mrmailbox_t(env, cls));
|
||||
carray* ca = mrmailbox_get_fresh_msgs(get_mrmailbox_t(env, cls));
|
||||
return carray2jintArray_n_carray_free(env, ca);
|
||||
}
|
||||
|
||||
@@ -871,10 +910,13 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMsg_MrMsgGetToId(JNIEnv *env, jclass c,
|
||||
JNIEXPORT jstring Java_com_b44t_messenger_MrMsg_getParam(JNIEnv *env, jobject obj, jint key, jstring def)
|
||||
{
|
||||
mrmsg_t* ths = get_mrmsg_t(env, obj);
|
||||
jstring ret = NULL;
|
||||
CHAR_REF(def);
|
||||
char* temp = mrparam_get(ths? ths->m_param:NULL, key, defPtr);
|
||||
jstring ret = JSTRING_NEW(temp);
|
||||
free(temp);
|
||||
if( temp ) {
|
||||
ret = JSTRING_NEW(temp);
|
||||
free(temp);
|
||||
}
|
||||
CHAR_UNREF(def);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -105,15 +105,8 @@
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<!-- if used, add 'android:manageSpaceActivity="com.b44t.ui.ManageSpaceActivity"' to application-tag
|
||||
<activity
|
||||
android:name="com.b44t.ui.ManageSpaceActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustPan">
|
||||
</activity> -->
|
||||
<activity
|
||||
android:name="com.b44t.ui.IntroActivity"
|
||||
android:name="com.b44t.ui.WelcomeActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
<activity
|
||||
|
||||
@@ -51,6 +51,7 @@ import android.support.v4.content.FileProvider;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.StateSet;
|
||||
@@ -98,7 +99,6 @@ public class AndroidUtilities {
|
||||
public static DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
public static int leftBaseline;
|
||||
public static boolean usingHardwareInput;
|
||||
private static Boolean isTablet = null;
|
||||
private static int adjustOwnerClassGuid = 0;
|
||||
|
||||
static {
|
||||
@@ -121,12 +121,12 @@ public class AndroidUtilities {
|
||||
|
||||
static {
|
||||
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
|
||||
leftBaseline = isTablet() ? 80 : 72;
|
||||
leftBaseline = 72;
|
||||
checkDisplaySize();
|
||||
}
|
||||
|
||||
public static void requestAdjustResize(Activity activity, int classGuid) {
|
||||
if (activity == null || isTablet()) {
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
@@ -134,7 +134,7 @@ public class AndroidUtilities {
|
||||
}
|
||||
|
||||
public static void removeAdjustResize(Activity activity, int classGuid) {
|
||||
if (activity == null || isTablet()) {
|
||||
if (activity == null ) {
|
||||
return;
|
||||
}
|
||||
if (adjustOwnerClassGuid == classGuid) {
|
||||
@@ -330,43 +330,6 @@ public class AndroidUtilities {
|
||||
ApplicationLoader.applicationHandler.removeCallbacks(runnable);
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
/* -- we do not make any special for tablet or not. _If_ sth. like this is desired, check for an appropriate screen size.
|
||||
if (isTablet == null) {
|
||||
isTablet = ApplicationLoader.applicationContext.getResources().getBoolean(R.bool.isTablet);
|
||||
}
|
||||
return isTablet;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSmallTablet() {
|
||||
/*
|
||||
float minSide = Math.min(displaySize.x, displaySize.y) / density;
|
||||
return minSide <= 700;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getMinTabletSide() {
|
||||
if (!isSmallTablet()) {
|
||||
int smallSide = Math.min(displaySize.x, displaySize.y);
|
||||
int leftSide = smallSide * 35 / 100;
|
||||
if (leftSide < dp(320)) {
|
||||
leftSide = dp(320);
|
||||
}
|
||||
return smallSide - leftSide;
|
||||
} else {
|
||||
int smallSide = Math.min(displaySize.x, displaySize.y);
|
||||
int maxSide = Math.max(displaySize.x, displaySize.y);
|
||||
int leftSide = maxSide * 35 / 100;
|
||||
if (leftSide < dp(320)) {
|
||||
leftSide = dp(320);
|
||||
}
|
||||
return Math.min(smallSide, maxSide - leftSide);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPhotoSize() {
|
||||
if (photoSize == null) {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
@@ -378,19 +341,6 @@ public class AndroidUtilities {
|
||||
return photoSize;
|
||||
}
|
||||
|
||||
public static void clearCursorDrawable(EditText editText) {
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
||||
mCursorDrawableRes.setAccessible(true);
|
||||
mCursorDrawableRes.setInt(editText, 0);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static Intent createShortcutIntent(int did, Bitmap bitmap) {
|
||||
Intent shortcutIntent = new Intent(ApplicationLoader.applicationContext, OpenChatReceiver.class);
|
||||
|
||||
@@ -509,59 +459,67 @@ public class AndroidUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int FLAG_TAG_BR = 1;
|
||||
public static final int FLAG_TAG_BOLD = 2;
|
||||
public static final int FLAG_TAG_COLOR = 4;
|
||||
public static final int FLAG_TAG_ALL = FLAG_TAG_BR | FLAG_TAG_BOLD | FLAG_TAG_COLOR;
|
||||
|
||||
public static SpannableStringBuilder replaceTags(String str) {
|
||||
return replaceTags(str, FLAG_TAG_ALL);
|
||||
}
|
||||
|
||||
public static SpannableStringBuilder replaceTags(String str, int flag) {
|
||||
try {
|
||||
int start;
|
||||
int end;
|
||||
StringBuilder stringBuilder = new StringBuilder(str);
|
||||
if ((flag & FLAG_TAG_BR) != 0) {
|
||||
while ((start = stringBuilder.indexOf("<br>")) != -1) {
|
||||
stringBuilder.replace(start, start + 4, "\n");
|
||||
}
|
||||
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
|
||||
stringBuilder.replace(start, start + 5, "\n");
|
||||
}
|
||||
|
||||
// breaks
|
||||
while ((start = stringBuilder.indexOf("<br>")) != -1) {
|
||||
stringBuilder.replace(start, start + 4, "\n");
|
||||
}
|
||||
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
|
||||
stringBuilder.replace(start, start + 5, "\n");
|
||||
}
|
||||
|
||||
// bold
|
||||
ArrayList<Integer> bolds = new ArrayList<>();
|
||||
if ((flag & FLAG_TAG_BOLD) != 0) {
|
||||
while ((start = stringBuilder.indexOf("<b>")) != -1) {
|
||||
stringBuilder.replace(start, start + 3, "");
|
||||
end = stringBuilder.indexOf("</b>");
|
||||
if (end == -1) {
|
||||
end = stringBuilder.indexOf("<b>");
|
||||
}
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
bolds.add(start);
|
||||
bolds.add(end);
|
||||
while ((start = stringBuilder.indexOf("<b>")) != -1) {
|
||||
stringBuilder.replace(start, start + 3, "");
|
||||
end = stringBuilder.indexOf("</b>");
|
||||
if (end == -1) {
|
||||
end = stringBuilder.indexOf("<b>");
|
||||
}
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
bolds.add(start);
|
||||
bolds.add(end);
|
||||
}
|
||||
|
||||
// italics
|
||||
ArrayList<Integer> italics = new ArrayList<>();
|
||||
while ((start = stringBuilder.indexOf("<i>")) != -1) {
|
||||
stringBuilder.replace(start, start + 3, "");
|
||||
end = stringBuilder.indexOf("</i>");
|
||||
if (end == -1) {
|
||||
end = stringBuilder.indexOf("<i>");
|
||||
}
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
italics.add(start);
|
||||
italics.add(end);
|
||||
}
|
||||
|
||||
// color - used eg. by the message preview when following a mailto:-link
|
||||
ArrayList<Integer> colors = new ArrayList<>();
|
||||
if ((flag & FLAG_TAG_COLOR) != 0) { // used eg. by the message preview when following a mailto:-link
|
||||
while ((start = stringBuilder.indexOf("<c#")) != -1) {
|
||||
stringBuilder.replace(start, start + 2, "");
|
||||
end = stringBuilder.indexOf(">", start);
|
||||
int color = Color.parseColor(stringBuilder.substring(start, end));
|
||||
stringBuilder.replace(start, end + 1, "");
|
||||
end = stringBuilder.indexOf("</c>");
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
colors.add(start);
|
||||
colors.add(end);
|
||||
colors.add(color);
|
||||
}
|
||||
while ((start = stringBuilder.indexOf("<c#")) != -1) {
|
||||
stringBuilder.replace(start, start + 2, "");
|
||||
end = stringBuilder.indexOf(">", start);
|
||||
int color = Color.parseColor(stringBuilder.substring(start, end));
|
||||
stringBuilder.replace(start, end + 1, "");
|
||||
end = stringBuilder.indexOf("</c>");
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
colors.add(start);
|
||||
colors.add(end);
|
||||
colors.add(color);
|
||||
}
|
||||
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
|
||||
for (int a = 0; a < bolds.size() / 2; a++) {
|
||||
spannableStringBuilder.setSpan(new TypefaceSpan(Typeface.DEFAULT_BOLD), bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
for (int a = 0; a < italics.size() / 2; a++) {
|
||||
spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italics.get(a * 2), italics.get(a * 2 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
for (int a = 0; a < colors.size() / 3; a++) {
|
||||
spannableStringBuilder.setSpan(new ForegroundColorSpan(colors.get(a * 3 + 2)), colors.get(a * 3), colors.get(a * 3 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ApplicationLoader extends Application {
|
||||
}
|
||||
|
||||
public static int getServiceMessageColor() {
|
||||
return 0x44000000; // this color is used as a background for date headlines, empty chat hints and in the drawer
|
||||
return 0x44000000; // this color is used as a background for date headlines and empty chat hints
|
||||
}
|
||||
|
||||
public static void loadWallpaper() {
|
||||
@@ -182,7 +182,7 @@ public class ApplicationLoader extends Application {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// track screen on/ff
|
||||
// track screen on/off
|
||||
try {
|
||||
final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
|
||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
@@ -227,6 +227,7 @@ public class ApplicationLoader extends Application {
|
||||
|
||||
ImageLoader.getInstance();
|
||||
MediaController.getInstance();
|
||||
NotificationsController.getInstance(); // force instace creation which also does some init stuff
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AutoMessageHeardReceiver extends BroadcastReceiver {
|
||||
if (dialog_id == 0 || max_id == 0) {
|
||||
return;
|
||||
}
|
||||
MrMailbox.markseenChat((int)dialog_id);
|
||||
MrMailbox.marknoticedChat((int)dialog_id);
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AutoMessageReplyReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
SendMessagesHelper.getInstance().sendMessageText(text.toString(), dialog_id, null);
|
||||
MrMailbox.markseenChat((int)dialog_id);
|
||||
MrMailbox.marknoticedChat((int)dialog_id);
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,12 +167,14 @@ public class ContactsController {
|
||||
// get email/name to search avatar image for
|
||||
String tempEmail = null;
|
||||
String tempName = "";
|
||||
String tempPath = "";
|
||||
if (mrContact != null) {
|
||||
tempEmail = mrContact.getAddr();
|
||||
tempName = mrContact.getDisplayName();
|
||||
} else if (mrChat != null) {
|
||||
tempName = mrChat.getName();
|
||||
if (mrChat.getType() == MrChat.MR_CHAT_NORMAL) {
|
||||
int chatType = mrChat.getType();
|
||||
if (chatType == MrChat.MR_CHAT_NORMAL) {
|
||||
int[] contact_ids = MrMailbox.getChatContacts(mrChat.getId());
|
||||
if (contact_ids.length == 1) {
|
||||
MrContact mrc = MrMailbox.getContact(contact_ids[0]);
|
||||
@@ -180,16 +182,20 @@ public class ContactsController {
|
||||
tempName = mrc.getDisplayName();
|
||||
}
|
||||
}
|
||||
else if( chatType == MrChat.MR_CHAT_GROUP ) {
|
||||
tempPath = mrChat.getParam(MrChat.MRP_PROFILE_IMAGE, "");
|
||||
}
|
||||
}
|
||||
|
||||
setupAvatarByStrings(avtView, avtImageReceiver, avtDrawable, tempEmail, tempName);
|
||||
setupAvatarByStrings(avtView, avtImageReceiver, avtDrawable, tempEmail, tempName, tempPath);
|
||||
}
|
||||
|
||||
public static void setupAvatarByStrings(final View avtView,
|
||||
private static void setupAvatarByStrings(final View avtView,
|
||||
final ImageReceiver avtImageReceiver,
|
||||
final AvatarDrawable avtDrawable,
|
||||
String tempEmail,
|
||||
String tempName)
|
||||
String tempName,
|
||||
String tempPath)
|
||||
{
|
||||
if( tempEmail == null ) {
|
||||
tempEmail = "fallback:" + tempName;
|
||||
@@ -197,13 +203,14 @@ public class ContactsController {
|
||||
|
||||
final String email = tempEmail;
|
||||
final String fallbackName = tempName;
|
||||
final String path = tempPath;
|
||||
|
||||
// bind email+name address to view object to detect overwrites and discard loading old images (may happen on fast scrolling)
|
||||
// moreover, check if the avatar is in cache
|
||||
AvtCacheEntry cacheEntry;
|
||||
synchronized (s_sync) {
|
||||
avtImageReceiver.m_userDataUnique = email+fallbackName;
|
||||
cacheEntry = s_avtCache.get(email+fallbackName);
|
||||
avtImageReceiver.m_userDataUnique = email+fallbackName+path;
|
||||
cacheEntry = s_avtCache.get(email+fallbackName+path);
|
||||
}
|
||||
|
||||
if( cacheEntry != null )
|
||||
@@ -231,14 +238,27 @@ public class ContactsController {
|
||||
public void run() {
|
||||
// is the avatar still desired?
|
||||
synchronized (s_sync) {
|
||||
if (!avtImageReceiver.m_userDataUnique.equals(email+fallbackName)) {
|
||||
if (!avtImageReceiver.m_userDataUnique.equals(email+fallbackName+path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// try to get avatar image from the address book
|
||||
Bitmap tempBitmap = null;
|
||||
if (!email.startsWith("fallback:")) {
|
||||
|
||||
if( !path.isEmpty() ) {
|
||||
try {
|
||||
Bitmap tempBitmap2 = BitmapFactory.decodeFile(path);
|
||||
if (tempBitmap2 != null) {
|
||||
tempBitmap = createRoundBitmap(tempBitmap2);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if( tempBitmap==null && !email.startsWith("fallback:")) {
|
||||
try {
|
||||
if (s_cr == null) {
|
||||
s_cr = ApplicationLoader.applicationContext.getContentResolver();
|
||||
@@ -274,7 +294,7 @@ public class ContactsController {
|
||||
public void run() {
|
||||
// is the avatar still desired?
|
||||
synchronized (s_sync) {
|
||||
if (!avtImageReceiver.m_userDataUnique.equals(email+fallbackName)) {
|
||||
if (!avtImageReceiver.m_userDataUnique.equals(email+fallbackName+path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -288,7 +308,7 @@ public class ContactsController {
|
||||
avtView.invalidate();
|
||||
|
||||
synchronized (s_sync) {
|
||||
s_avtCache.put(email+fallbackName, new AvtCacheEntry(photoBitmap, fallbackName));
|
||||
s_avtCache.put(email+fallbackName+path, new AvtCacheEntry(photoBitmap, fallbackName));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -334,7 +354,8 @@ public class ContactsController {
|
||||
private static RectF bitmapRect;
|
||||
private static Bitmap createRoundBitmap(Bitmap bitmap) {
|
||||
try {
|
||||
Bitmap result = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
int wh = Math.min(bitmap.getWidth(), bitmap.getHeight());
|
||||
Bitmap result = Bitmap.createBitmap(wh, wh, Bitmap.Config.ARGB_8888);
|
||||
result.eraseColor(Color.TRANSPARENT);
|
||||
Canvas canvas = new Canvas(result);
|
||||
BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
|
||||
@@ -343,8 +364,8 @@ public class ContactsController {
|
||||
bitmapRect = new RectF();
|
||||
}
|
||||
roundPaint.setShader(shader);
|
||||
bitmapRect.set(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
canvas.drawRoundRect(bitmapRect, bitmap.getWidth(), bitmap.getHeight(), roundPaint);
|
||||
bitmapRect.set(0, 0, wh, wh);
|
||||
canvas.drawRoundRect(bitmapRect, wh, wh, roundPaint);
|
||||
return result;
|
||||
} catch (Throwable e) {
|
||||
;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Emoji {
|
||||
emojiFullSize = 64;
|
||||
}
|
||||
drawImgSize = AndroidUtilities.dp(20);
|
||||
bigImgSize = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 40 : 32);
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
|
||||
for (int j = 0; j < EmojiData.data.length; j++) {
|
||||
int count2 = (int) Math.ceil(EmojiData.data[j].length / (float) splitCount);
|
||||
|
||||
@@ -325,18 +325,10 @@ public class MessageObject {
|
||||
|
||||
int maxWidth;
|
||||
boolean substractAvatar = !isOut() && MrMailbox.getChat((int)messageOwner.dialog_id).getType()==MrChat.MR_CHAT_GROUP;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (substractAvatar) {
|
||||
maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122);
|
||||
} else {
|
||||
maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(80);
|
||||
}
|
||||
if (substractAvatar) {
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
|
||||
} else {
|
||||
if (substractAvatar) {
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
|
||||
} else {
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80);
|
||||
}
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80);
|
||||
}
|
||||
|
||||
StaticLayout textLayout;
|
||||
@@ -625,11 +617,7 @@ public class MessageObject {
|
||||
} else if (type == MO_TYPE13_STICKER) {
|
||||
float maxHeight = AndroidUtilities.displaySize.y * 0.4f;
|
||||
float maxWidth;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
maxWidth = AndroidUtilities.getMinTabletSide() * 0.5f;
|
||||
} else {
|
||||
maxWidth = AndroidUtilities.displaySize.x * 0.5f;
|
||||
}
|
||||
maxWidth = AndroidUtilities.displaySize.x * 0.5f;
|
||||
int photoHeight = 0;
|
||||
int photoWidth = 0;
|
||||
for (TLRPC.DocumentAttribute attribute : messageOwner.media.document.attributes) {
|
||||
@@ -655,11 +643,7 @@ public class MessageObject {
|
||||
int photoHeight;
|
||||
int photoWidth;
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
photoWidth = (int) (AndroidUtilities.getMinTabletSide() * 0.7f);
|
||||
} else {
|
||||
photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
|
||||
}
|
||||
photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
|
||||
photoHeight = photoWidth + AndroidUtilities.dp(100);
|
||||
if (photoWidth > AndroidUtilities.getPhotoSize()) {
|
||||
photoWidth = AndroidUtilities.getPhotoSize();
|
||||
@@ -726,11 +710,7 @@ public class MessageObject {
|
||||
}
|
||||
|
||||
public boolean isForwarded() {
|
||||
return isForwardedMessage(messageOwner);
|
||||
}
|
||||
|
||||
private static boolean isForwardedMessage(TLRPC.Message message) {
|
||||
return (message.flags & TLRPC.MESSAGE_FLAG_FWD) != 0;
|
||||
return (messageOwner.flags & TLRPC.MESSAGE_FLAG_FWD) != 0;
|
||||
}
|
||||
|
||||
private boolean isMediaEmpty() {
|
||||
@@ -741,13 +721,6 @@ public class MessageObject {
|
||||
return message == null || message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty;
|
||||
}
|
||||
|
||||
public String getForwardedName() {
|
||||
if (messageOwner.fwd_from != null) {
|
||||
return messageOwner.fwd_from.m_name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkMediaExistance() {
|
||||
attachPathExists = false;
|
||||
mediaExists = false;
|
||||
|
||||
@@ -35,6 +35,7 @@ public class MrChat {
|
||||
public final static int MR_CHAT_GROUP = 120;
|
||||
|
||||
public final static int MR_CHAT_ID_DEADDROP = 1;
|
||||
public final static int MR_CHAT_ID_LAST_SPECIAL = 9;
|
||||
|
||||
public MrChat(long hChat) {
|
||||
m_hChat = hChat;
|
||||
@@ -50,7 +51,9 @@ public class MrChat {
|
||||
public native String getName();
|
||||
public native String getSubtitle();
|
||||
|
||||
public static int MR_CHAT_PARAM_UNPROMOTED = 'U';
|
||||
public static int MRP_UNPROMOTED = 'U';
|
||||
public static int MRP_PROFILE_IMAGE = 'i';
|
||||
public native String getParam(int key, String def);
|
||||
public native int getParamInt(int key, int def);
|
||||
|
||||
public String getDraft() {
|
||||
@@ -68,13 +71,7 @@ public class MrChat {
|
||||
public int setDraft(String draft/*NULL=delete*/, long replyToMsgId) {
|
||||
return MrChatSetDraft(m_hChat, draft, replyToMsgId);
|
||||
}
|
||||
public int getUnseenCount() {
|
||||
return MrChatGetUnseenCount(m_hChat);
|
||||
}
|
||||
|
||||
public int getTotalMsgCount() {
|
||||
return MrChatGetTotalMsgCount(m_hChat);
|
||||
}
|
||||
public native int getFreshMsgCount();
|
||||
|
||||
public native int sendText(String text);
|
||||
|
||||
@@ -86,17 +83,11 @@ public class MrChat {
|
||||
private native static long MrChatGetDraftTimestamp (long hChat); // returns 0 for "no draft"
|
||||
private native static int MrChatGetDraftReplyToMsgId (long hChat); // returns 0 for "no draft"
|
||||
private native static int MrChatSetDraft (long hChat, String draft/*NULL=delete*/, long replyToMsgId);
|
||||
private native static int MrChatGetUnseenCount (long hChat);
|
||||
private native static int MrChatGetTotalMsgCount (long hChat);
|
||||
|
||||
|
||||
/* additional functions that are not 1:1 available in the backend
|
||||
**********************************************************************************************/
|
||||
|
||||
public int isEncrypted() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static TLRPC.Chat chatId2chat(int id)
|
||||
{
|
||||
TLRPC.Chat ret = new TLRPC.Chat();
|
||||
|
||||
@@ -32,8 +32,6 @@ import android.app.Activity;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.util.Log;
|
||||
|
||||
import com.b44t.ui.Components.ForegroundDetector;
|
||||
@@ -72,10 +70,13 @@ public class MrMailbox {
|
||||
public native static String getInfo();
|
||||
public native static String cmdline(String cmd);
|
||||
|
||||
public final static int MR_IMEX_SELF_KEYS = 0x01;
|
||||
public final static int MR_EXPORT_BACKUP = 0x02;
|
||||
public native static int importStuff(int what, String dir);
|
||||
public native static void exportStuff(int what, String dir);
|
||||
public final static int MR_IMEX_EXPORT_SELF_KEYS = 1;
|
||||
public final static int MR_IMEX_IMPORT_SELF_KEYS = 2;
|
||||
public final static int MR_IMEX_EXPORT_BACKUP = 11;
|
||||
public final static int MR_IMEX_IMPORT_BACKUP = 12;
|
||||
public native static void imex(int what, String dir);
|
||||
public native static String imexHasBackup(String dir);
|
||||
public native static int checkPassword(String pw);
|
||||
|
||||
public native static void heartbeat();
|
||||
|
||||
@@ -125,8 +126,8 @@ public class MrMailbox {
|
||||
return new MrChat(MrMailboxGetChat(m_hMailbox, chat_id));
|
||||
}
|
||||
|
||||
public native static int markseenMsg (int msg_id);
|
||||
public native static int markseenChat (int chat_id);
|
||||
public native static int markseenMsgs (int msg_ids[]);
|
||||
public native static int marknoticedChat (int chat_id);
|
||||
|
||||
public native static int getChatIdByContactId (int contact_id);
|
||||
public native static int createChatByContactId(int contact_id); // returns chat_id
|
||||
@@ -136,13 +137,14 @@ public class MrMailbox {
|
||||
public native static int addContactToChat (int chat_id, int contact_id);
|
||||
public native static int removeContactFromChat (int chat_id, int contact_id);
|
||||
public native static int setChatName (int chat_id, String name);
|
||||
public native static int setChatImage (int chat_id, String name);
|
||||
|
||||
public final static int MR_GCM_ADDDAYMARKER = 0x01;
|
||||
public native static int[] getChatMsgs(int chat_id, int flags, int marker1before);
|
||||
|
||||
public native static int[] searchMsgs(int chat_id, String query);
|
||||
|
||||
public native static int[] getUnseenMsgs();
|
||||
public native static int[] getFreshMsgs();
|
||||
|
||||
public native static int[] getChatMedia(int chat_id, int msg_type, int or_msg_type);
|
||||
public native static int getNextMedia(int msg_id, int dir);
|
||||
@@ -192,7 +194,9 @@ public class MrMailbox {
|
||||
public final static int MR_EVENT_CONFIGURE_ENDED = 2040;
|
||||
public final static int MR_EVENT_CONFIGURE_PROGRESS = 2041;
|
||||
|
||||
public final static int MR_EVENT_EXPORT_FILE_WRITTEN = 2052;
|
||||
public final static int MR_EVENT_IMEX_ENDED = 2050;
|
||||
public final static int MR_EVENT_IMEX_PROGRESS = 2051;
|
||||
public final static int MR_EVENT_IMEX_FILE_WRITTEN = 2052;
|
||||
|
||||
public final static int MR_EVENT_IS_ONLINE = 2080;
|
||||
public final static int MR_EVENT_GET_STRING = 2091;
|
||||
@@ -227,15 +231,30 @@ public class MrMailbox {
|
||||
});
|
||||
return 0;
|
||||
|
||||
case MR_EVENT_EXPORT_FILE_WRITTEN: {
|
||||
final String file_name = CPtr2String(data1);
|
||||
final String file_mime = CPtr2String(data2);
|
||||
case MR_EVENT_IMEX_ENDED:
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
File file = new File(file_name);
|
||||
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
downloadManager.addCompletedDownload(file.getName(), file.getName(), true, file_mime, file.getAbsolutePath(), file.length(), true);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.imexEnded, (int)data1);
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
|
||||
case MR_EVENT_IMEX_PROGRESS:
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.imexProgress, (int)data1);
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
|
||||
case MR_EVENT_IMEX_FILE_WRITTEN: {
|
||||
final String fileName = CPtr2String(data1);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.imexFileWritten, fileName);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -360,6 +379,9 @@ public class MrMailbox {
|
||||
case 28: s = ApplicationLoader.applicationContext.getString(R.string.EncrinfoNone); break;
|
||||
case 29: s = "<c#808080>"+ApplicationLoader.applicationContext.getString(R.string.EncrinfoNoE2EExplain)+"</c>"; break;
|
||||
case 30: s = ApplicationLoader.applicationContext.getString(R.string.EncrinfoFingerprints); break;
|
||||
case 31: s = ApplicationLoader.applicationContext.getString(R.string.ReadReceipt); break;
|
||||
case 32: s = ApplicationLoader.applicationContext.getString(R.string.ReadReceiptMailBody); break;
|
||||
case 33: s = ApplicationLoader.applicationContext.getString(R.string.MsgGroupImageDeleted); break;
|
||||
}
|
||||
return String2CPtr(s);
|
||||
|
||||
@@ -403,7 +425,7 @@ public class MrMailbox {
|
||||
}
|
||||
else {
|
||||
if( !ApplicationLoader.wakeupWakeLock.isHeld()) {
|
||||
ApplicationLoader.wakeupWakeLock.acquire(1 * 1000); /* make sure, subsequent release/acquires do not make the CPU sleep */
|
||||
ApplicationLoader.wakeupWakeLock.acquire(500); /* make sure, subsequent release/acquires do not make the CPU sleep */
|
||||
}
|
||||
ApplicationLoader.backendWakeLock.release();
|
||||
}
|
||||
|
||||
@@ -48,13 +48,12 @@ public class MrMsg {
|
||||
public final static int MR_MSG_FILE = 60;
|
||||
|
||||
public final static int MR_STATE_UNDEFINED = 0;
|
||||
public final static int MR_IN_UNREAD = 10;
|
||||
public final static int MR_IN_READ = 16;
|
||||
public final static int MR_IN_FRESH = 10;
|
||||
public final static int MR_IN_NOTICED = 13;
|
||||
public final static int MR_OUT_PENDING = 20;
|
||||
public final static int MR_OUT_SENDING = 22;
|
||||
public final static int MR_OUT_ERROR = 24;
|
||||
public final static int MR_OUT_DELIVERED = 26;
|
||||
public final static int MR_OUT_READ = 28;
|
||||
public final static int MR_OUT_MDN_RCVD = 28;
|
||||
|
||||
public final static int MR_MSG_ID_MARKER1 = 1;
|
||||
public final static int MR_MSG_ID_DAYMARKER = 9;
|
||||
@@ -138,7 +137,7 @@ public class MrMsg {
|
||||
case MR_OUT_DELIVERED: ret.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; break;
|
||||
case MR_OUT_ERROR: ret.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR; break;
|
||||
case MR_OUT_PENDING: ret.send_state = MessageObject.MESSAGE_SEND_STATE_SENDING; break;
|
||||
case MR_OUT_READ: ret.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; break;
|
||||
case MR_OUT_MDN_RCVD: ret.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; break;
|
||||
}
|
||||
|
||||
ret.id = getId();
|
||||
@@ -147,11 +146,12 @@ public class MrMsg {
|
||||
ret.to_id.user_id = getToId();
|
||||
ret.date = (int)getTimestamp();
|
||||
ret.dialog_id = getChatId();
|
||||
ret.unread = state!=MR_OUT_READ; // the state of outgoing messages
|
||||
ret.unread = state!=MR_OUT_MDN_RCVD; // the state of outgoing messages
|
||||
ret.media_unread = ret.unread;
|
||||
ret.flags = 0; // posible flags: MESSAGE_FLAG_HAS_FROM_ID, however, this seems to be read only
|
||||
ret.out = ret.from_id==MrContact.MR_CONTACT_ID_SELF; // true=outgoing message, read eg. in MessageObject.isOutOwner()
|
||||
ret.created_by_mr = true;
|
||||
ret.e2ee = getParamInt('c', 0)!=0;
|
||||
|
||||
if( type == MR_MSG_TEXT ) {
|
||||
ret.message = getText();
|
||||
@@ -272,11 +272,6 @@ public class MrMsg {
|
||||
|
||||
if( !getParam('a', "").equals("") ) {
|
||||
ret.flags |= TLRPC.MESSAGE_FLAG_FWD;
|
||||
ret.fwd_from = new TLRPC.TL_messageFwdHeader();
|
||||
ret.fwd_from.m_name = getParam('A', "");
|
||||
if( ret.fwd_from.m_name.isEmpty() ) {
|
||||
ret.fwd_from.m_name = getParam('a', "");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -33,6 +33,9 @@ public class NotificationCenter {
|
||||
|
||||
public static final int configureEnded = totalEvents++;
|
||||
public static final int configureProgress = totalEvents++;
|
||||
public static final int imexEnded = totalEvents++;
|
||||
public static final int imexProgress = totalEvents++;
|
||||
public static final int imexFileWritten = totalEvents++;
|
||||
public static final int didReceivedNewMessages = totalEvents++;
|
||||
public static final int updateInterfaces = totalEvents++;
|
||||
public static final int dialogsNeedReload = totalEvents++;
|
||||
@@ -46,7 +49,6 @@ public class NotificationCenter {
|
||||
public static final int mediaCountDidLoaded = totalEvents++;
|
||||
public static final int notificationsSettingsUpdated = totalEvents++;
|
||||
public static final int blockedUsersDidLoaded = totalEvents++;
|
||||
public static final int openedChatChanged = totalEvents++;
|
||||
public static final int mainUserInfoChanged = totalEvents++;
|
||||
public static final int recentImagesDidLoaded = totalEvents++;
|
||||
public static final int waveformCalculated = totalEvents++;
|
||||
@@ -130,12 +132,6 @@ public class NotificationCenter {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isAnimationInProgress() {
|
||||
return animationInProgress;
|
||||
}
|
||||
|
||||
|
||||
public void postNotificationName(int id, Object... args) {
|
||||
boolean allowDuringAnimation = false;
|
||||
if (allowedNotifications != null) {
|
||||
|
||||
@@ -148,6 +148,8 @@ public class NotificationsController {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setBadge(0); // the set badge number survives application restarts, so reset it when creating
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -502,7 +504,7 @@ public class NotificationsController {
|
||||
}
|
||||
|
||||
// get all unread messages as a hash
|
||||
int unseenArr[] = MrMailbox.getUnseenMsgs();
|
||||
int unseenArr[] = MrMailbox.getFreshMsgs();
|
||||
int unseenCnt = unseenArr.length;
|
||||
HashMap<Integer, Boolean> unseenHash = new HashMap<>();
|
||||
for( int i = 0; i < unseenCnt; i++ ) {
|
||||
|
||||
@@ -108,8 +108,6 @@ public class TLRPC {
|
||||
|
||||
public static class User extends TLObject {
|
||||
public int id;
|
||||
public String first_name;
|
||||
public String last_name;
|
||||
public String username;
|
||||
public UserProfilePhoto photo;
|
||||
public int flags;
|
||||
@@ -150,7 +148,6 @@ public class TLRPC {
|
||||
|
||||
public static class InputStickerSet extends TLObject {
|
||||
public long id;
|
||||
public String short_name;
|
||||
}
|
||||
|
||||
public static class TL_inputStickerSetEmpty extends InputStickerSet {
|
||||
@@ -200,10 +197,6 @@ public class TLRPC {
|
||||
public int hash;
|
||||
}
|
||||
|
||||
public static class TL_messageFwdHeader extends TLObject {
|
||||
public String m_name;
|
||||
}
|
||||
|
||||
public static class FileLocation extends TLObject {
|
||||
public int dc_id;
|
||||
public long volume_id;
|
||||
@@ -284,13 +277,13 @@ public class TLRPC {
|
||||
public final int views = 0;
|
||||
public final boolean silent = false;
|
||||
public final boolean post = false;// ? true=avatar wird in gruppen nicht angezeigt, wird aber in isFromUser() auch überprüft...
|
||||
public TL_messageFwdHeader fwd_from;
|
||||
public int send_state = 0; //custom
|
||||
public String attachPath = ""; //custom
|
||||
public HashMap<String, String> params; //custom
|
||||
public long dialog_id; //custom
|
||||
public final int layer = 0; //custom
|
||||
public boolean created_by_mr;
|
||||
public boolean e2ee;
|
||||
}
|
||||
|
||||
public static class TL_message extends Message {
|
||||
|
||||
@@ -35,19 +35,24 @@ import android.util.Log;
|
||||
public class TimerReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
// acquire for 3 seconds, this should wake up the threads,
|
||||
// _if_ there is more to do, the backend acquires an additional wakelock using MR_EVENT_WAKE_LOCK
|
||||
ApplicationLoader.wakeupWakeLock.acquire(3*1000); // do this first!
|
||||
MrMailbox.log_i("DeltaChat", "*** TimerReceiver.onReceive()");
|
||||
// for a discussion about the different approaches to save batter, see https://github.com/deltachat/deltachat-android/issues/104#issuecomment-331670326
|
||||
|
||||
// we assume, the IMAP thread is alive. I cannot imagine, the thread was killed with the App being running.
|
||||
// (if the whole App was killed, the IMAP thread is already started by MrMailbox.connect() if we're here)
|
||||
// (the thread itself will reconnect to the IMAP server as needed)
|
||||
// however, it seems as if the threads sleep longer than ususal, check this by calling heartbeat() manually
|
||||
MrMailbox.heartbeat();
|
||||
try {
|
||||
ApplicationLoader.wakeupWakeLock.acquire(); // do this first!
|
||||
MrMailbox.log_i("DeltaChat", "*** TimerReceiver.onReceive()");
|
||||
|
||||
// create the next alarm in about a minute
|
||||
scheduleNextAlarm();
|
||||
// we assume, the IMAP thread is alive. I cannot imagine, the thread was killed with the App being running.
|
||||
// (if the whole App was killed, the IMAP thread is already started by MrMailbox.connect() if we're here)
|
||||
// (the thread itself will reconnect to the IMAP server as needed)
|
||||
// however, it seems as if the threads sleep longer than ususal, check this by calling heartbeat() manually
|
||||
MrMailbox.heartbeat();
|
||||
|
||||
// create the next alarm in about a minute
|
||||
scheduleNextAlarm();
|
||||
} finally {
|
||||
// Always release the wakelock, _if_ there is more to do, the backend acquires an additional wakelock using MR_EVENT_WAKE_LOCK
|
||||
ApplicationLoader.wakeupWakeLock.release();
|
||||
}
|
||||
}
|
||||
|
||||
public static void scheduleNextAlarm()
|
||||
|
||||
@@ -49,7 +49,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
SendMessagesHelper.getInstance().sendMessageText(text.toString(), dialog_id, null);
|
||||
MrMailbox.markseenChat((int)dialog_id);
|
||||
MrMailbox.marknoticedChat((int)dialog_id);
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,12 +378,6 @@ public class ActionBar extends FrameLayout {
|
||||
if (subtitleTextView != null) {
|
||||
subtitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
|
||||
}
|
||||
if( backButtonImageView != null ) {
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable != null && drawable instanceof MenuDrawable) {
|
||||
((MenuDrawable) drawable).setRotation(visible ? 1 : 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setInterceptTouches(boolean value) {
|
||||
@@ -435,12 +429,11 @@ public class ActionBar extends FrameLayout {
|
||||
int availableWidth = width - (menu != null ? menu.getMeasuredWidth() : 0) - AndroidUtilities.dp(16) - textLeft;
|
||||
|
||||
if (titleTextView != null && titleTextView.getVisibility() != GONE) {
|
||||
titleTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20);
|
||||
titleTextView.setTextSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20);
|
||||
titleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.AT_MOST));
|
||||
|
||||
}
|
||||
if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) {
|
||||
//subtitleTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 14 : 16);
|
||||
subtitleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.AT_MOST));
|
||||
}
|
||||
}
|
||||
@@ -475,14 +468,14 @@ public class ActionBar extends FrameLayout {
|
||||
if (titleTextView != null && titleTextView.getVisibility() != GONE) {
|
||||
int textTop;
|
||||
if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) {
|
||||
textTop = (getCurrentActionBarHeight() / 2 - titleTextView.getTextHeight()) / 2 + AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 3);
|
||||
textTop = (getCurrentActionBarHeight() / 2 - titleTextView.getTextHeight()) / 2 + AndroidUtilities.dp(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 3);
|
||||
} else {
|
||||
textTop = (getCurrentActionBarHeight() - titleTextView.getTextHeight()) / 2;
|
||||
}
|
||||
titleTextView.layout(textLeft, additionalTop + textTop, textLeft + titleTextView.getMeasuredWidth(), additionalTop + textTop + titleTextView.getTextHeight());
|
||||
}
|
||||
if (subtitleTextView != null && subtitleTextView.getVisibility() != GONE) {
|
||||
int textTop = getCurrentActionBarHeight() / 2 + (getCurrentActionBarHeight() / 2 - subtitleTextView.getTextHeight()) / 2 - AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 1);
|
||||
int textTop = getCurrentActionBarHeight() / 2 + (getCurrentActionBarHeight() / 2 - subtitleTextView.getTextHeight()) / 2 - AndroidUtilities.dp(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 1);
|
||||
subtitleTextView.layout(textLeft, additionalTop + textTop, textLeft + subtitleTextView.getMeasuredWidth(), additionalTop + textTop + subtitleTextView.getTextHeight());
|
||||
}
|
||||
|
||||
@@ -553,22 +546,6 @@ public class ActionBar extends FrameLayout {
|
||||
allowOverlayTitle = value;
|
||||
}
|
||||
|
||||
public void setTitleOverlayText(String text) {
|
||||
/* EDIT BY MR
|
||||
if (!allowOverlayTitle || parentFragment.parentLayout == null) {
|
||||
return;
|
||||
}
|
||||
CharSequence textToSet = text != null ? text : lastTitle;
|
||||
if (textToSet != null && titleTextView == null) {
|
||||
createTitleTextView();
|
||||
}
|
||||
if (titleTextView != null) {
|
||||
titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
|
||||
titleTextView.setText(textToSet);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isSearchFieldVisible() {
|
||||
return isSearchFieldVisible;
|
||||
}
|
||||
@@ -605,9 +582,7 @@ public class ActionBar extends FrameLayout {
|
||||
}
|
||||
|
||||
public static int getCurrentActionBarHeight() {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
return AndroidUtilities.dp(64);
|
||||
} else if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
return AndroidUtilities.dp(48);
|
||||
} else {
|
||||
return AndroidUtilities.dp(56);
|
||||
|
||||
@@ -60,7 +60,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout);
|
||||
boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout);
|
||||
boolean needCloseLastFragment(ActionBarLayout layout);
|
||||
void onRebuildAllFragments(ActionBarLayout layout);
|
||||
}
|
||||
|
||||
public class LinearLayoutContainer extends LinearLayout {
|
||||
@@ -131,7 +130,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
|
||||
private LinearLayoutContainer containerView;
|
||||
private LinearLayoutContainer containerViewBack;
|
||||
private DrawerLayoutContainer drawerLayoutContainer;
|
||||
private ActionBar currentActionBar;
|
||||
|
||||
private AnimatorSet currentAnimation;
|
||||
@@ -153,16 +151,12 @@ public class ActionBarLayout extends FrameLayout {
|
||||
private int startedTrackingPointerId;
|
||||
private Runnable onCloseAnimationEndRunnable;
|
||||
private Runnable onOpenAnimationEndRunnable;
|
||||
private boolean useAlphaAnimations;
|
||||
private View backgroundView;
|
||||
private boolean removeActionBarExtraHeight;
|
||||
private Runnable animationRunnable;
|
||||
|
||||
private float animationProgress = 0.0f;
|
||||
private long lastFrameTime;
|
||||
|
||||
private String titleOverlayText;
|
||||
|
||||
private ActionBarLayoutDelegate delegate = null;
|
||||
protected Activity parentActivity = null;
|
||||
|
||||
@@ -385,7 +379,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
lastFragment.actionBar.setOccupyStatusBar(false);
|
||||
}
|
||||
containerViewBack.addView(lastFragment.actionBar);
|
||||
lastFragment.actionBar.setTitleOverlayText(titleOverlayText);
|
||||
}
|
||||
containerViewBack.addView(fragmentView);
|
||||
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||
@@ -678,7 +671,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
parent.removeView(fragment.actionBar);
|
||||
}
|
||||
containerViewBack.addView(fragment.actionBar);
|
||||
fragment.actionBar.setTitleOverlayText(titleOverlayText);
|
||||
}
|
||||
|
||||
containerViewBack.addView(fragmentView);
|
||||
@@ -702,110 +694,56 @@ public class ActionBarLayout extends FrameLayout {
|
||||
bringChildToFront(containerView);
|
||||
if (!needAnimation) {
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (needAnimation) {
|
||||
if (useAlphaAnimations && fragmentsStack.size() == 1) {
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
transitionAnimationInProgress = true;
|
||||
onOpenAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fragment.onTransitionAnimationEnd(true, false);
|
||||
fragment.onBecomeFullyVisible();
|
||||
}
|
||||
};
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(this, "alpha", 0.0f, 1.0f));
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(VISIBLE);
|
||||
animators.add(ObjectAnimator.ofFloat(backgroundView, "alpha", 0.0f, 1.0f));
|
||||
}
|
||||
|
||||
fragment.onTransitionAnimationStart(true, false);
|
||||
currentAnimation = new AnimatorSet();
|
||||
currentAnimation.playTogether(animators);
|
||||
currentAnimation.setInterpolator(accelerateDecelerateInterpolator);
|
||||
currentAnimation.setDuration(200);
|
||||
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onAnimationEndCheck(false);
|
||||
}
|
||||
});
|
||||
currentAnimation.start();
|
||||
} else {
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
transitionAnimationInProgress = true;
|
||||
onOpenAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
containerView.setLayerType(LAYER_TYPE_NONE, null);
|
||||
containerViewBack.setLayerType(LAYER_TYPE_NONE, null);
|
||||
}
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
fragment.onTransitionAnimationEnd(true, false);
|
||||
fragment.onBecomeFullyVisible();
|
||||
containerView.setTranslationX(0);
|
||||
}
|
||||
};
|
||||
fragment.onTransitionAnimationStart(true, false);
|
||||
AnimatorSet animation = fragment.onCustomTransitionAnimation(true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onAnimationEndCheck(false);
|
||||
}
|
||||
});
|
||||
if (animation == null) {
|
||||
containerView.setAlpha(0.0f);
|
||||
containerView.setTranslationX(48.0f);
|
||||
if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) {
|
||||
waitingForKeyboardCloseRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (waitingForKeyboardCloseRunnable != this) {
|
||||
return;
|
||||
}
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(waitingForKeyboardCloseRunnable, 200);
|
||||
} else if (fragment.needDelayOpenAnimation()) {
|
||||
delayedOpenAnimationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (delayedOpenAnimationRunnable != this) {
|
||||
return;
|
||||
}
|
||||
delayedOpenAnimationRunnable = null;
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(delayedOpenAnimationRunnable, 200);
|
||||
} else {
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
} else {
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
transitionAnimationInProgress = true;
|
||||
onOpenAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
//containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
//containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
containerView.setLayerType(LAYER_TYPE_NONE, null);
|
||||
containerViewBack.setLayerType(LAYER_TYPE_NONE, null);
|
||||
}
|
||||
containerView.setAlpha(1.0f);
|
||||
containerView.setTranslationX(0.0f);
|
||||
currentAnimation = animation;
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
fragment.onTransitionAnimationEnd(true, false);
|
||||
fragment.onBecomeFullyVisible();
|
||||
containerView.setTranslationX(0);
|
||||
}
|
||||
};
|
||||
fragment.onTransitionAnimationStart(true, false);
|
||||
{
|
||||
containerView.setAlpha(0.0f);
|
||||
containerView.setTranslationX(48.0f);
|
||||
if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) {
|
||||
waitingForKeyboardCloseRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (waitingForKeyboardCloseRunnable != this) {
|
||||
return;
|
||||
}
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(waitingForKeyboardCloseRunnable, 200);
|
||||
} else if (fragment.needDelayOpenAnimation()) {
|
||||
delayedOpenAnimationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (delayedOpenAnimationRunnable != this) {
|
||||
return;
|
||||
}
|
||||
delayedOpenAnimationRunnable = null;
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
};
|
||||
AndroidUtilities.runOnUIThread(delayedOpenAnimationRunnable, 200);
|
||||
} else {
|
||||
startLayoutAnimation(true, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setAlpha(1.0f);
|
||||
backgroundView.setVisibility(VISIBLE);
|
||||
}
|
||||
fragment.onTransitionAnimationStart(true, false);
|
||||
fragment.onTransitionAnimationEnd(true, false);
|
||||
fragment.onBecomeFullyVisible();
|
||||
@@ -895,7 +833,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
parent.removeView(previousFragment.actionBar);
|
||||
}
|
||||
containerView.addView(previousFragment.actionBar);
|
||||
previousFragment.actionBar.setTitleOverlayText(titleOverlayText);
|
||||
}
|
||||
containerView.addView(fragmentView);
|
||||
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||
@@ -932,13 +869,8 @@ public class ActionBarLayout extends FrameLayout {
|
||||
previousFragmentFinal.onBecomeFullyVisible();
|
||||
}
|
||||
};
|
||||
AnimatorSet animation = currentFragment.onCustomTransitionAnimation(false, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onAnimationEndCheck(false);
|
||||
}
|
||||
});
|
||||
if (animation == null) {
|
||||
|
||||
{
|
||||
if (containerView.isKeyboardVisible || containerViewBack.isKeyboardVisible) {
|
||||
waitingForKeyboardCloseRunnable = new Runnable() {
|
||||
@Override
|
||||
@@ -953,12 +885,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
} else {
|
||||
startLayoutAnimation(false, true);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
//containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
//containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
currentAnimation = animation;
|
||||
}
|
||||
} else {
|
||||
currentFragment.onTransitionAnimationEnd(false, false);
|
||||
@@ -966,53 +892,8 @@ public class ActionBarLayout extends FrameLayout {
|
||||
previousFragment.onBecomeFullyVisible();
|
||||
}
|
||||
} else {
|
||||
if (useAlphaAnimations) {
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
transitionAnimationInProgress = true;
|
||||
|
||||
onCloseAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
removeFragmentFromStackInternal(currentFragment);
|
||||
setVisibility(GONE);
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(GONE);
|
||||
}
|
||||
if (drawerLayoutContainer != null) {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(this, "alpha", 1.0f, 0.0f));
|
||||
if (backgroundView != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(backgroundView, "alpha", 1.0f, 0.0f));
|
||||
}
|
||||
|
||||
currentAnimation = new AnimatorSet();
|
||||
currentAnimation.playTogether(animators);
|
||||
currentAnimation.setInterpolator(accelerateDecelerateInterpolator);
|
||||
currentAnimation.setDuration(200);
|
||||
currentAnimation.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
onAnimationEndCheck(false);
|
||||
}
|
||||
});
|
||||
currentAnimation.start();
|
||||
} else {
|
||||
removeFragmentFromStackInternal(currentFragment);
|
||||
setVisibility(GONE);
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
removeFragmentFromStackInternal(currentFragment);
|
||||
setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1056,7 +937,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
parent.removeView(previousFragment.actionBar);
|
||||
}
|
||||
containerView.addView(previousFragment.actionBar);
|
||||
previousFragment.actionBar.setTitleOverlayText(titleOverlayText);
|
||||
}
|
||||
containerView.addView(fragmentView);
|
||||
ViewGroup.LayoutParams layoutParams = fragmentView.getLayoutParams();
|
||||
@@ -1078,11 +958,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
public void removeFragmentFromStack(BaseFragment fragment) {
|
||||
if (useAlphaAnimations && fragmentsStack.size() == 1 && AndroidUtilities.isTablet()) {
|
||||
closeLastFragment(true);
|
||||
} else {
|
||||
removeFragmentFromStackInternal(fragment);
|
||||
}
|
||||
removeFragmentFromStackInternal(fragment);
|
||||
}
|
||||
|
||||
public void removeAllFragments() {
|
||||
@@ -1092,16 +968,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuildAllFragmentViews(boolean last) {
|
||||
for (int a = 0; a < fragmentsStack.size() - (last ? 0 : 1); a++) {
|
||||
fragmentsStack.get(a).clearViews();
|
||||
fragmentsStack.get(a).setParentLayout(this);
|
||||
}
|
||||
if (delegate != null) {
|
||||
delegate.onRebuildAllFragments(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU && !checkTransitionAnimation() && !startedTracking && currentActionBar != null) {
|
||||
currentActionBar.onMenuButtonPressed();
|
||||
@@ -1184,35 +1050,10 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void setUseAlphaAnimations(boolean value) {
|
||||
useAlphaAnimations = value;
|
||||
}
|
||||
|
||||
public void setBackgroundView(View view) {
|
||||
backgroundView = view;
|
||||
}
|
||||
|
||||
public void setDrawerLayoutContainer(DrawerLayoutContainer layout) {
|
||||
drawerLayoutContainer = layout;
|
||||
}
|
||||
|
||||
public DrawerLayoutContainer getDrawerLayoutContainer() {
|
||||
return drawerLayoutContainer;
|
||||
}
|
||||
|
||||
public void setRemoveActionBarExtraHeight(boolean value) {
|
||||
removeActionBarExtraHeight = value;
|
||||
}
|
||||
|
||||
public void setTitleOverlayText(String text) {
|
||||
titleOverlayText = text;
|
||||
for (BaseFragment fragment : fragmentsStack) {
|
||||
if (fragment.actionBar != null) {
|
||||
fragment.actionBar.setTitleOverlayText(titleOverlayText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ActionBarMenu extends LinearLayout {
|
||||
case R.drawable.photo_crop: hint = ApplicationLoader.applicationContext.getString(R.string.CropImage); break;
|
||||
case R.drawable.photo_tools: hint = ApplicationLoader.applicationContext.getString(R.string.EditImage); break;
|
||||
case R.drawable.ic_ab_search: hint = ApplicationLoader.applicationContext.getString(R.string.Search); break;
|
||||
case R.drawable.lock_close: hint = ApplicationLoader.applicationContext.getString(R.string.Passcode); break;
|
||||
case R.drawable.ic_ab_lock_screen: hint = ApplicationLoader.applicationContext.getString(R.string.Passcode); break;
|
||||
}
|
||||
if( hint != null ) {
|
||||
if( s_menuItemHint != null ) {
|
||||
|
||||
@@ -466,13 +466,7 @@ public class ActionBarMenuItem extends FrameLayout {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
||||
mCursorDrawableRes.setAccessible(true);
|
||||
mCursorDrawableRes.set(searchField, R.drawable.search_carret);
|
||||
} catch (Exception e) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
searchField.setTextIsSelectable(false);
|
||||
if( applyHack ) {
|
||||
searchField.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
|
||||
@@ -286,10 +286,6 @@ public class BaseFragment {
|
||||
|
||||
}
|
||||
|
||||
protected AnimatorSet onCustomTransitionAnimation(boolean isOpen, final Runnable callback) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onLowMemory() {
|
||||
|
||||
}
|
||||
|
||||
@@ -307,11 +307,7 @@ public class BottomSheet extends Dialog {
|
||||
if (containerView != null) {
|
||||
if (!fullWidth) {
|
||||
int widthSpec;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
widthSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY);
|
||||
} else {
|
||||
widthSpec = MeasureSpec.makeMeasureSpec(isPortrait ? width + backgroundPaddingLeft * 2 : (int) Math.max(width * 0.8f, Math.min(AndroidUtilities.dp(480), width)) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY);
|
||||
}
|
||||
widthSpec = MeasureSpec.makeMeasureSpec(isPortrait ? width + backgroundPaddingLeft * 2 : (int) Math.max(width * 0.8f, Math.min(AndroidUtilities.dp(480), width)) + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY);
|
||||
containerView.measure(widthSpec, MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
} else {
|
||||
containerView.measure(MeasureSpec.makeMeasureSpec(width + backgroundPaddingLeft * 2, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
|
||||
|
||||
@@ -1,520 +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.ui.ActionBar;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.messenger.AnimatorListenerAdapterProxy;
|
||||
|
||||
public class DrawerLayoutContainer extends FrameLayout {
|
||||
|
||||
public static boolean USE_DRAWER;
|
||||
|
||||
private static final int MIN_DRAWER_MARGIN = 64;
|
||||
|
||||
private ViewGroup drawerLayout;
|
||||
private ActionBarLayout parentActionBarLayout;
|
||||
|
||||
private boolean maybeStartTracking;
|
||||
private boolean startedTracking;
|
||||
private int startedTrackingX;
|
||||
private int startedTrackingY;
|
||||
private int startedTrackingPointerId;
|
||||
private VelocityTracker velocityTracker;
|
||||
private boolean beginTrackingSent;
|
||||
private AnimatorSet currentAnimation;
|
||||
|
||||
private Paint scrimPaint = new Paint();
|
||||
|
||||
private Object lastInsets;
|
||||
private boolean inLayout;
|
||||
private int minDrawerMargin;
|
||||
private float scrimOpacity;
|
||||
private Drawable shadowLeft;
|
||||
private boolean allowOpenDrawer;
|
||||
|
||||
private float drawerPosition;
|
||||
private boolean drawerOpened;
|
||||
private boolean allowDrawContent = true;
|
||||
|
||||
public DrawerLayoutContainer(Context context) {
|
||||
super(context);
|
||||
|
||||
USE_DRAWER = MrMailbox.getConfigInt("drawer", 0)!=0;
|
||||
|
||||
minDrawerMargin = (int) (MIN_DRAWER_MARGIN * AndroidUtilities.density + 0.5f);
|
||||
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||
setFocusableInTouchMode(true);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
setFitsSystemWindows(true);
|
||||
setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
|
||||
final DrawerLayoutContainer drawerLayout = (DrawerLayoutContainer) v;
|
||||
lastInsets = insets;
|
||||
drawerLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
|
||||
drawerLayout.requestLayout();
|
||||
return insets.consumeSystemWindowInsets();
|
||||
}
|
||||
});
|
||||
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
|
||||
shadowLeft = getResources().getDrawable(R.drawable.menu_shadow);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (drawerGravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (drawerGravity == Gravity.RIGHT) {
|
||||
wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
|
||||
}
|
||||
child.dispatchApplyWindowInsets(wi);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (drawerGravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (drawerGravity == Gravity.RIGHT) {
|
||||
wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
|
||||
}
|
||||
lp.leftMargin = wi.getSystemWindowInsetLeft();
|
||||
lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
|
||||
lp.rightMargin = wi.getSystemWindowInsetRight();
|
||||
lp.bottomMargin = wi.getSystemWindowInsetBottom();
|
||||
}
|
||||
|
||||
private int getTopInset(Object insets) { /* not sure, if this or one of the other unsed methods is called indirectly somewhere; however, at the moment, I do not habe the time tp check this. */
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return insets != null ? ((WindowInsets) insets).getSystemWindowInsetTop() : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setDrawerLayout(ViewGroup layout) {
|
||||
drawerLayout = layout;
|
||||
addView(drawerLayout);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
drawerLayout.setFitsSystemWindows(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void moveDrawerByX(float dx) {
|
||||
setDrawerPosition(drawerPosition + dx);
|
||||
}
|
||||
|
||||
public void setDrawerPosition(float value) {
|
||||
drawerPosition = value;
|
||||
if (drawerPosition > drawerLayout.getMeasuredWidth()) {
|
||||
drawerPosition = drawerLayout.getMeasuredWidth();
|
||||
} else if (drawerPosition < 0) {
|
||||
drawerPosition = 0;
|
||||
}
|
||||
drawerLayout.setTranslationX(drawerPosition);
|
||||
|
||||
final int newVisibility = drawerPosition > 0 ? VISIBLE : GONE;
|
||||
if (drawerLayout.getVisibility() != newVisibility) {
|
||||
drawerLayout.setVisibility(newVisibility);
|
||||
}
|
||||
setScrimOpacity(drawerPosition / (float) drawerLayout.getMeasuredWidth());
|
||||
}
|
||||
|
||||
public float getDrawerPosition() { /* not sure, if this or one of the other unsed methods is called indirectly somewhere; however, at the moment, I do not habe the time tp check this. */
|
||||
return drawerPosition;
|
||||
}
|
||||
|
||||
public void cancelCurrentAnimation() {
|
||||
if (currentAnimation != null) {
|
||||
currentAnimation.cancel();
|
||||
currentAnimation = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void openDrawer(boolean fast) {
|
||||
if (!allowOpenDrawer) {
|
||||
return;
|
||||
}
|
||||
if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) {
|
||||
AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus());
|
||||
}
|
||||
cancelCurrentAnimation();
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth()));
|
||||
animatorSet.setInterpolator(new DecelerateInterpolator());
|
||||
if (fast) {
|
||||
animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50));
|
||||
} else {
|
||||
animatorSet.setDuration(300);
|
||||
}
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
onDrawerAnimationEnd(true);
|
||||
}
|
||||
});
|
||||
animatorSet.start();
|
||||
currentAnimation = animatorSet;
|
||||
}
|
||||
|
||||
public void closeDrawer(boolean fast) {
|
||||
cancelCurrentAnimation();
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(this, "drawerPosition", 0)
|
||||
);
|
||||
animatorSet.setInterpolator(new DecelerateInterpolator());
|
||||
if (fast) {
|
||||
animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * drawerPosition), 50));
|
||||
} else {
|
||||
animatorSet.setDuration(300);
|
||||
}
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
onDrawerAnimationEnd(false);
|
||||
}
|
||||
});
|
||||
animatorSet.start();
|
||||
}
|
||||
|
||||
private void onDrawerAnimationEnd(boolean opened) {
|
||||
startedTracking = false;
|
||||
currentAnimation = null;
|
||||
drawerOpened = opened;
|
||||
if (!opened) {
|
||||
if (drawerLayout instanceof ListView) {
|
||||
((ListView) drawerLayout).setSelectionFromTop(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrimOpacity(float value) {
|
||||
scrimOpacity = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private float getScrimOpacity() { /* not sure, if this or one of the other unsed methods is called indirectly somewhere; however, at the moment, I do not habe the time tp check this. */
|
||||
return scrimOpacity;
|
||||
}
|
||||
|
||||
public View getDrawerLayout() { /* not sure, if this or one of the other unsed methods is called indirectly somewhere; however, at the moment, I do not habe the time tp check this. */
|
||||
return drawerLayout;
|
||||
}
|
||||
|
||||
public void setParentActionBarLayout(ActionBarLayout layout) {
|
||||
parentActionBarLayout = layout;
|
||||
}
|
||||
|
||||
public void setAllowOpenDrawer(boolean value, boolean animated) {
|
||||
if( !USE_DRAWER ) {
|
||||
allowOpenDrawer = false;
|
||||
return;
|
||||
}
|
||||
|
||||
allowOpenDrawer = value;
|
||||
if (!allowOpenDrawer && drawerPosition != 0) {
|
||||
if (!animated) {
|
||||
setDrawerPosition(0);
|
||||
onDrawerAnimationEnd(false);
|
||||
} else {
|
||||
closeDrawer(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareForDrawerOpen(MotionEvent ev) {
|
||||
maybeStartTracking = false;
|
||||
startedTracking = true;
|
||||
if (ev != null) {
|
||||
startedTrackingX = (int) ev.getX();
|
||||
}
|
||||
beginTrackingSent = false;
|
||||
}
|
||||
|
||||
public boolean isDrawerOpened() {
|
||||
return drawerOpened;
|
||||
}
|
||||
|
||||
public void setAllowDrawContent(boolean value) {
|
||||
if (allowDrawContent != value) {
|
||||
allowDrawContent = value;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (!parentActionBarLayout.checkTransitionAnimation()) {
|
||||
if (drawerOpened && ev != null && ev.getX() > drawerPosition && !startedTracking) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_UP) {
|
||||
closeDrawer(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (allowOpenDrawer && parentActionBarLayout.fragmentsStack.size() == 1) {
|
||||
if (ev != null && (ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_MOVE) && !startedTracking && !maybeStartTracking) {
|
||||
startedTrackingPointerId = ev.getPointerId(0);
|
||||
maybeStartTracking = true;
|
||||
startedTrackingX = (int) ev.getX();
|
||||
startedTrackingY = (int) ev.getY();
|
||||
cancelCurrentAnimation();
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.clear();
|
||||
}
|
||||
} else if (ev != null && ev.getAction() == MotionEvent.ACTION_MOVE && ev.getPointerId(0) == startedTrackingPointerId) {
|
||||
if (velocityTracker == null) {
|
||||
velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
float dx = (int) (ev.getX() - startedTrackingX);
|
||||
float dy = Math.abs((int) ev.getY() - startedTrackingY);
|
||||
velocityTracker.addMovement(ev);
|
||||
if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.4f, true))) {
|
||||
prepareForDrawerOpen(ev);
|
||||
startedTrackingX = (int) ev.getX();
|
||||
requestDisallowInterceptTouchEvent(true);
|
||||
} else if (startedTracking) {
|
||||
if (!beginTrackingSent) {
|
||||
if (((Activity) getContext()).getCurrentFocus() != null) {
|
||||
AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
|
||||
}
|
||||
beginTrackingSent = true;
|
||||
}
|
||||
moveDrawerByX(dx);
|
||||
startedTrackingX = (int) ev.getX();
|
||||
}
|
||||
} else if (ev == null || ev != null && ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
|
||||
if (velocityTracker == null) {
|
||||
velocityTracker = VelocityTracker.obtain();
|
||||
}
|
||||
velocityTracker.computeCurrentVelocity(1000);
|
||||
/*if (!startedTracking) {
|
||||
float velX = velocityTracker.getXVelocity();
|
||||
float velY = velocityTracker.getYVelocity();
|
||||
if (Math.abs(velX) >= 3500 && Math.abs(velX) > Math.abs(velY)) {
|
||||
prepareForDrawerOpen(ev);
|
||||
if (!beginTrackingSent) {
|
||||
if (((Activity)getContext()).getCurrentFocus() != null) {
|
||||
AndroidUtilities.hideKeyboard(((Activity)getContext()).getCurrentFocus());
|
||||
}
|
||||
beginTrackingSent = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (startedTracking || drawerPosition != 0 && drawerPosition != drawerLayout.getMeasuredWidth()) {
|
||||
float velX = velocityTracker.getXVelocity();
|
||||
float velY = velocityTracker.getYVelocity();
|
||||
boolean backAnimation = drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f && (velX < 3500 || Math.abs(velX) < Math.abs(velY)) || velX < 0 && Math.abs(velX) >= 3500;
|
||||
if (!backAnimation) {
|
||||
openDrawer(!drawerOpened && Math.abs(velX) >= 3500);
|
||||
} else {
|
||||
closeDrawer(drawerOpened && Math.abs(velX) >= 3500);
|
||||
}
|
||||
startedTracking = false;
|
||||
} else {
|
||||
maybeStartTracking = false;
|
||||
startedTracking = false;
|
||||
}
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.recycle();
|
||||
velocityTracker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return startedTracking;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return parentActionBarLayout.checkTransitionAnimation() || onTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
if (maybeStartTracking && !startedTracking) {
|
||||
onTouchEvent(null);
|
||||
}
|
||||
super.requestDisallowInterceptTouchEvent(disallowIntercept);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
inLayout = true;
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
try {
|
||||
if (drawerLayout != child) {
|
||||
child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight());
|
||||
} else {
|
||||
child.layout(-child.getMeasuredWidth(), lp.topMargin, 0, lp.topMargin + child.getMeasuredHeight());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
inLayout = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLayout() {
|
||||
if (!inLayout) {
|
||||
/*StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
for (int a = 0; a < elements.length; a++) {
|
||||
Log.d("DeltaChat", "on " + elements[a]);
|
||||
}*/
|
||||
super.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
setMeasuredDimension(widthSize, heightSize);
|
||||
|
||||
final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21;
|
||||
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
if (applyInsets) {
|
||||
if (child.getFitsSystemWindows()) {
|
||||
dispatchChildInsets(child, lastInsets, lp.gravity);
|
||||
} else if (child.getTag() == null) {
|
||||
applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawerLayout != child) {
|
||||
final int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
|
||||
final int contentHeightSpec = MeasureSpec.makeMeasureSpec(heightSize - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY);
|
||||
child.measure(contentWidthSpec, contentHeightSpec);
|
||||
} else {
|
||||
child.setPadding(0, 0, 0, 0);
|
||||
final int drawerWidthSpec = getChildMeasureSpec(widthMeasureSpec, minDrawerMargin + lp.leftMargin + lp.rightMargin, lp.width);
|
||||
final int drawerHeightSpec = getChildMeasureSpec(heightMeasureSpec, lp.topMargin + lp.bottomMargin, lp.height);
|
||||
child.measure(drawerWidthSpec, drawerHeightSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
if (!allowDrawContent) {
|
||||
return false;
|
||||
}
|
||||
final int height = getHeight();
|
||||
final boolean drawingContent = child != drawerLayout;
|
||||
int lastVisibleChild = 0;
|
||||
int clipLeft = 0, clipRight = getWidth();
|
||||
|
||||
final int restoreCount = canvas.save();
|
||||
if (drawingContent) {
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View v = getChildAt(i);
|
||||
if (v.getVisibility() == VISIBLE && v != drawerLayout) {
|
||||
lastVisibleChild = i;
|
||||
}
|
||||
if (v == child || v.getVisibility() != VISIBLE || v != drawerLayout || v.getHeight() < height) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final int vright = v.getRight();
|
||||
if (vright > clipLeft) {
|
||||
clipLeft = vright;
|
||||
}
|
||||
}
|
||||
if (clipLeft != 0) {
|
||||
canvas.clipRect(clipLeft, 0, clipRight, getHeight());
|
||||
}
|
||||
}
|
||||
final boolean result = super.drawChild(canvas, child, drawingTime);
|
||||
canvas.restoreToCount(restoreCount);
|
||||
|
||||
if (scrimOpacity > 0 && drawingContent) {
|
||||
if (indexOfChild(child) == lastVisibleChild) {
|
||||
scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24);
|
||||
canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
|
||||
}
|
||||
} else if (shadowLeft != null) {
|
||||
final float alpha = Math.max(0, Math.min(drawerPosition / AndroidUtilities.dp(20), 1.0f));
|
||||
if (alpha != 0) {
|
||||
shadowLeft.setBounds((int) drawerPosition, child.getTop(), (int) drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom());
|
||||
shadowLeft.setAlpha((int) (0xff * alpha));
|
||||
shadowLeft.draw(canvas);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +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.ui.ActionBar;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
|
||||
public class MenuDrawable extends Drawable {
|
||||
|
||||
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private boolean reverseAngle = false;
|
||||
private long lastFrameTime;
|
||||
//private boolean animationInProgress;
|
||||
private float finalRotation;
|
||||
private float currentRotation;
|
||||
private int currentAnimationTime;
|
||||
private DecelerateInterpolator interpolator = new DecelerateInterpolator();
|
||||
|
||||
public MenuDrawable() {
|
||||
super();
|
||||
paint.setColor(0xffffffff);
|
||||
paint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||
}
|
||||
|
||||
public void setRotation(float rotation, boolean animated) {
|
||||
lastFrameTime = 0;
|
||||
if (currentRotation == 1) {
|
||||
reverseAngle = true;
|
||||
} else if (currentRotation == 0) {
|
||||
reverseAngle = false;
|
||||
}
|
||||
lastFrameTime = 0;
|
||||
if (animated) {
|
||||
if (currentRotation < rotation) {
|
||||
currentAnimationTime = (int) (currentRotation * 300);
|
||||
} else {
|
||||
currentAnimationTime = (int) ((1.0f - currentRotation) * 300);
|
||||
}
|
||||
lastFrameTime = System.currentTimeMillis();
|
||||
finalRotation = rotation;
|
||||
} else {
|
||||
finalRotation = currentRotation = rotation;
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (currentRotation != finalRotation) {
|
||||
if (lastFrameTime != 0) {
|
||||
long dt = System.currentTimeMillis() - lastFrameTime;
|
||||
|
||||
currentAnimationTime += dt;
|
||||
if (currentAnimationTime >= 300) {
|
||||
currentRotation = finalRotation;
|
||||
} else {
|
||||
if (currentRotation < finalRotation) {
|
||||
currentRotation = interpolator.getInterpolation(currentAnimationTime / 300.0f) * finalRotation;
|
||||
} else {
|
||||
currentRotation = 1.0f - interpolator.getInterpolation(currentAnimationTime / 300.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastFrameTime = System.currentTimeMillis();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2);
|
||||
canvas.rotate(currentRotation * (reverseAngle ? -180 : 180));
|
||||
canvas.drawLine(-AndroidUtilities.dp(9), 0, AndroidUtilities.dp(9) - AndroidUtilities.dp(3.0f) * currentRotation, 0, paint);
|
||||
float endYDiff = AndroidUtilities.dp(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation);
|
||||
float endXDiff = AndroidUtilities.dp(9) - AndroidUtilities.dp(2.5f) * Math.abs(currentRotation);
|
||||
float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(2.0f) * Math.abs(currentRotation);
|
||||
float startXDiff = -AndroidUtilities.dp(9) + AndroidUtilities.dp(7.5f) * Math.abs(currentRotation);
|
||||
canvas.drawLine(startXDiff, -startYDiff, endXDiff, -endYDiff, paint);
|
||||
canvas.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSPARENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return AndroidUtilities.dp(24);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return AndroidUtilities.dp(24);
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,9 @@ public class Theme {
|
||||
public static Drawable systemDrawable;
|
||||
public static Drawable timeBackgroundDrawable;
|
||||
public static Drawable timeStickerBackgroundDrawable;
|
||||
public static Drawable encrOutDrawable;
|
||||
public static Drawable encrInDrawable;
|
||||
public static Drawable encrMediaDrawable;
|
||||
|
||||
public static Drawable[] cornerOuter = new Drawable[4];
|
||||
public static Drawable[] cornerInner = new Drawable[4];
|
||||
@@ -147,6 +150,10 @@ public class Theme {
|
||||
timeStickerBackgroundDrawable = context.getResources().getDrawable(R.drawable.phototime2);
|
||||
systemDrawable = context.getResources().getDrawable(R.drawable.system);
|
||||
|
||||
encrInDrawable = context.getResources().getDrawable(R.drawable.msg_encr_in);
|
||||
encrOutDrawable = context.getResources().getDrawable(R.drawable.msg_encr_out);
|
||||
encrMediaDrawable = context.getResources().getDrawable(R.drawable.msg_encr_media);
|
||||
|
||||
inlistDrawable[INLIST_FILE] = context.getResources().getDrawable(R.drawable.attach_file_inlist);
|
||||
inlistDrawable[INLIST_PLAY] = context.getResources().getDrawable(R.drawable.attach_audio_inlist_play);
|
||||
inlistDrawable[INLIST_TRANSP_PLAY] = context.getResources().getDrawable(R.drawable.video_play);
|
||||
|
||||
@@ -90,9 +90,6 @@ public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
DialogCell cell = (DialogCell) viewHolder.itemView;
|
||||
cell.useSeparator = (i != getItemCount() - 1);
|
||||
MrChat mrChat = getItem(i);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(mrChat.getId() == openedDialogId);
|
||||
}
|
||||
|
||||
MrPoortext mrSummary = MrMailbox.m_currChatlist.getSummaryByIndex(i, mrChat);
|
||||
cell.setDialog(mrChat, mrSummary, i, true);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class DialogsSearchAdapter extends RecyclerView.Adapter {
|
||||
MrPoortext mrSummary = mrMsg.getSummary(mrChat);
|
||||
|
||||
cell.setDialog(mrChat, mrSummary, -1,
|
||||
mrMsg.getState()==MrMsg.MR_IN_UNREAD /*show unread count only if the message itself is unread*/ );
|
||||
mrMsg.getState()==MrMsg.MR_IN_FRESH /*show unread count only if the message itself is unread*/ );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1,157 +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.ui.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.Cells.DrawerActionCell;
|
||||
import com.b44t.ui.Cells.DividerCell;
|
||||
import com.b44t.ui.Cells.EmptyCell;
|
||||
import com.b44t.ui.Cells.DrawerProfileCell;
|
||||
|
||||
public class DrawerLayoutAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public final static int ROW_PROFILE = 0;
|
||||
public final static int ROW_EMPTY_BELOW_PROFILE = 1;
|
||||
public final static int ROW_NEW_CHAT = 2;
|
||||
public final static int ROW_NEW_GROUP = 3;
|
||||
public final static int ROW_DIVIDER = 4;
|
||||
public final static int ROW_SETTINGS = 5;
|
||||
public final static int ROW_INVITE = 6;
|
||||
public final static int ROW_DEADDROP = 7;
|
||||
public final static int ROW_FAQ = 8;
|
||||
public final static int ROW_COUNT = 9;
|
||||
|
||||
private final static int TYPE_PROFILE = 0;
|
||||
private final static int TYPE_EMPTY = 1;
|
||||
private final static int TYPE_DIVIDER = 2;
|
||||
private final static int TYPE_BUTTON = 3;
|
||||
private final static int TYPE_COUNT = 4;
|
||||
|
||||
public DrawerLayoutAdapter(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return !(i == ROW_PROFILE || i == ROW_EMPTY_BELOW_PROFILE || i == ROW_DIVIDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return ROW_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasStableIds() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
int type = getItemViewType(i);
|
||||
if (type == TYPE_PROFILE) {
|
||||
if (view == null) {
|
||||
view = new DrawerProfileCell(mContext);
|
||||
}
|
||||
((DrawerProfileCell) view).updateUserName();
|
||||
} else if (type == TYPE_EMPTY) {
|
||||
if (view == null) {
|
||||
view = new EmptyCell(mContext, AndroidUtilities.dp(8));
|
||||
}
|
||||
} else if (type == TYPE_DIVIDER) {
|
||||
if (view == null) {
|
||||
view = new DividerCell(mContext);
|
||||
}
|
||||
} else if (type == TYPE_BUTTON) {
|
||||
if (view == null) {
|
||||
view = new DrawerActionCell(mContext);
|
||||
}
|
||||
DrawerActionCell actionCell = (DrawerActionCell) view;
|
||||
if (i == ROW_NEW_CHAT) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.NewChat), R.drawable.menu_newchat);
|
||||
} else if (i == ROW_NEW_GROUP) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.NewGroup), R.drawable.menu_empty);
|
||||
} else if (i == ROW_INVITE) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.InviteMenuEntry), R.drawable.menu_empty);
|
||||
} else if (i == ROW_DEADDROP) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.Deaddrop), R.drawable.menu_empty);
|
||||
// we do not want an icon beside the mailbox:
|
||||
// 1. We do not want to give it much attention,
|
||||
// 2. If the mailbox is shown in the chatlist, it gets the chat icon (KISS), but we should not use this icon in the drawer for the mailbox.
|
||||
// 3. Simplicity - we have two sections, "Add" and "Tools" - Mailbox belongs to the latter
|
||||
} else if (i == ROW_SETTINGS) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.Settings), R.drawable.menu_settings);
|
||||
} else if (i == ROW_FAQ) {
|
||||
actionCell.setTextAndIcon(mContext.getString(R.string.Help), R.drawable.menu_empty);
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == ROW_PROFILE) {
|
||||
return TYPE_PROFILE;
|
||||
} else if (i == ROW_EMPTY_BELOW_PROFILE) {
|
||||
return TYPE_EMPTY;
|
||||
} else if (i == ROW_DIVIDER) {
|
||||
return TYPE_DIVIDER;
|
||||
}
|
||||
return TYPE_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return TYPE_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -197,8 +197,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
private static TextPaint timePaint;
|
||||
private static TextPaint namePaint;
|
||||
private static TextPaint forwardNamePaint;
|
||||
private static TextPaint forward2NamePaint;
|
||||
|
||||
private int backgroundWidth = 100;
|
||||
|
||||
@@ -208,7 +206,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean avatarPressed;
|
||||
private boolean forwardNamePressed;
|
||||
|
||||
private boolean drawNewchatButton;
|
||||
private boolean newchatPressed;
|
||||
@@ -223,26 +220,23 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
private boolean drawName;
|
||||
private boolean drawNameLayout;
|
||||
|
||||
private StaticLayout[] forwardedNameLayout = new StaticLayout[2];
|
||||
private boolean allowForwardedName;
|
||||
private static TextPaint forwardedNamePaint;
|
||||
private StaticLayout forwardedNameLayout;
|
||||
private int forwardedNameWidth;
|
||||
private boolean drawForwardedName;
|
||||
private int forwardNameX;
|
||||
private int forwardNameY;
|
||||
private float forwardNameOffsetX[] = new float[2];
|
||||
private float forwardedNameOffsetX;
|
||||
|
||||
private StaticLayout timeLayout;
|
||||
private int timeWidth;
|
||||
private int timeTextWidth;
|
||||
private int timeWidth; // includes timeEncrWidth
|
||||
private int timeEncrWidth;
|
||||
private int timeX;
|
||||
private String currentTimeString;
|
||||
private boolean drawTime = true;
|
||||
|
||||
private TLRPC.User currentUser;
|
||||
private final Object currentChat = null;
|
||||
private TLRPC.FileLocation currentPhoto;
|
||||
private String currentNameString;
|
||||
|
||||
private String currentForwardNameString;
|
||||
|
||||
private ChatMessageCellDelegate delegate;
|
||||
|
||||
@@ -287,12 +281,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
namePaint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
namePaint.setTextSize(dp(14));
|
||||
|
||||
forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
forwardNamePaint.setTextSize(dp(14));
|
||||
|
||||
forward2NamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
forward2NamePaint.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
forward2NamePaint.setTextSize(dp(14));
|
||||
forwardedNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
forwardedNamePaint.setTextSize(dp(14));
|
||||
}
|
||||
avatarImage = new ImageReceiver(this);
|
||||
avatarImage.setRoundRadius(dp(21));
|
||||
@@ -664,9 +654,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
if (isAvatarVisible && avatarImage.isInsideImage(x, y)) {
|
||||
avatarPressed = true;
|
||||
result = true;
|
||||
} else if (drawForwardedName && forwardedNameLayout[0] != null && x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + dp(32)) {
|
||||
forwardNamePressed = true;
|
||||
result = true;
|
||||
} else if (drawNewchatButton && x >= newchatStartX && x <= newchatStartX + dp(40) && y >= newchatStartY && y <= newchatStartY + dp(32)) {
|
||||
newchatPressed = true;
|
||||
result = true;
|
||||
@@ -696,16 +683,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
avatarPressed = false;
|
||||
}
|
||||
}
|
||||
} else if (forwardNamePressed) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
forwardNamePressed = false;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
forwardNamePressed = false;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (!(x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + dp(32))) {
|
||||
forwardNamePressed = false;
|
||||
}
|
||||
}
|
||||
} else if (newchatPressed) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
newchatPressed = false;
|
||||
@@ -867,7 +844,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
|
||||
private boolean isUserDataChanged() {
|
||||
if (currentMessageObject == null || currentUser == null && currentChat == null) {
|
||||
if (currentMessageObject == null || currentUser == null) {
|
||||
return false;
|
||||
}
|
||||
if (lastSendState != currentMessageObject.messageOwner.send_state) {
|
||||
@@ -878,12 +855,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
|
||||
TLRPC.User newUser = null;
|
||||
final TLRPC.Chat newChat = null;
|
||||
if (currentMessageObject.isFromUser()) {
|
||||
newUser = MrMailbox.getUser(currentMessageObject.messageOwner.from_id);
|
||||
} /*else if (currentMessageObject.messageOwner.post) {
|
||||
newChat = MessagesController.getInstance().getChat(currentMessageObject.messageOwner.to_id.channel_id);
|
||||
}*/
|
||||
}
|
||||
TLRPC.FileLocation newPhoto = null;
|
||||
|
||||
if (isAvatarVisible) {
|
||||
@@ -900,8 +874,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
if (drawName && isGroupChat && !currentMessageObject.isOutOwner()) {
|
||||
if (newUser != null) {
|
||||
newNameString = "ErrName"; // use MrContact.getName(), if really needed
|
||||
} else if (newChat != null) {
|
||||
newNameString = newChat.title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -909,10 +881,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
return true;
|
||||
}
|
||||
|
||||
if (drawForwardedName) {
|
||||
newNameString = currentMessageObject.getForwardedName();
|
||||
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1083,12 +1051,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
int minutes = duration / 60;
|
||||
int seconds = duration - minutes * 60;
|
||||
String str = String.format("%d:%02d, %s", minutes, seconds, formatFileSize(documentAttach.size));
|
||||
String infoString = String.format("%d:%02d, %s", minutes, seconds, formatFileSize(documentAttach.size));
|
||||
if( MrMailbox.getMsg(messageObject.getId()).isIncreation()!=0 ) {
|
||||
str = ApplicationLoader.applicationContext.getString(R.string.OneMoment);
|
||||
infoString = ApplicationLoader.applicationContext.getString(R.string.OneMoment);
|
||||
}
|
||||
infoWidth = (int) Math.ceil(infoPaint.measureText(str));
|
||||
infoLayout = new StaticLayout(str, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
infoWidth = (int) Math.ceil(infoPaint.measureText(infoString));
|
||||
infoLayout = new StaticLayout(infoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1103,30 +1071,24 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
docTitleLayout = StaticLayoutEx.createStaticLayout(name, docNamePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.MIDDLE, maxWidth, drawPhotoImage ? 2 : 1);
|
||||
docTitleOffsetX = Integer.MIN_VALUE;
|
||||
int width;
|
||||
if (docTitleLayout != null && docTitleLayout.getLineCount() > 0) {
|
||||
int maxLineWidth = 0;
|
||||
for (int a = 0; a < docTitleLayout.getLineCount(); a++) {
|
||||
maxLineWidth = Math.max(maxLineWidth, (int) Math.ceil(docTitleLayout.getLineWidth(a)));
|
||||
docTitleOffsetX = Math.max(docTitleOffsetX, (int) Math.ceil(-docTitleLayout.getLineLeft(a)));
|
||||
}
|
||||
width = Math.min(maxWidth, maxLineWidth);
|
||||
} else {
|
||||
width = maxWidth;
|
||||
docTitleOffsetX = 0;
|
||||
}
|
||||
|
||||
String str = formatFileSize(documentAttach.size) + " " + FileLoader.getDocumentExtension(documentAttach);
|
||||
infoWidth = Math.min(maxWidth - AndroidUtilities.dp(30), (int) Math.ceil(infoPaint.measureText(str)));
|
||||
CharSequence str2 = TextUtils.ellipsize(str, infoPaint, infoWidth, TextUtils.TruncateAt.END);
|
||||
try {
|
||||
if (infoWidth < 0) {
|
||||
infoWidth = dp(10);
|
||||
}
|
||||
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
} catch (Exception e) {
|
||||
String infoString = formatFileSize(documentAttach.size) + " " + FileLoader.getDocumentExtension(documentAttach);
|
||||
infoWidth = Math.min(maxWidth - AndroidUtilities.dp(30), (int) Math.ceil(infoPaint.measureText(infoString)));
|
||||
CharSequence str2 = TextUtils.ellipsize(infoString, infoPaint, infoWidth, TextUtils.TruncateAt.END);
|
||||
|
||||
if (infoWidth < 0) {
|
||||
infoWidth = dp(10);
|
||||
}
|
||||
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
if (drawPhotoImage) {
|
||||
currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, getPhotoSize());
|
||||
@@ -1221,7 +1183,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
wasLayout = false;
|
||||
drawNewchatButton = checkNeedDrawNewchatButton(messageObject);
|
||||
currentUser = null;
|
||||
//currentChat = null;
|
||||
drawNameLayout = false;
|
||||
|
||||
resetPressedLink(-1);
|
||||
@@ -1243,7 +1204,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
drawBackground = true;
|
||||
drawName = false;
|
||||
useSeekBarWaveform = false;
|
||||
drawForwardedName = false;
|
||||
allowForwardedName = false;
|
||||
mediaBackground = false;
|
||||
availableTimeWidth = 0;
|
||||
photoImage.setNeedsQualityThumb(false);
|
||||
@@ -1258,25 +1219,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
|
||||
if (messageObject.type == MessageObject.MO_TYPE0_TEXT) {
|
||||
drawForwardedName = true;
|
||||
allowForwardedName = true;
|
||||
|
||||
int maxWidth;
|
||||
if (isTablet()) {
|
||||
if (isGroupChat && !messageObject.isOutOwner() && messageObject.isFromUser()) {
|
||||
maxWidth = getMinTabletSide() - dp(122);
|
||||
drawName = true;
|
||||
} else {
|
||||
drawName = false;
|
||||
maxWidth = getMinTabletSide() - dp(80);
|
||||
}
|
||||
if (isGroupChat && !messageObject.isOutOwner() && messageObject.isFromUser()) {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(122);
|
||||
drawName = true;
|
||||
} else {
|
||||
if (isGroupChat && !messageObject.isOutOwner() && messageObject.isFromUser()) {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(122);
|
||||
drawName = true;
|
||||
} else {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(80);
|
||||
drawName = false;
|
||||
}
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(80);
|
||||
drawName = false;
|
||||
}
|
||||
measureTime(messageObject);
|
||||
int timeMore = timeWidth + dp(6);
|
||||
@@ -1309,12 +1260,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
photoImage.setImageBitmap((Drawable) null);
|
||||
calcBackgroundWidth(maxWidth, timeMore, maxChildWidth);
|
||||
} else if (messageObject.type == MessageObject.MO_TYPE2_VOICE) {
|
||||
drawForwardedName = true;
|
||||
if (isTablet()) {
|
||||
backgroundWidth = Math.min(getMinTabletSide() - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
} else {
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
}
|
||||
allowForwardedName = true;
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
createDocumentLayout(backgroundWidth, messageObject);
|
||||
|
||||
setMessageObjectInternal(messageObject);
|
||||
@@ -1323,11 +1270,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
updateWaveform(true);
|
||||
} else if (messageObject.type == MessageObject.MO_TYPE14_MUSIC) {
|
||||
if (isTablet()) {
|
||||
backgroundWidth = Math.min(getMinTabletSide() - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
} else {
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
}
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
|
||||
createDocumentLayout(backgroundWidth, messageObject);
|
||||
|
||||
@@ -1335,7 +1278,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
totalHeight = dp(80) + namesOffset;
|
||||
} else {
|
||||
drawForwardedName = messageObject.messageOwner.fwd_from != null && messageObject.type != MessageObject.MO_TYPE13_STICKER;
|
||||
allowForwardedName = messageObject.isForwarded() && messageObject.type != MessageObject.MO_TYPE13_STICKER;
|
||||
mediaBackground = messageObject.type != MessageObject.MO_TYPE9_FILE;
|
||||
drawImageButton = false; // we do not want the image button for images
|
||||
drawPhotoImage = true;
|
||||
@@ -1352,11 +1295,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
photoImage.setForcePreview(false);
|
||||
if (messageObject.type == MessageObject.MO_TYPE9_FILE) {
|
||||
if (isTablet()) {
|
||||
backgroundWidth = Math.min(getMinTabletSide() - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
} else {
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
}
|
||||
backgroundWidth = Math.min(displaySize.x - dp(isGroupChat && messageObject.isFromUser() && !messageObject.isOutOwner() ? 102 : 50), dp(270));
|
||||
if (checkNeedDrawNewchatButton(messageObject)) {
|
||||
backgroundWidth -= dp(20);
|
||||
}
|
||||
@@ -1395,11 +1334,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
float maxHeight;
|
||||
float maxWidth;
|
||||
if (isTablet()) {
|
||||
maxHeight = maxWidth = getMinTabletSide() * 0.4f;
|
||||
} else {
|
||||
maxHeight = maxWidth = Math.min(displaySize.x, displaySize.y) * 0.5f;
|
||||
}
|
||||
maxHeight = maxWidth = Math.min(displaySize.x, displaySize.y) * 0.5f;
|
||||
if (photoWidth == 0) {
|
||||
photoHeight = (int) maxHeight;
|
||||
photoWidth = photoHeight + dp(100);
|
||||
@@ -1431,11 +1366,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
} else {
|
||||
int maxPhotoWidth;
|
||||
if (isTablet()) {
|
||||
maxPhotoWidth = photoWidth = (int) (getMinTabletSide() * 0.7f);
|
||||
} else {
|
||||
maxPhotoWidth = photoWidth = (int) (Math.min(displaySize.x, displaySize.y) * 0.7f);
|
||||
}
|
||||
maxPhotoWidth = photoWidth = (int) (Math.min(displaySize.x, displaySize.y) * 0.7f);
|
||||
photoHeight = photoWidth + dp(100);
|
||||
if (checkNeedDrawNewchatButton(messageObject)) {
|
||||
maxPhotoWidth -= dp(20);
|
||||
@@ -1604,7 +1535,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
setMessageObjectInternal(messageObject);
|
||||
|
||||
if (drawForwardedName) {
|
||||
if (allowForwardedName) {
|
||||
namesOffset += dp(5);
|
||||
} else if (drawNameLayout && messageObject.messageOwner.reply_to_msg_id == 0) {
|
||||
namesOffset += dp(7);
|
||||
@@ -1655,10 +1586,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
if (changed || !wasLayout) {
|
||||
layoutWidth = getMeasuredWidth();
|
||||
layoutHeight = getMeasuredHeight() - substractBackgroundHeight;
|
||||
if (timeTextWidth < 0) {
|
||||
timeTextWidth = dp(10);
|
||||
}
|
||||
timeLayout = new StaticLayout(currentTimeString, timePaint, timeTextWidth + dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
timeLayout = new StaticLayout(currentTimeString, timePaint, timeWidth + dp(6), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (!mediaBackground) {
|
||||
if (!currentMessageObject.isOutOwner()) {
|
||||
timeX = backgroundWidth - dp(9) - timeWidth + (isGroupChat && currentMessageObject.isFromUser() ? dp(48) : 0);
|
||||
@@ -1882,7 +1810,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
}
|
||||
else if (currentMessageObject.type == MessageObject.MO_TYPE1_PHOTO || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
|
||||
if (photoImage.getVisible()) {
|
||||
if (infoLayout != null && (buttonState == BS1_CLICK_TO_PAUSE || buttonState == BS0_CLICK_TO_PLAY || buttonState == BS3_NORMAL)) {
|
||||
if (infoLayout != null /*&& (buttonState == BS1_CLICK_TO_PAUSE || buttonState == BS0_CLICK_TO_PLAY || buttonState == BS3_NORMAL)*/) {
|
||||
infoPaint.setColor(Theme.MSG_MEDIA_INFO_TEXT_COLOR);
|
||||
setDrawableBounds(Theme.timeBackgroundDrawable, photoImage.getImageX() + dp(4), photoImage.getImageY() + dp(4), infoWidth + dp(8), dp(16.5f));
|
||||
Theme.timeBackgroundDrawable.draw(canvas);
|
||||
@@ -1978,18 +1906,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
private int getMaxNameWidth() {
|
||||
if (documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) {
|
||||
int maxWidth;
|
||||
if (isTablet()) {
|
||||
if (isGroupChat && !currentMessageObject.isOutOwner() && currentMessageObject.isFromUser()) {
|
||||
maxWidth = getMinTabletSide() - dp(42);
|
||||
} else {
|
||||
maxWidth = getMinTabletSide();
|
||||
}
|
||||
if (isGroupChat && !currentMessageObject.isOutOwner() && currentMessageObject.isFromUser()) {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(42);
|
||||
} else {
|
||||
if (isGroupChat && !currentMessageObject.isOutOwner() && currentMessageObject.isFromUser()) {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y) - dp(42);
|
||||
} else {
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y);
|
||||
}
|
||||
maxWidth = Math.min(displaySize.x, displaySize.y);
|
||||
}
|
||||
return maxWidth - backgroundWidth - dp(57);
|
||||
}
|
||||
@@ -2089,7 +2009,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
private void measureTime(MessageObject messageObject) {
|
||||
currentTimeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
|
||||
timeTextWidth = timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
|
||||
timeWidth = (int) Math.ceil(timePaint.measureText(currentTimeString));
|
||||
timeEncrWidth = 0;
|
||||
if( messageObject.messageOwner.e2ee ) {
|
||||
timeEncrWidth = Theme.encrOutDrawable.getIntrinsicWidth();
|
||||
timeWidth += timeEncrWidth;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDrawSelectedBackground() {
|
||||
@@ -2107,11 +2032,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
|
||||
if (currentMessageObject.isFromUser()) {
|
||||
currentUser = MrMailbox.getUser(currentMessageObject.messageOwner.from_id);
|
||||
} /*else if (currentMessageObject.messageOwner.from_id < 0) {
|
||||
currentChat = MessagesController.getInstance().getChat(-currentMessageObject.messageOwner.from_id);
|
||||
} else if (currentMessageObject.messageOwner.post) {
|
||||
currentChat = MessagesController.getInstance().getChat(currentMessageObject.messageOwner.to_id.channel_id);
|
||||
}*/
|
||||
}
|
||||
|
||||
MrContact mrContact = null;
|
||||
String cname = "";
|
||||
@@ -2137,21 +2058,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
nameWidth = dp(100);
|
||||
}
|
||||
|
||||
if (authorName) {
|
||||
if (currentUser != null) {
|
||||
currentNameString = cname;
|
||||
} /*else if (currentChat != null) {
|
||||
currentNameString = currentChat.title;
|
||||
} */ else {
|
||||
currentNameString = "DELETED";
|
||||
}
|
||||
if (currentUser != null) {
|
||||
currentNameString = cname;
|
||||
} else {
|
||||
currentNameString = "";
|
||||
currentNameString = "DELETED";
|
||||
}
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace('\n', ' '), namePaint, nameWidth, TextUtils.TruncateAt.END);
|
||||
try {
|
||||
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth + dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (nameLayout != null && nameLayout.getLineCount() > 0) {
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
nameWidth = (int) Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (messageObject.type != MessageObject.MO_TYPE13_STICKER) {
|
||||
namesOffset += dp(19);
|
||||
@@ -2172,28 +2087,18 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
nameWidth = 0;
|
||||
}
|
||||
|
||||
currentForwardNameString = null;
|
||||
forwardedNameLayout[0] = null;
|
||||
forwardedNameLayout[1] = null;
|
||||
forwardedNameLayout = null;
|
||||
forwardedNameWidth = 0;
|
||||
if( drawForwardedName && messageObject.isForwarded() && messageObject.messageOwner.fwd_from!=null )
|
||||
if( allowForwardedName && messageObject.isForwarded() )
|
||||
{
|
||||
currentForwardNameString = messageObject.messageOwner.fwd_from.m_name;
|
||||
|
||||
forwardedNameWidth = getMaxNameWidth();
|
||||
int fromWidth = (int) Math.ceil(forwardNamePaint.measureText(ApplicationLoader.applicationContext.getString(R.string.From) + " "));
|
||||
CharSequence name = TextUtils.ellipsize(currentForwardNameString.replace('\n', ' '), forward2NamePaint, forwardedNameWidth - fromWidth, TextUtils.TruncateAt.END);
|
||||
CharSequence lastLine;
|
||||
lastLine = replaceTags(String.format("%s <b>%s</b>", ApplicationLoader.applicationContext.getString(R.string.From), name));
|
||||
lastLine = TextUtils.ellipsize(lastLine, forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END);
|
||||
try {
|
||||
forwardedNameLayout[1] = new StaticLayout(lastLine, forwardNamePaint, forwardedNameWidth + dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
lastLine = TextUtils.ellipsize(replaceTags(ApplicationLoader.applicationContext.getString(R.string.ForwardedMessage)), forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END);
|
||||
forwardedNameLayout[0] = new StaticLayout(lastLine, forwardNamePaint, forwardedNameWidth + dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout[0].getLineWidth(0)), (int) Math.ceil(forwardedNameLayout[1].getLineWidth(0)));
|
||||
forwardNameOffsetX[0] = forwardedNameLayout[0].getLineLeft(0);
|
||||
forwardNameOffsetX[1] = forwardedNameLayout[1].getLineLeft(0);
|
||||
namesOffset += dp(36);
|
||||
lastLine = TextUtils.ellipsize(replaceTags(ApplicationLoader.applicationContext.getString(R.string.ForwardedMessage)), forwardedNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END);
|
||||
forwardedNameLayout = new StaticLayout(lastLine, forwardedNamePaint, forwardedNameWidth + dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
forwardedNameWidth = (int) Math.ceil(forwardedNameLayout.getLineWidth(0));
|
||||
forwardedNameOffsetX = forwardedNameLayout.getLineLeft(0);
|
||||
namesOffset += dp(18);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
@@ -2299,24 +2204,23 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (drawForwardedName && forwardedNameLayout[0] != null && forwardedNameLayout[1] != null) {
|
||||
forwardNameY = dp(10 + (drawNameLayout ? 19 : 0));
|
||||
forwardNamePaint.setColor(Theme.MSG_IN_TIME_N_FWD_TEXT_COLOR);
|
||||
if (allowForwardedName && forwardedNameLayout != null ) {
|
||||
int forwardedNameX = 0;
|
||||
int forwardedNameY = dp(10 + (drawNameLayout ? 19 : 0));
|
||||
forwardedNamePaint.setColor(Theme.MSG_IN_TIME_N_FWD_TEXT_COLOR);
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + dp(11);
|
||||
forwardedNameX = currentBackgroundDrawable.getBounds().left + dp(11);
|
||||
} else {
|
||||
if (mediaBackground) {
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + dp(11);
|
||||
forwardedNameX = currentBackgroundDrawable.getBounds().left + dp(11);
|
||||
} else {
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + dp(17);
|
||||
forwardedNameX = currentBackgroundDrawable.getBounds().left + dp(17);
|
||||
}
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
canvas.save();
|
||||
canvas.translate(forwardNameX - forwardNameOffsetX[a], forwardNameY + dp(16) * a);
|
||||
forwardedNameLayout[a].draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.save();
|
||||
canvas.translate(forwardedNameX - forwardedNameOffsetX, forwardedNameY);
|
||||
forwardedNameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (drawTime || !mediaBackground) {
|
||||
@@ -2333,19 +2237,36 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||
int additionalX = 0;
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX + additionalX, layoutHeight - dp(11.3f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX + additionalX + timeEncrWidth, layoutHeight - dp(11.3f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
int additionalX = 0;
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX + additionalX, layoutHeight - dp(6.5f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX + additionalX + timeEncrWidth, layoutHeight - dp(6.5f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
//canvas.drawRect(timeX, layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight(), timeX + availableTimeWidth, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight(), timePaint);
|
||||
}
|
||||
|
||||
// draw encryption icon left of clock
|
||||
if( timeEncrWidth>0 ) {
|
||||
if (!mediaBackground) {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
setDrawableBounds(Theme.encrOutDrawable, timeX, layoutHeight - dp(8.5f) - Theme.encrOutDrawable.getIntrinsicHeight());
|
||||
Theme.encrOutDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(Theme.encrInDrawable, timeX, layoutHeight - dp(8.5f) - Theme.encrInDrawable.getIntrinsicHeight());
|
||||
Theme.encrInDrawable.draw(canvas);
|
||||
}
|
||||
} else {
|
||||
setDrawableBounds(Theme.encrMediaDrawable, timeX, layoutHeight - dp(13.2f) - Theme.encrMediaDrawable.getIntrinsicHeight());
|
||||
Theme.encrMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
// draw checkmarks right of clock
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
boolean drawCheck1 = false;
|
||||
boolean drawCheck2 = false;
|
||||
|
||||
@@ -70,7 +70,6 @@ public class DialogCell extends BaseCell {
|
||||
private static Drawable countDrawableGrey;
|
||||
private static Drawable groupDrawable;
|
||||
private static Drawable muteDrawable;
|
||||
private static Drawable verifiedDrawable;
|
||||
|
||||
private static Paint linePaint;
|
||||
private static Paint backPaint;
|
||||
@@ -114,7 +113,7 @@ public class DialogCell extends BaseCell {
|
||||
private StaticLayout messageLayout;
|
||||
|
||||
private boolean drawError;
|
||||
private int errorTop = AndroidUtilities.dp(39);
|
||||
private int errorTop = AndroidUtilities.dp(42);
|
||||
private int errorLeft;
|
||||
|
||||
private boolean drawCount;
|
||||
@@ -123,8 +122,6 @@ public class DialogCell extends BaseCell {
|
||||
private int countWidth;
|
||||
private StaticLayout countLayout;
|
||||
|
||||
private boolean drawVerified;
|
||||
|
||||
private int avatarTop = AndroidUtilities.dp(10);
|
||||
|
||||
private boolean isSelected;
|
||||
@@ -168,12 +165,11 @@ public class DialogCell extends BaseCell {
|
||||
checkDrawable = getResources().getDrawable(R.drawable.dialogs_check);
|
||||
halfCheckDrawable = getResources().getDrawable(R.drawable.dialogs_halfcheck);
|
||||
clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
|
||||
errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning);
|
||||
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);
|
||||
verifiedDrawable = getResources().getDrawable(R.drawable.check_list);
|
||||
}
|
||||
|
||||
setBackgroundResource(R.drawable.list_selector);
|
||||
@@ -253,10 +249,6 @@ public class DialogCell extends BaseCell {
|
||||
boolean checkMessage = true;
|
||||
|
||||
drawNameGroup = false;
|
||||
//drawNameBroadcast = false;
|
||||
//drawNameLock = false;
|
||||
//drawNameBot = false;
|
||||
drawVerified = false;
|
||||
|
||||
{
|
||||
if (m_mrChat.getType()==MrChat.MR_CHAT_GROUP) { // EDIT BY MR
|
||||
@@ -267,7 +259,6 @@ public class DialogCell extends BaseCell {
|
||||
drawNameGroup = true;
|
||||
nameLockTop = AndroidUtilities.dp(17.5f);
|
||||
//}
|
||||
//drawVerified = chat.verified; -- /EDIT BY MR
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
|
||||
@@ -326,9 +317,8 @@ public class DialogCell extends BaseCell {
|
||||
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_READ: drawCheck1 = true; drawCheck2 = true; break;
|
||||
case MrMsg.MR_OUT_MDN_RCVD: drawCheck1 = true; drawCheck2 = true; break;
|
||||
}
|
||||
drawVerified = m_mrChat.isEncrypted()!=0; // we use the "verified" check as an icon for "encryted" and "verified"
|
||||
}
|
||||
|
||||
if (unreadCount != 0) {
|
||||
@@ -393,18 +383,12 @@ public class DialogCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
if (dialogMuted && !drawVerified) {
|
||||
if (dialogMuted) {
|
||||
int w = AndroidUtilities.dp(6) + muteDrawable.getIntrinsicWidth();
|
||||
nameWidth -= w;
|
||||
if (LocaleController.isRTL) {
|
||||
nameLeft += w;
|
||||
}
|
||||
} else if (drawVerified) {
|
||||
int w = AndroidUtilities.dp(6) + verifiedDrawable.getIntrinsicWidth();
|
||||
nameWidth -= w;
|
||||
if (LocaleController.isRTL) {
|
||||
nameLeft += w;
|
||||
}
|
||||
}
|
||||
|
||||
nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth);
|
||||
@@ -419,19 +403,19 @@ public class DialogCell extends BaseCell {
|
||||
int avatarLeft;
|
||||
if (!LocaleController.isRTL) {
|
||||
messageLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
|
||||
avatarLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 13 : 9);
|
||||
avatarLeft = AndroidUtilities.dp(9);
|
||||
} else {
|
||||
messageLeft = AndroidUtilities.dp(16);
|
||||
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 65 : 61);
|
||||
avatarLeft = getMeasuredWidth() - AndroidUtilities.dp(61);
|
||||
}
|
||||
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(52), AndroidUtilities.dp(52));
|
||||
if (drawError) {
|
||||
int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8);
|
||||
messageWidth -= w;
|
||||
if (!LocaleController.isRTL) {
|
||||
errorLeft = getMeasuredWidth() - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(11);
|
||||
errorLeft = getMeasuredWidth() - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(16);
|
||||
} else {
|
||||
errorLeft = AndroidUtilities.dp(11);
|
||||
errorLeft = AndroidUtilities.dp(16);
|
||||
messageLeft += w;
|
||||
}
|
||||
} else if (countString != null) {
|
||||
@@ -475,10 +459,8 @@ public class DialogCell extends BaseCell {
|
||||
if (nameLayout != null && nameLayout.getLineCount() > 0) {
|
||||
left = nameLayout.getLineLeft(0);
|
||||
widthpx = Math.ceil(nameLayout.getLineWidth(0));
|
||||
if (dialogMuted && !drawVerified) {
|
||||
if (dialogMuted) {
|
||||
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - muteDrawable.getIntrinsicWidth());
|
||||
} else if (drawVerified) {
|
||||
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - verifiedDrawable.getIntrinsicWidth());
|
||||
}
|
||||
if (left == 0) {
|
||||
if (widthpx < nameWidth) {
|
||||
@@ -504,7 +486,7 @@ public class DialogCell extends BaseCell {
|
||||
nameLeft -= (nameWidth - widthpx);
|
||||
}
|
||||
}
|
||||
if (dialogMuted || drawVerified) {
|
||||
if (dialogMuted) {
|
||||
nameMuteLeft = (int) (nameLeft + left + AndroidUtilities.dp(6));
|
||||
}
|
||||
}
|
||||
@@ -544,7 +526,7 @@ public class DialogCell extends BaseCell {
|
||||
|
||||
public void update(int mask) {
|
||||
if( m_showUnreadCount ) {
|
||||
unreadCount = m_mrChat.getUnseenCount();
|
||||
unreadCount = m_mrChat.getFreshMsgCount();
|
||||
}
|
||||
|
||||
if (mask != 0) {
|
||||
@@ -669,12 +651,9 @@ public class DialogCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
if (dialogMuted && !drawVerified) { // TODO: if we enable encrypted chats and show the verified logo, we may show both, muted and verivied
|
||||
if (dialogMuted) {
|
||||
setDrawableBounds(muteDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
|
||||
muteDrawable.draw(canvas);
|
||||
} else if (drawVerified) {
|
||||
setDrawableBounds(verifiedDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
|
||||
verifiedDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
if (drawError) {
|
||||
|
||||
@@ -1,54 +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.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
|
||||
public class DividerCell extends BaseCell {
|
||||
|
||||
private static Paint paint;
|
||||
|
||||
public DividerCell(Context context) {
|
||||
super(context);
|
||||
if (paint == null) {
|
||||
paint = new Paint();
|
||||
paint.setColor(0xffd9d9d9);
|
||||
paint.setStrokeWidth(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(16) + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
canvas.drawLine(getPaddingLeft(), AndroidUtilities.dp(8), getWidth() - getPaddingRight(), AndroidUtilities.dp(8), paint);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
public class DrawerActionCell extends FrameLayout {
|
||||
|
||||
private TextView textView;
|
||||
|
||||
public DrawerActionCell(Context context) {
|
||||
super(context);
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setTextColor(0xff000000);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textView.setLines(1);
|
||||
textView.setMaxLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
textView.setCompoundDrawablePadding(AndroidUtilities.dp(18));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START | Gravity.TOP, 14, 0, 16, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setTextAndIcon(String text, int resId) {
|
||||
try {
|
||||
textView.setText(text);
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,14 +49,20 @@ public class EditTextCell extends FrameLayout {
|
||||
private static Paint paint;
|
||||
private boolean needDivider;
|
||||
private boolean useLabel;
|
||||
private boolean multiLine;
|
||||
|
||||
public EditTextCell(Context context) {
|
||||
this(context, true);
|
||||
this(context, true, false);
|
||||
}
|
||||
|
||||
public EditTextCell(Context context, boolean useLabel__) {
|
||||
public EditTextCell(Context context, boolean useLabel) {
|
||||
this(context, useLabel, false);
|
||||
}
|
||||
|
||||
public EditTextCell(Context context, boolean useLabel__, boolean multiLine__) {
|
||||
super(context);
|
||||
useLabel = useLabel__;
|
||||
multiLine = multiLine__;
|
||||
|
||||
if (paint == null) {
|
||||
paint = new Paint();
|
||||
@@ -75,41 +81,44 @@ public class EditTextCell extends FrameLayout {
|
||||
addView(labelTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP,
|
||||
17, 8, 17, 0));
|
||||
|
||||
|
||||
editView = new EditText(context);
|
||||
editView.setTextColor(0xff212121); // ok
|
||||
editView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); // ok, normal text is 16
|
||||
editView.setLines(1);
|
||||
editView.setMaxLines(1);
|
||||
editView.setSingleLine(true);
|
||||
editView.setTextColor(0xff212121);
|
||||
editView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); // normal text is 16
|
||||
int addImeFlag = 0, addInputType = 0;
|
||||
if( multiLine__ ) {
|
||||
editView.setLines(2);
|
||||
editView.setMaxLines(2);
|
||||
editView.setSingleLine(false);
|
||||
editView.setVerticalScrollBarEnabled(true);
|
||||
editView.setHorizontalScrollBarEnabled(false);
|
||||
editView.setMinimumHeight(AndroidUtilities.dp(100));
|
||||
addInputType = EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE|EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES;
|
||||
}
|
||||
else {
|
||||
editView.setLines(1);
|
||||
editView.setMaxLines(1);
|
||||
editView.setSingleLine(true);
|
||||
addInputType = InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
|
||||
addImeFlag = EditorInfo.IME_ACTION_DONE; // just close the keyboard, NEXT would not work as the other entries nay not yet loaded
|
||||
}
|
||||
editView.setHintTextColor(0xffBBBBBB); // was: 0xff979797
|
||||
editView.setGravity(Gravity.START);
|
||||
editView.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
editView.setImeOptions(EditorInfo.IME_ACTION_DONE); // just close the keyboard, NEXT would not work as the other entries nay not yet loaded
|
||||
AndroidUtilities.clearCursorDrawable(editView);
|
||||
/*
|
||||
e.setPadding(0, 0, 0, 0);
|
||||
e.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
|
||||
doneButton.performClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
*/
|
||||
editView.setInputType(editView.getInputType()|addInputType);
|
||||
editView.setImeOptions(addImeFlag|EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
|
||||
addView(editView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP,
|
||||
17, useLabel? 25 : 25-17, 17, 0));
|
||||
17, useLabel? 25 : 25-17, 17, multiLine?17:0));
|
||||
|
||||
setBackgroundColor(0xffffffff);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(useLabel? 64 : 64-15) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
||||
int dpheight = multiLine? 49*2 : 49;
|
||||
if( useLabel ) {
|
||||
dpheight += 15;
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(dpheight)+(needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setValueHintAndLabel(String value, String hint, String label, boolean divider) {
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
public class GreySectionCell extends FrameLayout {
|
||||
|
||||
@@ -31,21 +31,28 @@ import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
public class HeaderCell extends FrameLayout {
|
||||
|
||||
private TextView textView;
|
||||
|
||||
static public TextView createTextView(Context context, String text)
|
||||
{
|
||||
TextView ret = new TextView(context);
|
||||
ret.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
ret.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
ret.setTextColor(0xff5099c9);
|
||||
ret.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
if( text != null ) {
|
||||
ret.setText(text);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public HeaderCell(Context context) {
|
||||
super(context);
|
||||
|
||||
textView = new TextView(getContext());
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
textView.setTextColor(0xff5099c9);
|
||||
textView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
textView = createTextView(getContext(), null);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START | Gravity.TOP, 17, 15, 17, 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -158,11 +158,7 @@ public class PhotoPickerAlbumsCell extends FrameLayout {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int itemWidth;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
itemWidth = (AndroidUtilities.dp(490) - ((albumsCount + 1) * AndroidUtilities.dp(4))) / albumsCount;
|
||||
} else {
|
||||
itemWidth = (AndroidUtilities.displaySize.x - ((albumsCount + 1) * AndroidUtilities.dp(4))) / albumsCount;
|
||||
}
|
||||
itemWidth = (AndroidUtilities.displaySize.x - ((albumsCount + 1) * AndroidUtilities.dp(4))) / albumsCount;
|
||||
|
||||
for (int a = 0; a < albumsCount; a++) {
|
||||
LayoutParams layoutParams = (LayoutParams) albumViews[a].getLayoutParams();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Delta Chat Android
|
||||
* (C) 2013-2016 Nikolai Kudashov
|
||||
* (C) 2017 Björn Petersen
|
||||
* Contact: r10s@b44t.com, http://b44t.com
|
||||
*
|
||||
@@ -27,8 +26,6 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
@@ -42,15 +39,13 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.ActionBar.DrawerLayoutContainer;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
|
||||
public class DrawerProfileCell extends FrameLayout {
|
||||
public class SettingsProfileCell extends FrameLayout {
|
||||
|
||||
private TextView nameTextView;
|
||||
private TextView subtitleTextView;
|
||||
@@ -58,7 +53,7 @@ public class DrawerProfileCell extends FrameLayout {
|
||||
private Rect destRect = new Rect();
|
||||
private Paint paint = new Paint();
|
||||
|
||||
public DrawerProfileCell(Context context) {
|
||||
public SettingsProfileCell(Context context) {
|
||||
super(context);
|
||||
setBackgroundColor(Theme.ACTION_BAR_COLOR);
|
||||
|
||||
@@ -69,7 +64,7 @@ public class DrawerProfileCell extends FrameLayout {
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView.setTextColor(0xffffffff);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DrawerLayoutContainer.USE_DRAWER? 23 : 26);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 26);
|
||||
nameTextView.setLines(1);
|
||||
nameTextView.setMaxLines(1);
|
||||
nameTextView.setSingleLine(true);
|
||||
@@ -79,7 +74,7 @@ public class DrawerProfileCell extends FrameLayout {
|
||||
|
||||
subtitleTextView = new TextView(context);
|
||||
subtitleTextView.setTextColor(0xffc2e5ff);
|
||||
subtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DrawerLayoutContainer.USE_DRAWER? 13 : Theme.ACTION_BAR_SUBTITLE_TEXT_SIZE);
|
||||
subtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, Theme.ACTION_BAR_SUBTITLE_TEXT_SIZE);
|
||||
subtitleTextView.setLines(1);
|
||||
subtitleTextView.setMaxLines(1);
|
||||
subtitleTextView.setSingleLine(true);
|
||||
@@ -90,7 +85,7 @@ public class DrawerProfileCell extends FrameLayout {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int mrHeight = DrawerLayoutContainer.USE_DRAWER? 180 : 100/*see also shadow height above*/;
|
||||
int mrHeight = 100/*see also shadow height above*/;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(mrHeight) + AndroidUtilities.statusBarHeight, MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
@@ -1,87 +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.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
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;
|
||||
|
||||
public class TextDetailCell extends FrameLayout {
|
||||
|
||||
private TextView textView;
|
||||
private TextView valueTextView;
|
||||
private ImageView imageView;
|
||||
|
||||
public TextDetailCell(Context context) {
|
||||
super(context);
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setTextColor(0xff212121);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
textView.setLines(1);
|
||||
textView.setMaxLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setGravity(Gravity.START);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, LocaleController.isRTL ? 16 : 71, 10, LocaleController.isRTL ? 71 : 16, 0));
|
||||
|
||||
valueTextView = new TextView(context);
|
||||
valueTextView.setTextColor(0xff8a8a8a);
|
||||
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||
valueTextView.setLines(1);
|
||||
valueTextView.setMaxLines(1);
|
||||
valueTextView.setSingleLine(true);
|
||||
valueTextView.setGravity(Gravity.START);
|
||||
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START, LocaleController.isRTL ? 16 : 71, 35, LocaleController.isRTL ? 71 : 16, 0));
|
||||
|
||||
imageView = new ImageView(context);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
addView(imageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 0 : 16, 0, LocaleController.isRTL ? 16 : 0, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), View.MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setTextAndValue(String text, String value) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
imageView.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
public void setTextAndValueAndIcon(String text, String value, int resId) {
|
||||
textView.setText(text);
|
||||
valueTextView.setText(value);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
imageView.setImageResource(resId);
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ 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;
|
||||
import android.view.MotionEvent;
|
||||
@@ -152,7 +153,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
private boolean paused = true;
|
||||
private boolean wasPaused = false;
|
||||
private boolean readWhenResume = false;
|
||||
private SparseIntArray markseenWhenResume = new SparseIntArray();
|
||||
|
||||
private boolean scrollToTopOnResume;
|
||||
private boolean forceScrollToTop;
|
||||
@@ -232,10 +233,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.waveformCalculated);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, false);
|
||||
}
|
||||
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -325,7 +322,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MrMailbox.markseenChat((int)dialog_id);
|
||||
MrMailbox.marknoticedChat((int)dialog_id);
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
}, 700);
|
||||
@@ -362,10 +359,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioPlayStateChanged);
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
|
||||
}
|
||||
|
||||
/*
|
||||
if (currentUser != null) {
|
||||
MessagesController.getInstance().cancelLoadFullUser(currentUser.id);
|
||||
@@ -461,7 +454,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
args.putInt("user_id", contact_ids[0]);
|
||||
}
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
fragment.setPlayProfileAnimation(true);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
else if ( id == ID_DELETE_CHAT)
|
||||
@@ -474,7 +466,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 ) {
|
||||
@@ -486,7 +478,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (id == ID_MUTE) {
|
||||
toggleMute();
|
||||
@@ -505,12 +497,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();
|
||||
@@ -667,11 +654,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
setMeasuredDimension(width, height);
|
||||
|
||||
actionModeTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20);
|
||||
actionModeTextView.setTextSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20);
|
||||
actionModeTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24), MeasureSpec.AT_MOST));
|
||||
|
||||
if (actionModeSubTextView.getVisibility() != GONE) {
|
||||
actionModeSubTextView.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 14 : 16);
|
||||
actionModeSubTextView.setTextSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 14 : 16);
|
||||
actionModeSubTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.AT_MOST));
|
||||
}
|
||||
}
|
||||
@@ -682,14 +669,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
int textTop;
|
||||
if (actionModeSubTextView.getVisibility() != GONE) {
|
||||
textTop = (height / 2 - actionModeTextView.getTextHeight()) / 2 + AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 3);
|
||||
textTop = (height / 2 - actionModeTextView.getTextHeight()) / 2 + AndroidUtilities.dp(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 3);
|
||||
} else {
|
||||
textTop = (height - actionModeTextView.getTextHeight()) / 2;
|
||||
}
|
||||
actionModeTextView.layout(0, textTop, actionModeTextView.getMeasuredWidth(), textTop + actionModeTextView.getTextHeight());
|
||||
|
||||
if (actionModeSubTextView.getVisibility() != GONE) {
|
||||
textTop = height / 2 + (height / 2 - actionModeSubTextView.getTextHeight()) / 2 - AndroidUtilities.dp(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 1);
|
||||
textTop = height / 2 + (height / 2 - actionModeSubTextView.getTextHeight()) / 2 - AndroidUtilities.dp(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 1 : 1);
|
||||
actionModeSubTextView.layout(0, textTop, actionModeSubTextView.getMeasuredWidth(), textTop + actionModeSubTextView.getTextHeight());
|
||||
}
|
||||
}
|
||||
@@ -860,7 +847,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
TextView emptyView = new TextView(context);
|
||||
|
||||
if( m_mrChat.getParamInt(MrChat.MR_CHAT_PARAM_UNPROMOTED, 0)==1 ) {
|
||||
if( m_mrChat.getParamInt(MrChat.MRP_UNPROMOTED, 0)==1 ) {
|
||||
emptyView.setText(context.getString(R.string.MsgNewGroupDraftHint));
|
||||
emptyView.setGravity(Gravity.START);
|
||||
}
|
||||
@@ -1144,8 +1131,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
updateBottomOverlay();
|
||||
|
||||
fixLayoutInternal();
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
@@ -1490,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);
|
||||
@@ -1504,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());
|
||||
}
|
||||
@@ -1913,9 +1898,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
|
||||
if (markAsRead) {
|
||||
if (paused) {
|
||||
readWhenResume = true;
|
||||
markseenWhenResume.put(evt_msg_id, 1);
|
||||
} else {
|
||||
MrMailbox.markseenMsg(evt_msg_id);
|
||||
int msg_ids[] = new int[1];
|
||||
msg_ids[0] = evt_msg_id;
|
||||
MrMailbox.markseenMsgs(msg_ids);
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
}
|
||||
@@ -2251,9 +2238,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
scrollToMessage = null;
|
||||
}
|
||||
paused = false;
|
||||
if (readWhenResume ) {
|
||||
readWhenResume = false;
|
||||
MrMailbox.markseenChat((int)dialog_id);
|
||||
|
||||
int markseenWhenResumeCnt = markseenWhenResume.size();
|
||||
if (markseenWhenResumeCnt>0 ) {
|
||||
int msg_ids[] = new int[markseenWhenResumeCnt];
|
||||
for(int i=0; i<markseenWhenResumeCnt; i++) {
|
||||
msg_ids[i] = markseenWhenResume.keyAt(i);
|
||||
}
|
||||
MrMailbox.markseenMsgs(msg_ids);
|
||||
markseenWhenResume.clear();
|
||||
NotificationsController.getInstance().removeSeenMessages();
|
||||
}
|
||||
|
||||
@@ -2335,24 +2328,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
}
|
||||
}
|
||||
|
||||
private boolean fixLayoutInternal() {
|
||||
/*if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
selectedMessagesCountTextView.setTextSize(18);
|
||||
} else {
|
||||
selectedMessagesCountTextView.setTextSize(20);
|
||||
}*/
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
actionBar.setBackButtonDrawable(new BackDrawable(false));
|
||||
} else {
|
||||
actionBar.setBackButtonDrawable(new BackDrawable(parentLayout == null || parentLayout.fragmentsStack.isEmpty() || parentLayout.fragmentsStack.get(0) == ChatActivity.this || parentLayout.fragmentsStack.size() == 1));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void fixLayout() {
|
||||
if (avatarContainer != null) {
|
||||
avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@@ -2361,7 +2336,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
if (avatarContainer != null) {
|
||||
avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
return fixLayoutInternal();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2375,7 +2350,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) {
|
||||
|
||||
@@ -2396,7 +2371,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
|
||||
@@ -2478,9 +2453,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
args.putInt("chat_id", (int)fwd_chat_id);
|
||||
ChatActivity fragment = new ChatActivity(args);
|
||||
if( presentFragment(fragment, true /*remove last*/) ) {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
removeSelfFromStack();
|
||||
}
|
||||
removeSelfFromStack();
|
||||
}
|
||||
else {
|
||||
dialogsFragment.finishFragment(false);
|
||||
@@ -2702,7 +2675,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user.id);
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
fragment.setPlayProfileAnimation(false);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
}
|
||||
@@ -2769,13 +2741,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());
|
||||
}
|
||||
@@ -2865,6 +2837,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
} else {
|
||||
messageCell.setHighlightedText(null);
|
||||
}
|
||||
|
||||
// mark message as being read
|
||||
int state = mrMsg.getState();
|
||||
if( state == MrMsg.MR_IN_FRESH || state==MrMsg.MR_IN_NOTICED ) {
|
||||
if(paused) {
|
||||
markseenWhenResume.put(msg_id, 1);
|
||||
}
|
||||
else {
|
||||
int msg_ids[] = new int[1];
|
||||
msg_ids[0] = msg_id;
|
||||
MrMailbox.markseenMsgs(msg_ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( view instanceof ChatActionCell )
|
||||
{
|
||||
|
||||
@@ -35,26 +35,18 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.messenger.TLRPC;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
|
||||
public class AvatarDrawable extends Drawable {
|
||||
|
||||
private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private static TextPaint namePaint;
|
||||
private static TextPaint namePaintSmall;
|
||||
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xff8e85ee, 0xff76c84d, 0xff5bb6cc, 0xff549cdd, 0xffd25c99, 0xffb37800}; /* the colors should contrast to typical action bar colors as well as to white (more important, is used as text color)*/
|
||||
|
||||
private static Drawable photoDrawable;
|
||||
private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xff8e85ee, 0xff76c84d, 0xff5bb6cc, 0xff549cdd, 0xffd25c99, 0xffb37800}; /* the colors should contrast to typical action bar colors as well as to white (more important, is used as text color)*/
|
||||
|
||||
private int color;
|
||||
private StaticLayout textLayout;
|
||||
private float textWidth;
|
||||
private float textHeight;
|
||||
private float textLeft;
|
||||
private boolean drawPhoto;
|
||||
private boolean smallStyle;
|
||||
private StringBuilder stringBuilder = new StringBuilder(5);
|
||||
|
||||
public AvatarDrawable() {
|
||||
@@ -64,60 +56,18 @@ public class AvatarDrawable extends Drawable {
|
||||
namePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setColor(0xffffffff);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(20));
|
||||
|
||||
namePaintSmall = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
namePaintSmall.setColor(0xffffffff);
|
||||
namePaintSmall.setTextSize(AndroidUtilities.dp(14));
|
||||
}
|
||||
}
|
||||
|
||||
public AvatarDrawable(TLRPC.User user) {
|
||||
this();
|
||||
if (user != null) {
|
||||
setInfoByName(user.first_name+" "+ user.last_name);
|
||||
}
|
||||
}
|
||||
|
||||
public AvatarDrawable(TLRPC.Chat chat) {
|
||||
this();
|
||||
if (chat != null) {
|
||||
setInfoByName(chat.title);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSmallStyle(boolean value) {
|
||||
smallStyle = value;
|
||||
}
|
||||
|
||||
public static int getColorIndex(int id) {
|
||||
private static int getColorIndex(int id) {
|
||||
return Math.abs(id % arrColors.length);
|
||||
}
|
||||
|
||||
public static int getColorForId(int id) {
|
||||
return arrColors[getColorIndex(id)];
|
||||
}
|
||||
|
||||
public static int getNameColor(String name) {
|
||||
int id = strChecksum(name);
|
||||
return arrColors[getColorIndex(id)];
|
||||
}
|
||||
|
||||
public void setInfoByUser(TLRPC.User user) {
|
||||
if (user != null) {
|
||||
setInfoByName(user.first_name +" "+ user.last_name);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInfoByChat(TLRPC.Chat chat) {
|
||||
if (chat != null) {
|
||||
setInfoByName(chat.title);
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor_(int value) {
|
||||
color = value;
|
||||
}
|
||||
|
||||
private static int strChecksum(String str) {
|
||||
int ret = 0;
|
||||
if( str!=null ) {
|
||||
@@ -130,42 +80,22 @@ public class AvatarDrawable extends Drawable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setInfoByName(String firstName) {
|
||||
String lastName = null;
|
||||
|
||||
int id = strChecksum(firstName);
|
||||
public void setInfoByName(String name) {
|
||||
int id = strChecksum(name);
|
||||
|
||||
color = arrColors[getColorIndex(id)];
|
||||
|
||||
if (firstName == null || firstName.length() == 0) {
|
||||
firstName = lastName;
|
||||
lastName = null;
|
||||
}
|
||||
|
||||
stringBuilder.setLength(0);
|
||||
if (firstName != null && firstName.length() > 0) {
|
||||
stringBuilder.append(firstName.substring(0, 1));
|
||||
}
|
||||
if (lastName != null && lastName.length() > 0) {
|
||||
String lastch = null;
|
||||
for (int a = lastName.length() - 1; a >= 0; a--) {
|
||||
if (lastch != null && lastName.charAt(a) == ' ') {
|
||||
break;
|
||||
}
|
||||
lastch = lastName.substring(a, a + 1);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
stringBuilder.append("\u200C");
|
||||
}
|
||||
stringBuilder.append(lastch);
|
||||
} else if (firstName != null && firstName.length() > 0) {
|
||||
for (int a = firstName.length() - 1; a >= 0; a--) {
|
||||
if (firstName.charAt(a) == ' ') {
|
||||
if (a != firstName.length() - 1 && firstName.charAt(a + 1) != ' ') {
|
||||
if (name != null && name.length() > 0) {
|
||||
stringBuilder.appendCodePoint(name.codePointAt(0));
|
||||
|
||||
for (int a = name.length() - 1; a >= 0; a--) {
|
||||
if (name.charAt(a) == ' ') {
|
||||
if (a != name.length() - 1 && name.charAt(a + 1) != ' ') {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
stringBuilder.append("\u200C");
|
||||
stringBuilder.append("\u200C"); // ZERO WIDTH NON-JOINER - avoids the two letter to melt into a ligature which would be incorrect on the initials
|
||||
}
|
||||
stringBuilder.append(firstName.substring(a + 1, a + 2));
|
||||
stringBuilder.appendCodePoint(name.codePointAt(a + 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -175,7 +105,7 @@ public class AvatarDrawable extends Drawable {
|
||||
if (stringBuilder.length() > 0) {
|
||||
String text = stringBuilder.toString().toUpperCase();
|
||||
try {
|
||||
textLayout = new StaticLayout(text, (smallStyle ? namePaintSmall : namePaint), AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
textLayout = new StaticLayout(text, namePaint, AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (textLayout.getLineCount() > 0) {
|
||||
textLeft = textLayout.getLineLeft(0);
|
||||
textWidth = textLayout.getLineWidth(0);
|
||||
@@ -189,13 +119,6 @@ public class AvatarDrawable extends Drawable {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDrawPhoto(boolean value) {
|
||||
if (value && photoDrawable == null) {
|
||||
photoDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_w);
|
||||
}
|
||||
drawPhoto = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Rect bounds = getBounds();
|
||||
@@ -211,24 +134,17 @@ public class AvatarDrawable extends Drawable {
|
||||
if (textLayout != null) {
|
||||
canvas.translate((size - textWidth) / 2 - textLeft, (size - textHeight) / 2);
|
||||
textLayout.draw(canvas);
|
||||
} else if (drawPhoto && photoDrawable != null) {
|
||||
int x = (size - photoDrawable.getIntrinsicWidth()) / 2;
|
||||
int y = (size - photoDrawable.getIntrinsicHeight()) / 2;
|
||||
photoDrawable.setBounds(x, y, x + photoDrawable.getIntrinsicWidth(), y + photoDrawable.getIntrinsicHeight());
|
||||
photoDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
public void setAlpha(int alpha) { // must be present in non-abstract classes derived from Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
public void setColorFilter(ColorFilter cf) { // must be present in non-abstract classes derived from Drawable
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -149,26 +149,26 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
|
||||
private class EditTextCaption extends EditText {
|
||||
|
||||
private Object editor;
|
||||
private Field editorField;
|
||||
private Drawable[] mCursorDrawable;
|
||||
private Field mCursorDrawableField;
|
||||
//private Object editor;
|
||||
//private Field editorField;
|
||||
//private Drawable[] mCursorDrawable;
|
||||
//private Field mCursorDrawableField;
|
||||
|
||||
public EditTextCaption(Context context) {
|
||||
super(context);
|
||||
|
||||
try {
|
||||
Field field = TextView.class.getDeclaredField("mEditor");
|
||||
field.setAccessible(true);
|
||||
editor = field.get(this);
|
||||
Class editorClass = Class.forName("android.widget.Editor");
|
||||
editorField = editorClass.getDeclaredField("mShowCursor");
|
||||
editorField.setAccessible(true);
|
||||
mCursorDrawableField = editorClass.getDeclaredField("mCursorDrawable");
|
||||
mCursorDrawableField.setAccessible(true);
|
||||
mCursorDrawable = (Drawable[]) mCursorDrawableField.get(editor);
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
//try {
|
||||
//Field field = TextView.class.getDeclaredField("mEditor");
|
||||
//field.setAccessible(true);
|
||||
//editor = field.get(this);
|
||||
//Class editorClass = Class.forName("android.widget.Editor");
|
||||
//editorField = editorClass.getDeclaredField("mShowCursor");
|
||||
//editorField.setAccessible(true);
|
||||
//mCursorDrawableField = editorClass.getDeclaredField("mCursorDrawable");
|
||||
//mCursorDrawableField.setAccessible(true);
|
||||
//mCursorDrawable = (Drawable[]) mCursorDrawableField.get(editor);
|
||||
//} catch (Throwable e) {
|
||||
//}
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@@ -189,10 +189,10 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
try {
|
||||
//try {
|
||||
// the following lines are because otherwise the cursor stops blinking if
|
||||
// the focus was set to another text field in between (eg. search)
|
||||
if (editorField != null && mCursorDrawable != null && mCursorDrawable[0] != null) {
|
||||
/*if (editorField != null && mCursorDrawable != null && mCursorDrawable[0] != null) {
|
||||
long mShowCursor = editorField.getLong(editor);
|
||||
boolean showCursor = (SystemClock.uptimeMillis() - mShowCursor) % (2 * 500) < 500;
|
||||
if (showCursor) {
|
||||
@@ -201,9 +201,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
mCursorDrawable[0].draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}*/
|
||||
//} catch (Throwable e) {
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -575,13 +575,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
||||
mCursorDrawableRes.setAccessible(true);
|
||||
mCursorDrawableRes.set(messageEditText, R.drawable.field_carret);
|
||||
} catch (Exception e) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
if (isChat) {
|
||||
attachButton = new LinearLayout(context);
|
||||
@@ -1415,13 +1408,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();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
parentFragment.showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -757,7 +757,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
|
||||
}
|
||||
|
||||
private void setUseRevealAnimation(boolean value) {
|
||||
if (!value || value && Build.VERSION.SDK_INT >= 18 && !AndroidUtilities.isTablet()) {
|
||||
if (!value || value && Build.VERSION.SDK_INT >= 18) {
|
||||
useRevealAnimation = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
package com.b44t.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
@@ -35,7 +34,6 @@ import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.ContactsController;
|
||||
import com.b44t.messenger.MrChat;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.TLRPC;
|
||||
import com.b44t.ui.ActionBar.ActionBar;
|
||||
import com.b44t.ui.ActionBar.SimpleTextView;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
@@ -88,7 +86,6 @@ public class ChatAvatarContainer extends FrameLayout {
|
||||
}
|
||||
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
fragment.setPlayProfileAnimation(true);
|
||||
parentFragment.presentFragment(fragment);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -159,7 +159,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
pickerView.setSelection(0);
|
||||
}
|
||||
view.getLocationOnScreen(location);
|
||||
int x = emojiSize * pickerView.getSelection() + AndroidUtilities.dp(4 * pickerView.getSelection() - (AndroidUtilities.isTablet() ? 5 : 1));
|
||||
int x = emojiSize * pickerView.getSelection() + AndroidUtilities.dp(4 * pickerView.getSelection() - 1);
|
||||
if (location[0] - x < AndroidUtilities.dp(5)) {
|
||||
x += (location[0] - x) - AndroidUtilities.dp(5);
|
||||
} else if (location[0] - x + popupWidth > AndroidUtilities.displaySize.x - AndroidUtilities.dp(5)) {
|
||||
@@ -168,7 +168,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
int xOffset = -x;
|
||||
int yOffset = view.getTop() < 0 ? view.getTop() : 0;
|
||||
|
||||
pickerView.setEmoji(code, AndroidUtilities.dp(AndroidUtilities.isTablet() ? 30 : 22) - xOffset + (int) AndroidUtilities.dpf2(0.5f));
|
||||
pickerView.setEmoji(code, AndroidUtilities.dp(22) - xOffset + (int) AndroidUtilities.dpf2(0.5f));
|
||||
|
||||
pickerViewPopup.setFocusable(true);
|
||||
pickerViewPopup.showAsDropDown(view, xOffset, -view.getMeasuredHeight() - popupHeight + (view.getMeasuredHeight() - emojiSize) / 2 - yOffset);
|
||||
@@ -264,11 +264,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
}
|
||||
//setImageDrawable(Emoji.getEmojiBigDrawable(code));
|
||||
int bigImgSize;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
bigImgSize = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
}
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
setImageDrawable(TextDrawable.builder().beginConfig().textColor(Color.BLACK).fontSize(bigImgSize).endConfig().buildRect(code, Color.TRANSPARENT));
|
||||
sendEmoji(null);
|
||||
saveEmojiColors();
|
||||
@@ -461,10 +457,10 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), AndroidUtilities.dp(AndroidUtilities.isTablet() ? 60 : 52));
|
||||
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), AndroidUtilities.dp(52));
|
||||
backgroundDrawable.draw(canvas);
|
||||
|
||||
arrowDrawable.setBounds(arrowX - AndroidUtilities.dp(9), AndroidUtilities.dp(AndroidUtilities.isTablet() ? 55.5f : 47.5f), arrowX + AndroidUtilities.dp(9), AndroidUtilities.dp((AndroidUtilities.isTablet() ? 55.5f : 47.5f) + 8));
|
||||
arrowDrawable.setBounds(arrowX - AndroidUtilities.dp(9), AndroidUtilities.dp(47.5f), arrowX + AndroidUtilities.dp(9), AndroidUtilities.dp(47.5f + 8));
|
||||
arrowDrawable.draw(canvas);
|
||||
|
||||
if (currentEmoji != null) {
|
||||
@@ -499,11 +495,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
}
|
||||
|
||||
int bigImgSize;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
bigImgSize = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
}
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
Drawable drawable = TextDrawable.builder().beginConfig().textColor(Color.BLACK).fontSize(bigImgSize).endConfig().buildRect(code, Color.TRANSPARENT);
|
||||
|
||||
//Drawable drawable = Emoji.getEmojiBigDrawable(code);
|
||||
@@ -581,11 +573,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
|
||||
for (int i = 0; i < EmojiData.dataColored.length + 1; i++) {
|
||||
GridView gridView = new GridView(context);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
gridView.setColumnWidth(AndroidUtilities.dp(60));
|
||||
} else {
|
||||
gridView.setColumnWidth(AndroidUtilities.dp(45));
|
||||
}
|
||||
gridView.setColumnWidth(AndroidUtilities.dp(45));
|
||||
gridView.setNumColumns(-1);
|
||||
views.add(gridView);
|
||||
|
||||
@@ -936,9 +924,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
|
||||
addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.START | Gravity.TOP, 0, 48, 0, 0));
|
||||
|
||||
emojiSize = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 40 : 32);
|
||||
emojiSize = AndroidUtilities.dp(32);
|
||||
pickerView = new EmojiColorPickerView(context);
|
||||
pickerViewPopup = new EmojiPopupWindow(pickerView, popupWidth = AndroidUtilities.dp((AndroidUtilities.isTablet() ? 40 : 32) * 6 + 10 + 4 * 5), popupHeight = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 64 : 56));
|
||||
pickerViewPopup = new EmojiPopupWindow(pickerView, popupWidth = AndroidUtilities.dp(32 * 6 + 10 + 4 * 5), popupHeight = AndroidUtilities.dp(56));
|
||||
pickerViewPopup.setOutsideTouchable(true);
|
||||
pickerViewPopup.setClippingEnabled(true);
|
||||
pickerViewPopup.setInputMethodMode(EmojiPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
@@ -1787,11 +1775,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
||||
//imageView.setImageDrawable(Emoji.getEmojiBigDrawable(code));
|
||||
imageView.setTag(code);
|
||||
int bigImgSize;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
bigImgSize = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
}
|
||||
bigImgSize = AndroidUtilities.dp(32);
|
||||
imageView.setImageDrawable(TextDrawable.builder().beginConfig().textColor(Color.BLACK).fontSize(bigImgSize).endConfig().buildRect(coloredCode, Color.TRANSPARENT));
|
||||
return imageView;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@ public class PasscodeView extends FrameLayout {
|
||||
passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
passwordEditText.setTypeface(Typeface.DEFAULT);
|
||||
passwordEditText.setBackgroundDrawable(null);
|
||||
AndroidUtilities.clearCursorDrawable(passwordEditText);
|
||||
passwordFrameLayout.addView(passwordEditText);
|
||||
layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
|
||||
layoutParams.height = LayoutHelper.WRAP_CONTENT;
|
||||
@@ -531,7 +530,7 @@ public class PasscodeView extends FrameLayout {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setView(relativeLayout);
|
||||
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
@@ -666,7 +665,7 @@ public class PasscodeView extends FrameLayout {
|
||||
|
||||
LayoutParams layoutParams;
|
||||
|
||||
if (!AndroidUtilities.isTablet() && getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
|
||||
layoutParams.width = UserConfig.passcodeType == 0 ? width / 2 : width;
|
||||
layoutParams.height = AndroidUtilities.dp(140);
|
||||
@@ -682,16 +681,6 @@ public class PasscodeView extends FrameLayout {
|
||||
} else {
|
||||
int top = 0;
|
||||
int left = 0;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (width > AndroidUtilities.dp(498)) {
|
||||
left = (width - AndroidUtilities.dp(498)) / 2;
|
||||
width = AndroidUtilities.dp(498);
|
||||
}
|
||||
if (height > AndroidUtilities.dp(528)) {
|
||||
top = (height - AndroidUtilities.dp(528)) / 2;
|
||||
height = AndroidUtilities.dp(528);
|
||||
}
|
||||
}
|
||||
layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
|
||||
layoutParams.height = height / 3;
|
||||
layoutParams.width = width;
|
||||
@@ -759,7 +748,7 @@ public class PasscodeView extends FrameLayout {
|
||||
getWindowVisibleDisplayFrame(rect);
|
||||
keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||
|
||||
if (UserConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) {
|
||||
if (UserConfig.passcodeType == 1 && getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
|
||||
int t = 0;
|
||||
if (passwordFrameLayout.getTag() != null) {
|
||||
t = (Integer) passwordFrameLayout.getTag();
|
||||
|
||||
@@ -2292,7 +2292,7 @@ public class PhotoFilterView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
editView.addView(valueSeekBar, LayoutHelper.createFrame(AndroidUtilities.isTablet() ? 498 : LayoutHelper.MATCH_PARENT, 60, AndroidUtilities.isTablet() ? Gravity.CENTER_HORIZONTAL | Gravity.TOP : Gravity.START | Gravity.TOP, 14, 10, 14, 0));
|
||||
editView.addView(valueSeekBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 60, Gravity.START | Gravity.TOP, 14, 10, 14, 0));
|
||||
|
||||
curveLayout = new FrameLayout(context);
|
||||
editView.addView(curveLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 78, Gravity.CENTER_HORIZONTAL));
|
||||
@@ -2699,19 +2699,6 @@ public class PhotoFilterView extends FrameLayout {
|
||||
layoutParams = (LayoutParams) curvesControl.getLayoutParams();
|
||||
layoutParams.height = viewHeight + AndroidUtilities.dp(28);
|
||||
curvesControl.setLayoutParams(layoutParams);
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
int total = AndroidUtilities.dp(86) * 10;
|
||||
layoutParams = (FrameLayout.LayoutParams) recyclerListView.getLayoutParams();
|
||||
if (total < viewWidth) {
|
||||
layoutParams.width = total;
|
||||
layoutParams.leftMargin = (viewWidth - total) / 2;
|
||||
} else {
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.leftMargin = 0;
|
||||
}
|
||||
recyclerListView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Delta Chat Android
|
||||
* (C) 2013-2016 Nikolai Kudashov
|
||||
* (C) 2017 Björn Petersen
|
||||
* Contact: r10s@b44t.com, http://b44t.com
|
||||
*
|
||||
@@ -26,38 +25,30 @@ package com.b44t.ui;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.TLRPC;
|
||||
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.Components.AvatarDrawable;
|
||||
import com.b44t.ui.Components.AvatarUpdater;
|
||||
import com.b44t.ui.Components.BackupImageView;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.Cells.HeaderCell;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
|
||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private int do_what = 0;
|
||||
public final static int CREATE_CONTACT = 1;
|
||||
@@ -65,11 +56,6 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
private EditText nameTextView;
|
||||
private EditText emailTextView;
|
||||
private TLRPC.FileLocation avatar;
|
||||
private TLRPC.InputFile uploadedAvatar;
|
||||
private BackupImageView avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
private String nameToSet = null;
|
||||
private int chat_id; // only used for EDIT_NAME in chats
|
||||
private int user_id;
|
||||
@@ -79,16 +65,12 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
public ContactAddActivity(Bundle args) {
|
||||
super(args);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
avatarUpdater.parentFragment = this;
|
||||
avatarUpdater.delegate = this;
|
||||
avatarUpdater.returnOnly = true;
|
||||
do_what = getArguments().getInt("do_what", 0);
|
||||
user_id = getArguments().getInt("user_id", 0);
|
||||
chat_id = getArguments().getInt("chat_id", 0);
|
||||
@@ -100,8 +82,6 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||
|
||||
avatarUpdater.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,74 +162,22 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
LinearLayout linearLayout = (LinearLayout) fragmentView;
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
linearLayout.addView(frameLayout);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
nameTextView = new EditText(context);
|
||||
|
||||
avatarImage = new BackupImageView(context);
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
|
||||
avatarImage.setImageDrawable(avatarDrawable);
|
||||
frameLayout.addView(avatarImage);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
||||
layoutParams1.width = AndroidUtilities.dp(64);
|
||||
layoutParams1.height = AndroidUtilities.dp(64);
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.bottomMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
|
||||
layoutParams1.gravity = Gravity.TOP | Gravity.START;
|
||||
avatarImage.setLayoutParams(layoutParams1);
|
||||
{
|
||||
//avatarDrawable.setDrawPhoto(true);
|
||||
/* TODO: let the user select a photo for groups (contact photos come from the system's address book)
|
||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
CharSequence[] items;
|
||||
|
||||
if (avatar != null) {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
|
||||
} else {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
|
||||
}
|
||||
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
avatarUpdater.openCamera();
|
||||
} else if (i == 1) {
|
||||
avatarUpdater.openGallery();
|
||||
} else if (i == 2) {
|
||||
avatar = null;
|
||||
uploadedAvatar = null;
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
*/
|
||||
if(do_what==CREATE_CONTACT) {
|
||||
TextView label = HeaderCell.createTextView(context, context.getString(R.string.Name));
|
||||
linearLayout.addView(label, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 18, 18, 18, 0));
|
||||
}
|
||||
else {
|
||||
nameTextView.setHint(context.getString(R.string.Name));
|
||||
}
|
||||
|
||||
nameTextView = new EditText(context);
|
||||
nameTextView.setHint(context.getString(R.string.Name));
|
||||
if (nameToSet != null) {
|
||||
nameTextView.setText(nameToSet);
|
||||
}
|
||||
nameTextView.setMaxLines(4);
|
||||
nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
nameTextView.setHintTextColor(0xff979797);
|
||||
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
|
||||
@@ -257,36 +185,15 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
InputFilter[] inputFilters = new InputFilter[1];
|
||||
inputFilters[0] = new InputFilter.LengthFilter(100);
|
||||
nameTextView.setFilters(inputFilters);
|
||||
AndroidUtilities.clearCursorDrawable(nameTextView);
|
||||
nameTextView.setTextColor(0xff212121);
|
||||
frameLayout.addView(nameTextView);
|
||||
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
|
||||
layoutParams1.gravity = Gravity.CENTER_VERTICAL;
|
||||
nameTextView.setLayoutParams(layoutParams1);
|
||||
nameTextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
updateAvatar();
|
||||
}
|
||||
});
|
||||
linearLayout.addView(nameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 18, do_what==CREATE_CONTACT? 1:18, 18, 0));
|
||||
|
||||
if( do_what==CREATE_CONTACT ) {
|
||||
TextView label = HeaderCell.createTextView(context, context.getString(R.string.EmailAddress));
|
||||
linearLayout.addView(label, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 18, 18, 18, 0));
|
||||
|
||||
emailTextView = new EditText(context);
|
||||
emailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
emailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
emailTextView.setHintTextColor(0xff979797);
|
||||
emailTextView.setTextColor(0xff212121);
|
||||
emailTextView.setMaxLines(4);
|
||||
@@ -294,70 +201,19 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
emailTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
|
||||
emailTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
emailTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
|
||||
emailTextView.setHint(context.getString(R.string.EmailAddress));
|
||||
emailTextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
updateAvatar();
|
||||
}
|
||||
});
|
||||
AndroidUtilities.clearCursorDrawable(emailTextView);
|
||||
linearLayout.addView(emailTextView);
|
||||
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) emailTextView.getLayoutParams();
|
||||
layoutParams2.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams2.topMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.leftMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.rightMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.gravity = Gravity.CENTER_VERTICAL;
|
||||
emailTextView.setLayoutParams(layoutParams2);
|
||||
linearLayout.addView(emailTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 18, 1, 18, 0));
|
||||
}
|
||||
|
||||
updateAvatar();
|
||||
|
||||
nameToSet = null;
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
private void updateAvatar()
|
||||
{
|
||||
String email = null;
|
||||
if( emailTextView != null ) {
|
||||
email = emailTextView.length() > 0? emailTextView.getText().toString() : null;
|
||||
}
|
||||
else if( user_id != 0 ) {
|
||||
email = MrMailbox.getContact(user_id).getAddr();
|
||||
}
|
||||
ContactsController.setupAvatarByStrings(avatarImage, avatarImage.imageReceiver, avatarDrawable,
|
||||
email,
|
||||
nameTextView.length() > 0 ? nameTextView.getText().toString() : "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
||||
Toast.makeText(getParentActivity(), ApplicationLoader.applicationContext.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
|
||||
args.putString("path", avatarUpdater.currentPicturePath);
|
||||
}
|
||||
if (nameTextView != null) {
|
||||
String text = nameTextView.getText().toString();
|
||||
if (text != null && text.length() != 0) {
|
||||
@@ -368,9 +224,6 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
@Override
|
||||
public void restoreSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null) {
|
||||
avatarUpdater.currentPicturePath = args.getString("path");
|
||||
}
|
||||
String text = args.getString("nameTextView");
|
||||
if (text != null) {
|
||||
if (nameTextView != null) {
|
||||
@@ -383,7 +236,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
|
||||
@Override
|
||||
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
if (isOpen) {
|
||||
if (isOpen && nameTextView!=null) {
|
||||
nameTextView.requestFocus();
|
||||
AndroidUtilities.showKeyboard(nameTextView);
|
||||
}
|
||||
|
||||
@@ -291,7 +291,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
userSelectEditText.setPadding(0, 0, 0, 0);
|
||||
userSelectEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
userSelectEditText.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
|
||||
AndroidUtilities.clearCursorDrawable(userSelectEditText);
|
||||
frameLayout.addView(userSelectEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.START, 10, 0, 10, 0));
|
||||
|
||||
userSelectEditText.setHint(ApplicationLoader.applicationContext.getString(R.string.Search));
|
||||
@@ -429,7 +428,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);
|
||||
@@ -440,7 +439,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());
|
||||
}
|
||||
|
||||
@@ -36,12 +36,8 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Outline;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
@@ -53,7 +49,6 @@ import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
@@ -64,24 +59,20 @@ import com.b44t.messenger.MrChat;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.MrMsg;
|
||||
import com.b44t.messenger.Utilities;
|
||||
import com.b44t.messenger.browser.Browser;
|
||||
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.ActionBar.DrawerLayoutContainer;
|
||||
import com.b44t.ui.Adapters.DialogsAdapter;
|
||||
import com.b44t.ui.Adapters.DialogsSearchAdapter;
|
||||
import com.b44t.ui.Adapters.DrawerLayoutAdapter;
|
||||
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.ActionBar.MenuDrawable;
|
||||
import com.b44t.ui.Components.EmptyTextProgressView;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.Components.RecyclerListView;
|
||||
@@ -129,6 +120,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
ActionBarMenuItem headerItem;
|
||||
|
||||
private static final int ID_LOCK_APP = 1;
|
||||
private static final int ID_NEW_CHAT = 2;
|
||||
private static final int ID_NEW_GROUP= 3;
|
||||
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);
|
||||
@@ -157,7 +152,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.contactsDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.openedChatChanged);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageSendError);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didSetPasscode);
|
||||
@@ -177,7 +171,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.contactsDidLoaded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.openedChatChanged);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messageSendError);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didSetPasscode);
|
||||
@@ -199,13 +192,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
if (!onlySelect ) {
|
||||
passcodeItem = menu.addItem(ID_LOCK_APP, R.drawable.lock_close);
|
||||
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( !DrawerLayoutContainer.USE_DRAWER && headerItem!=null ) {
|
||||
if( headerItem!=null ) {
|
||||
headerItem.setVisibility(View.GONE);
|
||||
actionBar.setBackButtonDrawable(new BackDrawable(false));
|
||||
}
|
||||
@@ -225,7 +218,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
@Override
|
||||
public void onSearchCollapse() {
|
||||
if( !DrawerLayoutContainer.USE_DRAWER && headerItem!=null ) {
|
||||
if( headerItem!=null ) {
|
||||
headerItem.setVisibility(View.VISIBLE);
|
||||
actionBar.setBackButtonDrawable(null);
|
||||
}
|
||||
@@ -279,20 +272,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setTitle(onlySelectTitle);
|
||||
} else {
|
||||
if( DrawerLayoutContainer.USE_DRAWER ) {
|
||||
actionBar.setBackButtonDrawable(new MenuDrawable());
|
||||
}
|
||||
actionBar.setTitle(ApplicationLoader.applicationContext.getString(R.string.AppName));
|
||||
}
|
||||
actionBar.setAllowOverlayTitle(true);
|
||||
|
||||
if( !DrawerLayoutContainer.USE_DRAWER ) {
|
||||
headerItem = menu.addItem(0, R.drawable.ic_ab_other);
|
||||
headerItem.addSubItem(DrawerLayoutAdapter.ROW_NEW_CHAT, ApplicationLoader.applicationContext.getString(R.string.NewChat), 0);
|
||||
headerItem.addSubItem(DrawerLayoutAdapter.ROW_NEW_GROUP, ApplicationLoader.applicationContext.getString(R.string.NewGroup), 0);
|
||||
headerItem.addSubItem(DrawerLayoutAdapter.ROW_DEADDROP, ApplicationLoader.applicationContext.getString(R.string.Deaddrop), 0);
|
||||
headerItem.addSubItem(DrawerLayoutAdapter.ROW_SETTINGS, ApplicationLoader.applicationContext.getString(R.string.Settings), 0);
|
||||
}
|
||||
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
|
||||
@@ -300,8 +288,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
if (id == -1) {
|
||||
if (onlySelect) {
|
||||
finishFragment();
|
||||
} else if (parentLayout != null) {
|
||||
parentLayout.getDrawerLayoutContainer().openDrawer(false);
|
||||
}
|
||||
} else if (id == ID_LOCK_APP) {
|
||||
|
||||
@@ -330,20 +316,20 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
else if( !DrawerLayoutContainer.USE_DRAWER ) {
|
||||
if (id == DrawerLayoutAdapter.ROW_NEW_CHAT) {
|
||||
else {
|
||||
if (id == ID_NEW_CHAT) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactsActivity.SELECT_CONTACT_FOR_NEW_CHAT);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
} else if (id == DrawerLayoutAdapter.ROW_NEW_GROUP) {
|
||||
} else if (id == ID_NEW_GROUP) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactsActivity.SELECT_CONTACTS_FOR_NEW_GROUP);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
} else if (id == DrawerLayoutAdapter.ROW_DEADDROP) {
|
||||
} else if (id == ID_DEADDROP) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", MrChat.MR_CHAT_ID_DEADDROP);
|
||||
presentFragment(new ChatActivity(args));
|
||||
} else if (id == DrawerLayoutAdapter.ROW_SETTINGS) {
|
||||
} else if (id == ID_SETTINGS) {
|
||||
presentFragment(new SettingsActivity());
|
||||
}
|
||||
}
|
||||
@@ -411,16 +397,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
args.putInt("message_id", message_id);
|
||||
}
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (openedDialogId == dialog_id && adapter != dialogsSearchAdapter) {
|
||||
return;
|
||||
}
|
||||
if (dialogsAdapter != null) {
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
||||
updateVisibleRows(MrMailbox.UPDATE_MASK_SELECT_DIALOG);
|
||||
}
|
||||
}
|
||||
|
||||
presentFragment(new ChatActivity(args));
|
||||
}
|
||||
}
|
||||
@@ -539,9 +515,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
});
|
||||
|
||||
dialogsAdapter = new DialogsAdapter(context);
|
||||
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||
}
|
||||
listView.setAdapter(dialogsAdapter);
|
||||
dialogsSearchAdapter = new DialogsSearchAdapter(context);
|
||||
|
||||
@@ -615,14 +588,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();
|
||||
@@ -747,22 +720,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
updateVisibleRows((Integer) args[0]);
|
||||
} else if (id == NotificationCenter.contactsDidLoaded) {
|
||||
updateVisibleRows(0);
|
||||
} else if (id == NotificationCenter.openedChatChanged) {
|
||||
if ( AndroidUtilities.isTablet()) {
|
||||
boolean close = (Boolean) args[1];
|
||||
long dialog_id = (Long) args[0];
|
||||
if (close) {
|
||||
if (dialog_id == openedDialogId) {
|
||||
openedDialogId = 0;
|
||||
}
|
||||
} else {
|
||||
openedDialogId = dialog_id;
|
||||
}
|
||||
if (dialogsAdapter != null) {
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||
}
|
||||
updateVisibleRows(MrMailbox.UPDATE_MASK_SELECT_DIALOG);
|
||||
}
|
||||
} else if (id == NotificationCenter.notificationsSettingsUpdated) {
|
||||
updateVisibleRows(0);
|
||||
} else if ( id == NotificationCenter.messageSendError) {
|
||||
@@ -778,11 +735,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
if (UserConfig.passcodeHash.length() != 0 && !searching) {
|
||||
passcodeItem.setVisibility(View.VISIBLE);
|
||||
if (UserConfig.appLocked) {
|
||||
passcodeItem.setIcon(R.drawable.lock_close);
|
||||
} else {
|
||||
passcodeItem.setIcon(R.drawable.lock_open);
|
||||
}
|
||||
} else {
|
||||
passcodeItem.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -811,13 +763,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
|
||||
DialogCell cell = (DialogCell) child;
|
||||
if ((mask & MrMailbox.UPDATE_MASK_NEW_MESSAGE) != 0) {
|
||||
cell.checkCurrentDialogIndex();
|
||||
if ( AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
} else if ((mask & MrMailbox.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
||||
if ( AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
;
|
||||
} else {
|
||||
cell.update(mask);
|
||||
}
|
||||
@@ -855,7 +802,7 @@ 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) {
|
||||
|
||||
@@ -368,7 +368,7 @@ public class DocumentSelectActivity extends BaseFragment {
|
||||
if (selectedMessagesCountTextView == null) {
|
||||
return;
|
||||
}
|
||||
if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
selectedMessagesCountTextView.setTextSize(18);
|
||||
} else {
|
||||
selectedMessagesCountTextView.setTextSize(20);
|
||||
|
||||
@@ -26,10 +26,8 @@ package com.b44t.ui;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@@ -42,12 +40,8 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
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.TLRPC;
|
||||
import com.b44t.messenger.NotificationCenter;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.Adapters.BaseFragmentAdapter;
|
||||
@@ -55,41 +49,29 @@ 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.Components.AvatarDrawable;
|
||||
import com.b44t.ui.Components.AvatarUpdater;
|
||||
import com.b44t.ui.Components.BackupImageView;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
||||
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private ListAdapter listAdapter;
|
||||
private ListView listView;
|
||||
private EditText nameTextView;
|
||||
private TLRPC.FileLocation avatar;
|
||||
private TLRPC.InputFile uploadedAvatar;
|
||||
private ArrayList<Integer> selectedContacts;
|
||||
private BackupImageView avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
private String nameToSet = null;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
public GroupCreateFinalActivity(Bundle args) {
|
||||
super(args);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
avatarUpdater.parentFragment = this;
|
||||
avatarUpdater.delegate = this;
|
||||
avatarUpdater.returnOnly = true;
|
||||
selectedContacts = getArguments().getIntegerArrayList("result"); /* may be empty - in this case a group only with SELF is created */
|
||||
if( selectedContacts == null ) { selectedContacts = new ArrayList<>(); }
|
||||
selectedContacts.add(MrContact.MR_CONTACT_ID_SELF);
|
||||
@@ -100,7 +82,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||
avatarUpdater.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,9 +129,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putInt("chat_id", chat_id);
|
||||
presentFragment(new ChatActivity(args2), true);
|
||||
if (uploadedAvatar != null) {
|
||||
//MessagesController.getInstance().changeChatAvatar(chat_id, uploadedAvatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -170,59 +148,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
|
||||
avatarImage = new BackupImageView(context);
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
|
||||
//avatarDrawable.setInfoByName("?");
|
||||
avatarImage.setImageDrawable(avatarDrawable);
|
||||
frameLayout.addView(avatarImage);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
||||
layoutParams1.width = AndroidUtilities.dp(64);
|
||||
layoutParams1.height = AndroidUtilities.dp(64);
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.bottomMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
|
||||
layoutParams1.gravity = Gravity.TOP | Gravity.START;
|
||||
avatarImage.setLayoutParams(layoutParams1);
|
||||
{
|
||||
//avatarDrawable.setDrawPhoto(true);
|
||||
/* TODO: let the user select a photo for the group
|
||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
CharSequence[] items;
|
||||
|
||||
if (avatar != null) {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
|
||||
} else {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
|
||||
}
|
||||
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
avatarUpdater.openCamera();
|
||||
} else if (i == 1) {
|
||||
avatarUpdater.openGallery();
|
||||
} else if (i == 2) {
|
||||
avatar = null;
|
||||
uploadedAvatar = null;
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
nameTextView = new EditText(context);
|
||||
nameTextView.setHint(context.getString(R.string.EnterGroupNamePlaceholder));
|
||||
if (nameToSet != null) {
|
||||
@@ -231,7 +156,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
}
|
||||
nameTextView.setMaxLines(4);
|
||||
nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.START);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
nameTextView.setHintTextColor(0xff979797);
|
||||
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
|
||||
@@ -239,34 +164,17 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
InputFilter[] inputFilters = new InputFilter[1];
|
||||
inputFilters[0] = new InputFilter.LengthFilter(100);
|
||||
nameTextView.setFilters(inputFilters);
|
||||
AndroidUtilities.clearCursorDrawable(nameTextView);
|
||||
nameTextView.setTextColor(0xff212121);
|
||||
frameLayout.addView(nameTextView);
|
||||
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(18);
|
||||
layoutParams1.bottomMargin = AndroidUtilities.dp(18);
|
||||
layoutParams1.leftMargin = AndroidUtilities.dp(18);
|
||||
layoutParams1.rightMargin = AndroidUtilities.dp(18);
|
||||
layoutParams1.gravity = Gravity.CENTER_VERTICAL;
|
||||
nameTextView.setLayoutParams(layoutParams1);
|
||||
{
|
||||
nameTextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
updateAvatar();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
GreySectionCell sectionCell = new GreySectionCell(context);
|
||||
sectionCell.setText(context.getResources().getQuantityString(R.plurals.Members, selectedContacts.size(), selectedContacts.size()));
|
||||
@@ -282,45 +190,16 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
listView.setLayoutParams(layoutParams);
|
||||
|
||||
updateAvatar();
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
private void updateAvatar()
|
||||
{
|
||||
ContactsController.setupAvatarByStrings(avatarImage, avatarImage.imageReceiver, avatarDrawable, null,
|
||||
nameTextView.length() > 0 ? nameTextView.getText().toString() : "?");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
||||
Toast.makeText(getParentActivity(), ApplicationLoader.applicationContext.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
/*
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
uploadedAvatar = file;
|
||||
avatar = small.location;
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
if (createAfterUpload) {
|
||||
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, null, chatType, GroupCreateFinalActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
|
||||
args.putString("path", avatarUpdater.currentPicturePath);
|
||||
}
|
||||
if (nameTextView != null) {
|
||||
String text = nameTextView.getText().toString();
|
||||
if (text != null && text.length() != 0) {
|
||||
@@ -331,9 +210,6 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
|
||||
@Override
|
||||
public void restoreSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null) {
|
||||
avatarUpdater.currentPicturePath = args.getString("path");
|
||||
}
|
||||
String text = args.getString("nameTextView");
|
||||
if (text != null) {
|
||||
if (nameTextView != null) {
|
||||
@@ -346,7 +222,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
|
||||
|
||||
@Override
|
||||
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
if (isOpen) {
|
||||
if (isOpen && nameTextView!=null) {
|
||||
nameTextView.requestFocus();
|
||||
AndroidUtilities.showKeyboard(nameTextView);
|
||||
}
|
||||
|
||||
@@ -1,409 +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.ui;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.BuildConfig;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public class IntroActivity extends Activity {
|
||||
|
||||
private ViewPager viewPager;
|
||||
private ImageView topImage1;
|
||||
private ImageView topImage2;
|
||||
private ViewGroup bottomPages;
|
||||
private int lastPage = 0;
|
||||
private boolean justCreated = false;
|
||||
private boolean startPressed = false;
|
||||
private int[] icons;
|
||||
private int[] titles;
|
||||
private int[] messages;
|
||||
|
||||
private boolean isAbout = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(R.style.Theme_MessengerProj);
|
||||
super.onCreate(savedInstanceState);
|
||||
Theme.loadRecources(this);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if( extras != null && extras.getBoolean("com.b44t.ui.IntroActivity.isAbout") ) {
|
||||
isAbout = true;
|
||||
}
|
||||
|
||||
float heightOnLandscape = min(AndroidUtilities.displaySize.x,AndroidUtilities.displaySize.y)/AndroidUtilities.density;
|
||||
if( heightOnLandscape < 450 ) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
setContentView(R.layout.intro_layout);
|
||||
|
||||
if (LocaleController.isRTL) {
|
||||
icons = new int[]{
|
||||
R.drawable.intro7,
|
||||
R.drawable.intro6,
|
||||
R.drawable.intro5,
|
||||
R.drawable.intro4,
|
||||
R.drawable.intro3,
|
||||
R.drawable.intro2,
|
||||
R.drawable.intro1
|
||||
};
|
||||
titles = new int[]{
|
||||
R.string.Intro7Headline,
|
||||
R.string.Intro6Headline,
|
||||
R.string.Intro5Headline,
|
||||
R.string.Intro4Headline,
|
||||
R.string.Intro3Headline,
|
||||
R.string.Intro2Headline,
|
||||
R.string.Intro1Headline
|
||||
};
|
||||
messages = new int[]{
|
||||
R.string.Intro7Message,
|
||||
R.string.Intro6Message,
|
||||
R.string.Intro5Message,
|
||||
R.string.Intro4Message,
|
||||
R.string.Intro3Message,
|
||||
R.string.Intro2Message,
|
||||
R.string.Intro1Message
|
||||
};
|
||||
} else {
|
||||
icons = new int[]{
|
||||
R.drawable.intro1,
|
||||
R.drawable.intro2,
|
||||
R.drawable.intro3,
|
||||
R.drawable.intro4,
|
||||
R.drawable.intro5,
|
||||
R.drawable.intro6,
|
||||
R.drawable.intro7
|
||||
};
|
||||
titles = new int[]{
|
||||
R.string.Intro1Headline,
|
||||
R.string.Intro2Headline,
|
||||
R.string.Intro3Headline,
|
||||
R.string.Intro4Headline,
|
||||
R.string.Intro5Headline,
|
||||
R.string.Intro6Headline,
|
||||
R.string.Intro7Headline
|
||||
};
|
||||
messages = new int[]{
|
||||
R.string.Intro1Message,
|
||||
R.string.Intro2Message,
|
||||
R.string.Intro3Message,
|
||||
R.string.Intro4Message,
|
||||
R.string.Intro5Message,
|
||||
R.string.Intro6Message,
|
||||
R.string.Intro7Message
|
||||
};
|
||||
}
|
||||
viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
|
||||
|
||||
Button startMessagingButton = (Button) findViewById(R.id.start_messaging_button);
|
||||
Button detailsButton = (Button) findViewById(R.id.details_button);
|
||||
if( isAbout ) {
|
||||
startMessagingButton.setText(ApplicationLoader.applicationContext.getString(R.string.OK));
|
||||
detailsButton.setText(ApplicationLoader.applicationContext.getString(R.string.Info));
|
||||
detailsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new AlertDialog.Builder(IntroActivity.this)
|
||||
.setTitle(ApplicationLoader.applicationContext.getString(R.string.AppName) + " v" + getVersion())
|
||||
.setMessage("© 2017 Delta Chat contributors" + "\n\n" + MrMailbox.getInfo() + "\n\n" + getAndroidInfo())
|
||||
.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
startMessagingButton.setText(ApplicationLoader.applicationContext.getString(R.string.IntroStartMessaging));
|
||||
detailsButton.setVisibility(View.GONE);
|
||||
}
|
||||
startMessagingButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(!isAbout) {
|
||||
if(startPressed) {
|
||||
return;
|
||||
}
|
||||
startPressed = true;
|
||||
Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
|
||||
intent2.putExtra("fromIntro", true);
|
||||
startActivity(intent2);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
topImage1 = (ImageView) findViewById(R.id.icon_image1);
|
||||
topImage2 = (ImageView) findViewById(R.id.icon_image2);
|
||||
bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
|
||||
topImage2.setVisibility(View.GONE);
|
||||
viewPager.setAdapter(new IntroAdapter());
|
||||
viewPager.setPageMargin(0);
|
||||
viewPager.setOffscreenPageLimit(1);
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
|
||||
if (lastPage != viewPager.getCurrentItem()) {
|
||||
lastPage = viewPager.getCurrentItem();
|
||||
|
||||
final ImageView fadeoutImage;
|
||||
final ImageView fadeinImage;
|
||||
if (topImage1.getVisibility() == View.VISIBLE) {
|
||||
fadeoutImage = topImage1;
|
||||
fadeinImage = topImage2;
|
||||
|
||||
} else {
|
||||
fadeoutImage = topImage2;
|
||||
fadeinImage = topImage1;
|
||||
}
|
||||
|
||||
fadeinImage.bringToFront();
|
||||
fadeinImage.setImageResource(icons[lastPage]);
|
||||
fadeinImage.clearAnimation();
|
||||
fadeoutImage.clearAnimation();
|
||||
|
||||
Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_out);
|
||||
outAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
fadeoutImage.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this, R.anim.icon_anim_fade_in);
|
||||
inAnimation.setAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
fadeinImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
fadeoutImage.startAnimation(outAnimation);
|
||||
fadeinImage.startAnimation(inAnimation);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
justCreated = true;
|
||||
}
|
||||
|
||||
public static String getVersion()
|
||||
{
|
||||
try {
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
return pInfo.versionName;
|
||||
}
|
||||
catch(Exception e) {
|
||||
return "ErrVersion";
|
||||
}
|
||||
}
|
||||
|
||||
private String getAndroidInfo()
|
||||
{
|
||||
String abi = "ErrAbi";
|
||||
int versionCode = 0, ignoreBatteryOptimizations = -1;
|
||||
try {
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
versionCode = pInfo.versionCode;
|
||||
switch (versionCode % 10) {
|
||||
case 0:
|
||||
abi = "arm";
|
||||
break;
|
||||
case 1:
|
||||
abi = "arm-v7a";
|
||||
break;
|
||||
case 2:
|
||||
abi = "x86";
|
||||
break;
|
||||
case 3:
|
||||
abi = "universal";
|
||||
break;
|
||||
}
|
||||
if( Build.VERSION.SDK_INT >= 23 ) {
|
||||
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
ignoreBatteryOptimizations = pm.isIgnoringBatteryOptimizations(ApplicationLoader.applicationContext.getPackageName())? 1 : 0;
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
||||
return "SDK_INT=" + Build.VERSION.SDK_INT
|
||||
+ "\nMANUFACTURER=" + Build.MANUFACTURER
|
||||
+ "\nMODEL=" + Build.MODEL
|
||||
+ "\nAPPLICATION_ID=" + BuildConfig.APPLICATION_ID
|
||||
+ "\nBUILD_TYPE=" + BuildConfig.BUILD_TYPE
|
||||
+ "\nABI=" + abi // ABI = Application Binary Interface
|
||||
+ "\nignoreBatteryOptimizations=" + ignoreBatteryOptimizations
|
||||
+ "\nversionCode=" + versionCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (justCreated) {
|
||||
if (LocaleController.isRTL) {
|
||||
viewPager.setCurrentItem(6);
|
||||
lastPage = 6;
|
||||
} else {
|
||||
viewPager.setCurrentItem(0);
|
||||
lastPage = 0;
|
||||
}
|
||||
justCreated = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private class IntroAdapter extends PagerAdapter {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = View.inflate(container.getContext(), R.layout.intro_view_layout, null);
|
||||
TextView headerTextView = (TextView) view.findViewById(R.id.header_text);
|
||||
TextView messageTextView = (TextView) view.findViewById(R.id.message_text);
|
||||
container.addView(view, 0);
|
||||
|
||||
headerTextView.setText(getString(titles[position]));
|
||||
messageTextView.setText(AndroidUtilities.replaceTags(getString(messages[position])));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
super.setPrimaryItem(container, position, object);
|
||||
int count = bottomPages.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = bottomPages.getChildAt(a);
|
||||
if (a == position) {
|
||||
child.setBackgroundColor(0xff2ca5e0);
|
||||
} else {
|
||||
child.setBackgroundColor(0xffbbbbbb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view.equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState(Parcelable arg0, ClassLoader arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable saveState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
super.unregisterDataSetObserver(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,6 @@ import android.content.ContentResolver;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.net.MailTo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@@ -44,37 +42,25 @@ import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ActionMode;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
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.MrChat;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.SendMessagesHelper;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.messenger.NotificationCenter;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.messenger.browser.Browser;
|
||||
import com.b44t.messenger.UserConfig;
|
||||
import com.b44t.ui.Adapters.DrawerLayoutAdapter;
|
||||
import com.b44t.ui.ActionBar.ActionBarLayout;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.ActionBar.DrawerLayoutContainer;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.Components.PasscodeView;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
@@ -97,18 +83,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
private ArrayList<String> documentsOriginalPathsArray;
|
||||
private ArrayList<Integer> contactsToSend;
|
||||
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
|
||||
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
|
||||
private static ArrayList<BaseFragment> rightFragmentsStack = new ArrayList<>();
|
||||
private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener;
|
||||
|
||||
private ActionBarLayout actionBarLayout;
|
||||
private ActionBarLayout layersActionBarLayout;
|
||||
private ActionBarLayout rightActionBarLayout;
|
||||
private FrameLayout shadowTablet;
|
||||
private FrameLayout shadowTabletSide;
|
||||
private ImageView backgroundTablet;
|
||||
protected DrawerLayoutContainer drawerLayoutContainer;
|
||||
private DrawerLayoutAdapter drawerLayoutAdapter;
|
||||
protected LaunchLayoutContainer launchLayoutContainer;
|
||||
private PasscodeView passcodeView;
|
||||
private AlertDialog visibleDialog;
|
||||
|
||||
@@ -116,8 +94,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
private boolean passcodeSaveIntentIsNew;
|
||||
private boolean passcodeSaveIntentIsRestore;
|
||||
|
||||
private boolean tabletFullSize;
|
||||
|
||||
private Runnable lockRunnable;
|
||||
|
||||
@Override
|
||||
@@ -126,7 +102,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
if( MrMailbox.isConfigured()==0 ) {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && !intent.getBooleanExtra("fromIntro", false)) {
|
||||
Intent intent2 = new Intent(this, IntroActivity.class);
|
||||
Intent intent2 = new Intent(this, WelcomeActivity.class);
|
||||
startActivity(intent2);
|
||||
super.onCreate(savedInstanceState);
|
||||
finish();
|
||||
@@ -152,188 +128,18 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
|
||||
actionBarLayout = new ActionBarLayout(this);
|
||||
|
||||
drawerLayoutContainer = new DrawerLayoutContainer(this);
|
||||
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
launchLayoutContainer = new LaunchLayoutContainer(this);
|
||||
setContentView(launchLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
launchLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
||||
RelativeLayout launchLayout = new RelativeLayout(this);
|
||||
drawerLayoutContainer.addView(launchLayout);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.MATCH_PARENT;
|
||||
launchLayout.setLayoutParams(layoutParams1);
|
||||
|
||||
backgroundTablet = new ImageView(this);
|
||||
backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
backgroundTablet.setImageResource(R.drawable.background_hd);
|
||||
launchLayout.addView(backgroundTablet);
|
||||
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
backgroundTablet.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
launchLayout.addView(actionBarLayout);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
rightActionBarLayout = new ActionBarLayout(this);
|
||||
launchLayout.addView(rightActionBarLayout);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams)rightActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = AndroidUtilities.dp(320);
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
rightActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
rightActionBarLayout.init(rightFragmentsStack);
|
||||
rightActionBarLayout.setDelegate(this);
|
||||
|
||||
shadowTabletSide = new FrameLayout(this);
|
||||
shadowTabletSide.setBackgroundColor(0x40295274);
|
||||
launchLayout.addView(shadowTabletSide);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams();
|
||||
relativeLayoutParams.width = AndroidUtilities.dp(1);
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
shadowTabletSide.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
shadowTablet = new FrameLayout(this);
|
||||
shadowTablet.setVisibility(View.GONE);
|
||||
shadowTablet.setBackgroundColor(0x7F000000);
|
||||
launchLayout.addView(shadowTablet);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
shadowTablet.setLayoutParams(relativeLayoutParams);
|
||||
shadowTablet.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
int location[] = new int[2];
|
||||
layersActionBarLayout.getLocationOnScreen(location);
|
||||
int viewX = location[0];
|
||||
int viewY = location[1];
|
||||
|
||||
if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
|
||||
return false;
|
||||
} else {
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
shadowTablet.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
layersActionBarLayout = new ActionBarLayout(this);
|
||||
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
|
||||
layersActionBarLayout.setBackgroundView(shadowTablet);
|
||||
layersActionBarLayout.setUseAlphaAnimations(true);
|
||||
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
|
||||
launchLayout.addView(layersActionBarLayout);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = AndroidUtilities.dp(530);
|
||||
relativeLayoutParams.height = AndroidUtilities.dp(528);
|
||||
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
layersActionBarLayout.init(layerFragmentsStack);
|
||||
layersActionBarLayout.setDelegate(this);
|
||||
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
||||
layersActionBarLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
ListView listView = new ListView(this) {
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
listView.setBackgroundColor(0xffffffff);
|
||||
listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this));
|
||||
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
|
||||
listView.setDivider(null);
|
||||
listView.setDividerHeight(0);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
drawerLayoutContainer.setDrawerLayout(listView);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
||||
Point screenSize = AndroidUtilities.getRealScreenSize();
|
||||
|
||||
// Set the width of the drawer
|
||||
layoutParams.width = AndroidUtilities.isTablet() ?
|
||||
AndroidUtilities.dp(285)
|
||||
: Math.min( AndroidUtilities.dp(285), Math.min(screenSize.x,screenSize.y)-AndroidUtilities.dp(56) );
|
||||
|
||||
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
listView.setLayoutParams(layoutParams);
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == DrawerLayoutAdapter.ROW_NEW_CHAT) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactsActivity.SELECT_CONTACT_FOR_NEW_CHAT);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
else if (position == DrawerLayoutAdapter.ROW_NEW_GROUP) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactsActivity.SELECT_CONTACTS_FOR_NEW_GROUP);
|
||||
presentFragment(new ContactsActivity(args));
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
else if (position == DrawerLayoutAdapter.ROW_INVITE) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_TEXT, MrMailbox.getInviteText());
|
||||
startActivity(Intent.createChooser(intent, ApplicationLoader.applicationContext.getString(R.string.InviteMenuEntry)));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
else if (position == DrawerLayoutAdapter.ROW_DEADDROP) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", MrChat.MR_CHAT_ID_DEADDROP);
|
||||
presentFragment(new ChatActivity(args));
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
else if (position == DrawerLayoutAdapter.ROW_SETTINGS) {
|
||||
presentFragment(new SettingsActivity());
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
else if (position == DrawerLayoutAdapter.ROW_FAQ) {
|
||||
String helpUrl = ApplicationLoader.applicationContext.getString(R.string.HelpUrl);
|
||||
Browser.openUrl(LaunchActivity.this, helpUrl);
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
|
||||
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
||||
actionBarLayout.init(mainFragmentsStack);
|
||||
actionBarLayout.setDelegate(this);
|
||||
|
||||
ApplicationLoader.loadWallpaper();
|
||||
|
||||
passcodeView = new PasscodeView(this);
|
||||
drawerLayoutContainer.addView(passcodeView);
|
||||
launchLayoutContainer.addView(passcodeView);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) passcodeView.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.MATCH_PARENT;
|
||||
@@ -349,10 +155,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("fromIntro", true);
|
||||
actionBarLayout.addFragmentToStack(new SettingsAccountActivity(args));
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||
} else {
|
||||
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -403,12 +207,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
boolean allowOpen = true;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
allowOpen = actionBarLayout.fragmentsStack.size() <= 1 && layersActionBarLayout.fragmentsStack.isEmpty();
|
||||
}
|
||||
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
|
||||
}
|
||||
|
||||
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
||||
@@ -437,7 +235,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
}
|
||||
passcodeView.onShow();
|
||||
UserConfig.isWaitingForPasscodeEnter = true;
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||
passcodeView.setDelegate(new PasscodeView.PasscodeViewDelegate() {
|
||||
@Override
|
||||
public void didAcceptedPassword() {
|
||||
@@ -446,12 +243,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true);
|
||||
passcodeSaveIntent = null;
|
||||
}
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
actionBarLayout.showLastFragment();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.showLastFragment();
|
||||
rightActionBarLayout.showLastFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -785,7 +577,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));
|
||||
@@ -799,7 +591,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();
|
||||
}
|
||||
@@ -814,25 +606,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
}
|
||||
else if (showDialogsList)
|
||||
{
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
actionBarLayout.removeAllFragments();
|
||||
} else {
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(false);
|
||||
}
|
||||
}
|
||||
actionBarLayout.removeAllFragments();
|
||||
pushOpened = false;
|
||||
isNew = false;
|
||||
}
|
||||
else if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null || documentsUrisArray != null)
|
||||
{
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
if (dialogId == 0) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
@@ -842,24 +622,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
DialogsActivity fragment = new DialogsActivity(args);
|
||||
fragment.setDelegate(this);
|
||||
boolean removeLast;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
removeLast = layersActionBarLayout.fragmentsStack.size() > 0 && layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1) instanceof DialogsActivity;
|
||||
} else {
|
||||
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 DialogsActivity;
|
||||
actionBarLayout.presentFragment(fragment, removeLast, true, true);
|
||||
pushOpened = true;
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto(false, true);
|
||||
}
|
||||
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBarLayout.showLastFragment();
|
||||
rightActionBarLayout.showLastFragment();
|
||||
} else {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
} else {
|
||||
didSelectDialog(null, dialogId, false);
|
||||
}
|
||||
@@ -867,23 +636,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
|
||||
if (!pushOpened && !isNew)
|
||||
{
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
actionBarLayout.addFragmentToStack(new DialogsActivity(null));
|
||||
}
|
||||
actionBarLayout.showLastFragment();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.showLastFragment();
|
||||
rightActionBarLayout.showLastFragment();
|
||||
}
|
||||
}
|
||||
|
||||
intent.setAction(null);
|
||||
@@ -901,25 +657,17 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
if (dialog_id != 0) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("scrollToTopOnResume", true);
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
|
||||
args.putInt("chat_id", (int)dialog_id);
|
||||
ChatActivity fragment = new ChatActivity(args);
|
||||
|
||||
if (videoPath != null) {
|
||||
if(android.os.Build.VERSION.SDK_INT >= 16) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBarLayout.presentFragment(fragment, false, true, true);
|
||||
} else {
|
||||
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
||||
}
|
||||
actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1);
|
||||
|
||||
if (!fragment.openVideoEditor(videoPath, dialogsFragment != null, false) && dialogsFragment != null) {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
dialogsFragment.finishFragment(true);
|
||||
}
|
||||
dialogsFragment.finishFragment(true);
|
||||
}
|
||||
} else {
|
||||
actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true);
|
||||
@@ -983,106 +731,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
}
|
||||
|
||||
public void needLayout() {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) layersActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.leftMargin = (AndroidUtilities.displaySize.x - relativeLayoutParams.width) / 2;
|
||||
int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
relativeLayoutParams.topMargin = y + (AndroidUtilities.displaySize.y - relativeLayoutParams.height - y) / 2;
|
||||
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
|
||||
if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
tabletFullSize = false;
|
||||
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
|
||||
if (leftWidth < AndroidUtilities.dp(320)) {
|
||||
leftWidth = AndroidUtilities.dp(320);
|
||||
}
|
||||
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = leftWidth;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTabletSide.getLayoutParams();
|
||||
relativeLayoutParams.leftMargin = leftWidth;
|
||||
shadowTabletSide.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) rightActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = AndroidUtilities.displaySize.x - leftWidth;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.leftMargin = leftWidth;
|
||||
rightActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() >= 2) {
|
||||
for (int a = 1; a < actionBarLayout.fragmentsStack.size(); a++) {
|
||||
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(a);
|
||||
chatFragment.onPause();
|
||||
actionBarLayout.fragmentsStack.remove(a);
|
||||
rightActionBarLayout.fragmentsStack.add(chatFragment);
|
||||
a--;
|
||||
}
|
||||
if (passcodeView.getVisibility() != View.VISIBLE) {
|
||||
actionBarLayout.showLastFragment();
|
||||
rightActionBarLayout.showLastFragment();
|
||||
}
|
||||
}
|
||||
|
||||
rightActionBarLayout.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
backgroundTablet.setVisibility(rightActionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
shadowTabletSide.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.VISIBLE : View.GONE);
|
||||
} else {
|
||||
tabletFullSize = true;
|
||||
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
shadowTabletSide.setVisibility(View.GONE);
|
||||
rightActionBarLayout.setVisibility(View.GONE);
|
||||
backgroundTablet.setVisibility(!actionBarLayout.fragmentsStack.isEmpty() ? View.GONE : View.VISIBLE);
|
||||
|
||||
if (!rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < rightActionBarLayout.fragmentsStack.size(); a++) {
|
||||
BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(a);
|
||||
chatFragment.onPause();
|
||||
rightActionBarLayout.fragmentsStack.remove(a);
|
||||
actionBarLayout.fragmentsStack.add(chatFragment);
|
||||
a--;
|
||||
}
|
||||
if (passcodeView.getVisibility() != View.VISIBLE) {
|
||||
actionBarLayout.showLastFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fixLayout() {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
return;
|
||||
}
|
||||
if (actionBarLayout == null) {
|
||||
return;
|
||||
}
|
||||
actionBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
needLayout();
|
||||
}
|
||||
});
|
||||
if (actionBarLayout != null) {
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
actionBarLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
} else {
|
||||
actionBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1096,16 +747,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
||||
}
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (rightActionBarLayout.fragmentsStack.size() != 0) {
|
||||
BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
||||
}
|
||||
if (layersActionBarLayout.fragmentsStack.size() != 0) {
|
||||
BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onActivityResultFragment(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final int REQ_CONTACT_N_STORAGE_PERMISON_ID = 1;
|
||||
@@ -1145,8 +786,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() {
|
||||
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
|
||||
builder.setPositiveButton(R.string.PermissionOpenSettings, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
@@ -1160,7 +800,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;
|
||||
}
|
||||
@@ -1168,16 +808,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
||||
}
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (rightActionBarLayout.fragmentsStack.size() != 0) {
|
||||
BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
||||
}
|
||||
if (layersActionBarLayout.fragmentsStack.size() != 0) {
|
||||
BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
||||
fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1187,10 +817,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
ApplicationLoader.mainInterfacePaused = true;
|
||||
onPasscodePause();
|
||||
actionBarLayout.onPause();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
rightActionBarLayout.onPause();
|
||||
layersActionBarLayout.onPause();
|
||||
}
|
||||
if (passcodeView != null) {
|
||||
passcodeView.onPause();
|
||||
}
|
||||
@@ -1200,18 +826,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
ApplicationLoader.stayAwakeForAMoment();
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected void onStart() {
|
||||
Log.i("DeltaChat", "*** LaunchActivity.onStart()");
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Log.i("DeltaChat", "*** LaunchActivity.onStop()");
|
||||
super.onStop();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
MrMailbox.log_i("DeltaChat", "*** LaunchActivity.onDestroy()");
|
||||
@@ -1249,10 +863,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
onPasscodeResume();
|
||||
if (passcodeView.getVisibility() != View.VISIBLE) {
|
||||
actionBarLayout.onResume();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
rightActionBarLayout.onResume();
|
||||
layersActionBarLayout.onResume();
|
||||
}
|
||||
} else {
|
||||
passcodeView.onResume();
|
||||
}
|
||||
@@ -1278,7 +888,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
finish();
|
||||
}
|
||||
} else if (id == NotificationCenter.mainUserInfoChanged) {
|
||||
drawerLayoutAdapter.notifyDataSetChanged();
|
||||
KeepAliveService kas = KeepAliveService.getInstance();
|
||||
if( kas != null ) {
|
||||
kas.updateForegroundNotification();
|
||||
@@ -1337,18 +946,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
try {
|
||||
super.onSaveInstanceState(outState);
|
||||
BaseFragment lastFragment = null;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
lastFragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1);
|
||||
} else if (!rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
lastFragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
||||
} else if (!actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
||||
}
|
||||
} else {
|
||||
if (!actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
||||
}
|
||||
if (!actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
|
||||
}
|
||||
|
||||
if (lastFragment != null) {
|
||||
@@ -1382,21 +981,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
}
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto(true, false);
|
||||
} else if (drawerLayoutContainer.isDrawerOpened()) {
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
} else if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.getVisibility() == View.VISIBLE) {
|
||||
layersActionBarLayout.onBackPressed();
|
||||
} else {
|
||||
boolean cancel = false;
|
||||
if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
BaseFragment lastFragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1);
|
||||
cancel = !lastFragment.onBackPressed();
|
||||
}
|
||||
if (!cancel) {
|
||||
actionBarLayout.onBackPressed();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
actionBarLayout.onBackPressed();
|
||||
}
|
||||
@@ -1406,10 +990,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
actionBarLayout.onLowMemory();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
rightActionBarLayout.onLowMemory();
|
||||
layersActionBarLayout.onLowMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1419,10 +999,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
return;
|
||||
}
|
||||
actionBarLayout.onActionModeStarted(mode);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
rightActionBarLayout.onActionModeStarted(mode);
|
||||
layersActionBarLayout.onActionModeStarted(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1432,10 +1008,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
return;
|
||||
}
|
||||
actionBarLayout.onActionModeFinished(mode);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
rightActionBarLayout.onActionModeFinished(mode);
|
||||
layersActionBarLayout.onActionModeFinished(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1450,27 +1022,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_MENU && !UserConfig.isWaitingForPasscodeEnter) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.getVisibility() == View.VISIBLE && !layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
layersActionBarLayout.onKeyUp(keyCode, event);
|
||||
} else if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
rightActionBarLayout.onKeyUp(keyCode, event);
|
||||
} else {
|
||||
actionBarLayout.onKeyUp(keyCode, event);
|
||||
if (actionBarLayout.fragmentsStack.size() == 1) {
|
||||
if (getCurrentFocus() != null) {
|
||||
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
||||
}
|
||||
} else {
|
||||
if (actionBarLayout.fragmentsStack.size() == 1) {
|
||||
if (!drawerLayoutContainer.isDrawerOpened()) {
|
||||
if (getCurrentFocus() != null) {
|
||||
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
||||
}
|
||||
drawerLayoutContainer.openDrawer(false);
|
||||
} else {
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
}
|
||||
} else {
|
||||
actionBarLayout.onKeyUp(keyCode, event);
|
||||
}
|
||||
actionBarLayout.onKeyUp(keyCode, event);
|
||||
}
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
@@ -1478,182 +1035,21 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
|
||||
@Override
|
||||
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
||||
if (fragment instanceof DialogsActivity) {
|
||||
DialogsActivity dialogsActivity = (DialogsActivity)fragment;
|
||||
if (dialogsActivity.isMainDialogList() && layout != actionBarLayout) {
|
||||
actionBarLayout.removeAllFragments();
|
||||
actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
||||
layersActionBarLayout.removeAllFragments();
|
||||
layersActionBarLayout.setVisibility(View.GONE);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
if (!tabletFullSize) {
|
||||
shadowTabletSide.setVisibility(View.VISIBLE);
|
||||
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
backgroundTablet.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (fragment instanceof ChatActivity) {
|
||||
if (!tabletFullSize && layout == rightActionBarLayout || tabletFullSize && layout == actionBarLayout) {
|
||||
boolean result = !(tabletFullSize && layout == actionBarLayout && actionBarLayout.fragmentsStack.size() == 1);
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
||||
}
|
||||
if (!result) {
|
||||
actionBarLayout.presentFragment(fragment, false, forceWithoutAnimation, false);
|
||||
}
|
||||
return result;
|
||||
} else if (!tabletFullSize && layout != rightActionBarLayout) {
|
||||
rightActionBarLayout.setVisibility(View.VISIBLE);
|
||||
backgroundTablet.setVisibility(View.GONE);
|
||||
rightActionBarLayout.removeAllFragments();
|
||||
rightActionBarLayout.presentFragment(fragment, removeLast, true, false);
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
||||
}
|
||||
return false;
|
||||
} else if (tabletFullSize && layout != actionBarLayout) {
|
||||
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(!forceWithoutAnimation);
|
||||
}
|
||||
actionBarLayout.presentFragment(fragment, actionBarLayout.fragmentsStack.size() > 1, forceWithoutAnimation, false);
|
||||
return false;
|
||||
}
|
||||
} else if (layout != layersActionBarLayout) {
|
||||
layersActionBarLayout.setVisibility(View.VISIBLE);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
||||
shadowTablet.setBackgroundColor(0x7F000000);
|
||||
layersActionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(layersActionBarLayout.getVisibility() != View.VISIBLE, true);
|
||||
if (fragment instanceof DialogsActivity) {
|
||||
DialogsActivity dialogsActivity = (DialogsActivity)fragment;
|
||||
if (dialogsActivity.isMainDialogList() && layout != actionBarLayout) {
|
||||
actionBarLayout.removeAllFragments();
|
||||
actionBarLayout.addFragmentToStack(fragment);
|
||||
layersActionBarLayout.removeAllFragments();
|
||||
layersActionBarLayout.setVisibility(View.GONE);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
if (!tabletFullSize) {
|
||||
shadowTabletSide.setVisibility(View.VISIBLE);
|
||||
if (rightActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
backgroundTablet.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (fragment instanceof ChatActivity) {
|
||||
if (!tabletFullSize && layout != rightActionBarLayout) {
|
||||
rightActionBarLayout.setVisibility(View.VISIBLE);
|
||||
backgroundTablet.setVisibility(View.GONE);
|
||||
rightActionBarLayout.removeAllFragments();
|
||||
rightActionBarLayout.addFragmentToStack(fragment);
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(true);
|
||||
}
|
||||
return false;
|
||||
} else if (tabletFullSize && layout != actionBarLayout) {
|
||||
actionBarLayout.addFragmentToStack(fragment);
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (layout != layersActionBarLayout) {
|
||||
layersActionBarLayout.setVisibility(View.VISIBLE);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, true);
|
||||
shadowTablet.setBackgroundColor(0x7F000000);
|
||||
layersActionBarLayout.addFragmentToStack(fragment);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needCloseLastFragment(ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layout == actionBarLayout && layout.fragmentsStack.size() <= 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
} else if (layout == rightActionBarLayout) {
|
||||
if (!tabletFullSize) {
|
||||
backgroundTablet.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (layout.fragmentsStack.size() <= 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebuildAllFragments(ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layout == layersActionBarLayout) {
|
||||
rightActionBarLayout.rebuildAllFragmentViews(true);
|
||||
rightActionBarLayout.showLastFragment();
|
||||
actionBarLayout.rebuildAllFragmentViews(true);
|
||||
actionBarLayout.showLastFragment();
|
||||
}
|
||||
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needCloseLastFragment(ActionBarLayout layout) {
|
||||
if (layout.fragmentsStack.size() <= 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
drawerLayoutAdapter.notifyDataSetChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class LaunchLayoutContainer extends FrameLayout {
|
||||
|
||||
private Object lastInsets;
|
||||
private boolean inLayout;
|
||||
|
||||
public LaunchLayoutContainer(Context context) {
|
||||
super(context);
|
||||
|
||||
setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS);
|
||||
setFocusableInTouchMode(true);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
setFitsSystemWindows(true);
|
||||
setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
|
||||
final LaunchLayoutContainer launchLayout = (LaunchLayoutContainer) v;
|
||||
lastInsets = insets;
|
||||
launchLayout.setWillNotDraw(insets.getSystemWindowInsetTop() <= 0 && getBackground() == null);
|
||||
launchLayout.requestLayout();
|
||||
return insets.consumeSystemWindowInsets();
|
||||
}
|
||||
});
|
||||
setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void dispatchChildInsets(View child, Object insets, int gravity) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (gravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (gravity == Gravity.RIGHT) {
|
||||
wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
|
||||
}
|
||||
child.dispatchApplyWindowInsets(wi);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int gravity, boolean topOnly) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (gravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (gravity == Gravity.RIGHT) {
|
||||
wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
|
||||
}
|
||||
lp.leftMargin = wi.getSystemWindowInsetLeft();
|
||||
lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
|
||||
lp.rightMargin = wi.getSystemWindowInsetRight();
|
||||
lp.bottomMargin = wi.getSystemWindowInsetBottom();
|
||||
}
|
||||
|
||||
private int getTopInset(Object insets) { /* not sure, if this or one of the other unsed methods is called indirectly somewhere; however, at the moment, I do not habe the time tp check this. */
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return insets != null ? ((WindowInsets) insets).getSystemWindowInsetTop() : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
inLayout = true;
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
try {
|
||||
child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight());
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
inLayout = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLayout() {
|
||||
if (!inLayout) {
|
||||
/*StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||
for (int a = 0; a < elements.length; a++) {
|
||||
Log.d("DeltaChat", "on " + elements[a]);
|
||||
}*/
|
||||
super.requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
setMeasuredDimension(widthSize, heightSize);
|
||||
|
||||
final boolean applyInsets = lastInsets != null && Build.VERSION.SDK_INT >= 21;
|
||||
|
||||
final int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
final View child = getChildAt(i);
|
||||
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
if (applyInsets) {
|
||||
if (child.getFitsSystemWindows()) {
|
||||
dispatchChildInsets(child, lastInsets, lp.gravity);
|
||||
} else if (child.getTag() == null) {
|
||||
applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21);
|
||||
}
|
||||
}
|
||||
|
||||
final int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
|
||||
final int contentHeightSpec = MeasureSpec.makeMeasureSpec(heightSize - lp.topMargin - lp.bottomMargin, MeasureSpec.EXACTLY);
|
||||
child.measure(contentWidthSpec, contentHeightSpec);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,381 +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.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.NotificationCenter;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.ActionBar.ActionBarLayout;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.ActionBar.DrawerLayoutContainer;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ManageSpaceActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate {
|
||||
|
||||
private boolean finished;
|
||||
private static ArrayList<BaseFragment> mainFragmentsStack = new ArrayList<>();
|
||||
private static ArrayList<BaseFragment> layerFragmentsStack = new ArrayList<>();
|
||||
|
||||
private ActionBarLayout actionBarLayout;
|
||||
private ActionBarLayout layersActionBarLayout;
|
||||
protected DrawerLayoutContainer drawerLayoutContainer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setTheme(R.style.Theme_MessengerProj);
|
||||
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
Theme.loadRecources(this);
|
||||
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
|
||||
actionBarLayout = new ActionBarLayout(this);
|
||||
|
||||
drawerLayoutContainer = new DrawerLayoutContainer(this);
|
||||
drawerLayoutContainer.setAllowOpenDrawer(false, false);
|
||||
setContentView(drawerLayoutContainer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
|
||||
RelativeLayout launchLayout = new RelativeLayout(this);
|
||||
drawerLayoutContainer.addView(launchLayout);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) launchLayout.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.MATCH_PARENT;
|
||||
launchLayout.setLayoutParams(layoutParams1);
|
||||
|
||||
ImageView backgroundTablet = new ImageView(this);
|
||||
backgroundTablet.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
backgroundTablet.setImageResource(R.drawable.background_hd);
|
||||
launchLayout.addView(backgroundTablet);
|
||||
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams) backgroundTablet.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
backgroundTablet.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
launchLayout.addView(actionBarLayout);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
FrameLayout shadowTablet = new FrameLayout(this);
|
||||
shadowTablet.setBackgroundColor(0x7F000000);
|
||||
launchLayout.addView(shadowTablet);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) shadowTablet.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
shadowTablet.setLayoutParams(relativeLayoutParams);
|
||||
shadowTablet.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (!actionBarLayout.fragmentsStack.isEmpty() && event.getAction() == MotionEvent.ACTION_UP) {
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
int location[] = new int[2];
|
||||
layersActionBarLayout.getLocationOnScreen(location);
|
||||
int viewX = location[0];
|
||||
int viewY = location[1];
|
||||
|
||||
if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
|
||||
return false;
|
||||
} else {
|
||||
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
|
||||
layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
|
||||
a--;
|
||||
}
|
||||
layersActionBarLayout.closeLastFragment(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
shadowTablet.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
layersActionBarLayout = new ActionBarLayout(this);
|
||||
layersActionBarLayout.setRemoveActionBarExtraHeight(true);
|
||||
layersActionBarLayout.setBackgroundView(shadowTablet);
|
||||
layersActionBarLayout.setUseAlphaAnimations(true);
|
||||
layersActionBarLayout.setBackgroundResource(R.drawable.boxshadow);
|
||||
launchLayout.addView(layersActionBarLayout);
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = AndroidUtilities.dp(530);
|
||||
relativeLayoutParams.height = AndroidUtilities.dp(528);
|
||||
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
layersActionBarLayout.init(layerFragmentsStack);
|
||||
layersActionBarLayout.setDelegate(this);
|
||||
layersActionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
||||
} else {
|
||||
drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
|
||||
// drawerLayoutContainer.setDrawerLayout(listView);
|
||||
|
||||
drawerLayoutContainer.setParentActionBarLayout(actionBarLayout);
|
||||
actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer);
|
||||
actionBarLayout.init(mainFragmentsStack);
|
||||
actionBarLayout.setDelegate(this);
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeOtherAppActivities, this);
|
||||
|
||||
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
||||
needLayout();
|
||||
}
|
||||
|
||||
private boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
|
||||
layersActionBarLayout.addFragmentToStack(new CacheControlActivity());
|
||||
}
|
||||
} else {
|
||||
if (actionBarLayout.fragmentsStack.isEmpty()) {
|
||||
actionBarLayout.addFragmentToStack(new CacheControlActivity());
|
||||
}
|
||||
}
|
||||
actionBarLayout.showLastFragment();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.showLastFragment();
|
||||
}
|
||||
intent.setAction(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreIme() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleIntent(intent, true, false, false);
|
||||
}
|
||||
|
||||
private void onFinish() {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
}
|
||||
|
||||
public void presentFragment(BaseFragment fragment) {
|
||||
actionBarLayout.presentFragment(fragment);
|
||||
}
|
||||
|
||||
public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation) {
|
||||
return actionBarLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, true);
|
||||
}
|
||||
|
||||
public void needLayout() {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
RelativeLayout.LayoutParams relativeLayoutParams = (RelativeLayout.LayoutParams)layersActionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.leftMargin = (AndroidUtilities.displaySize.x - relativeLayoutParams.width) / 2;
|
||||
int y = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
relativeLayoutParams.topMargin = y + (AndroidUtilities.displaySize.y - relativeLayoutParams.height - y) / 2;
|
||||
layersActionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
|
||||
if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
int leftWidth = AndroidUtilities.displaySize.x / 100 * 35;
|
||||
if (leftWidth < AndroidUtilities.dp(320)) {
|
||||
leftWidth = AndroidUtilities.dp(320);
|
||||
}
|
||||
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = leftWidth;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
|
||||
if (AndroidUtilities.isSmallTablet() && actionBarLayout.fragmentsStack.size() == 2) {
|
||||
BaseFragment chatFragment = actionBarLayout.fragmentsStack.get(1);
|
||||
chatFragment.onPause();
|
||||
actionBarLayout.fragmentsStack.remove(1);
|
||||
actionBarLayout.showLastFragment();
|
||||
}
|
||||
} else {
|
||||
relativeLayoutParams = (RelativeLayout.LayoutParams) actionBarLayout.getLayoutParams();
|
||||
relativeLayoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
actionBarLayout.setLayoutParams(relativeLayoutParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fixLayout() {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
return;
|
||||
}
|
||||
if (actionBarLayout == null) {
|
||||
return;
|
||||
}
|
||||
actionBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
needLayout();
|
||||
if (actionBarLayout != null) {
|
||||
if (Build.VERSION.SDK_INT < 16) {
|
||||
actionBarLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
} else {
|
||||
actionBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
actionBarLayout.onPause();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
onFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
actionBarLayout.onResume();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||
AndroidUtilities.checkDisplaySize();
|
||||
super.onConfigurationChanged(newConfig);
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto(true, false);
|
||||
} else if (drawerLayoutContainer.isDrawerOpened()) {
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
} else if (AndroidUtilities.isTablet()) {
|
||||
if (layersActionBarLayout.getVisibility() == View.VISIBLE) {
|
||||
layersActionBarLayout.onBackPressed();
|
||||
} else {
|
||||
actionBarLayout.onBackPressed();
|
||||
}
|
||||
} else {
|
||||
actionBarLayout.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
actionBarLayout.onLowMemory();
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
layersActionBarLayout.onLowMemory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needCloseLastFragment(ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layout == actionBarLayout && layout.fragmentsStack.size() <= 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
} else if (layout == layersActionBarLayout && actionBarLayout.fragmentsStack.isEmpty() && layersActionBarLayout.fragmentsStack.size() == 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (layout.fragmentsStack.size() <= 1) {
|
||||
onFinish();
|
||||
finish();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebuildAllFragments(ActionBarLayout layout) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (layout == layersActionBarLayout) {
|
||||
actionBarLayout.rebuildAllFragmentViews(true);
|
||||
actionBarLayout.showLastFragment();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,6 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||
passwordEditText.setTypeface(Typeface.DEFAULT);
|
||||
AndroidUtilities.clearCursorDrawable(passwordEditText);
|
||||
frameLayout.addView(passwordEditText);
|
||||
layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(90);
|
||||
@@ -272,7 +271,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.width = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(40);
|
||||
layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(56);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
dropDownContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -383,7 +382,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
numberPicker.setWrapSelectorWheel(false);
|
||||
builder.setView(numberPicker);
|
||||
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
which = numberPicker.getValue();
|
||||
@@ -595,12 +594,10 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
private void fixLayoutInternal() {
|
||||
if (dropDownContainer != null) {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
|
||||
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
}
|
||||
if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
|
||||
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
dropDown.setTextSize(18);
|
||||
} else {
|
||||
dropDown.setTextSize(20);
|
||||
|
||||
@@ -172,7 +172,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
|
||||
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.width = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(40);
|
||||
layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(56);
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.START;
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
dropDownContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -391,19 +391,17 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
|
||||
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
columnsCount = 2;
|
||||
if (!AndroidUtilities.isTablet() && (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) {
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
columnsCount = 4;
|
||||
}
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
if (dropDownContainer != null) {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
|
||||
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
}
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
|
||||
layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
|
||||
dropDownContainer.setLayoutParams(layoutParams);
|
||||
|
||||
if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
dropDown.setTextSize(18);
|
||||
} else {
|
||||
dropDown.setTextSize(20);
|
||||
|
||||
@@ -398,11 +398,7 @@ public class PhotoCropActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
int size;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
size = AndroidUtilities.dp(520);
|
||||
} else {
|
||||
size = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
|
||||
}
|
||||
size = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
|
||||
imageToCrop = ImageLoader.loadBitmap(photoPath, photoUri, size, size, true);
|
||||
if (imageToCrop == null) {
|
||||
return false;
|
||||
|
||||
@@ -430,21 +430,13 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
|
||||
int columnsCount;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
columnsCount = 3;
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
columnsCount = 5;
|
||||
} else {
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
columnsCount = 5;
|
||||
} else {
|
||||
columnsCount = 3;
|
||||
}
|
||||
columnsCount = 3;
|
||||
}
|
||||
listView.setNumColumns(columnsCount);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
itemWidth = (AndroidUtilities.dp(490) - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
|
||||
} else {
|
||||
itemWidth = (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
|
||||
}
|
||||
itemWidth = (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
|
||||
listView.setColumnWidth(itemWidth);
|
||||
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
@@ -279,14 +279,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
super(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
if (parentActivity instanceof LaunchActivity) {
|
||||
((LaunchActivity) parentActivity).drawerLayoutContainer.setAllowDrawContent(!isVisible || alpha != 255);
|
||||
}
|
||||
super.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
super.draw(canvas);
|
||||
@@ -1026,7 +1018,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showAlertDialog(builder);
|
||||
*/
|
||||
}
|
||||
@@ -1479,7 +1471,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
mentionsAdapter.clearRecentHashtags();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showAlertDialog(builder);
|
||||
return true;
|
||||
}
|
||||
@@ -2012,13 +2004,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||
builder.setMessage(ApplicationLoader.applicationContext.getString(R.string.DiscardChanges));
|
||||
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) {
|
||||
switchToEditMode(0);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showAlertDialog(builder);
|
||||
} else {
|
||||
switchToEditMode(0);
|
||||
|
||||
@@ -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,16 +22,11 @@
|
||||
|
||||
package com.b44t.ui;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -46,16 +40,12 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.AnimatorListenerAdapterProxy;
|
||||
import com.b44t.messenger.ContactsController;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.messenger.FileLoader;
|
||||
import com.b44t.messenger.MrChat;
|
||||
import com.b44t.messenger.MrContact;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
@@ -69,11 +59,9 @@ import com.b44t.messenger.R;
|
||||
import com.b44t.messenger.MessageObject;
|
||||
import com.b44t.ui.ActionBar.BackDrawable;
|
||||
import com.b44t.ui.ActionBar.SimpleTextView;
|
||||
import com.b44t.ui.Cells.DividerCell;
|
||||
import com.b44t.ui.Cells.EmptyCell;
|
||||
import com.b44t.ui.Cells.ShadowSectionCell;
|
||||
import com.b44t.ui.Cells.TextCell;
|
||||
import com.b44t.ui.Cells.TextDetailCell;
|
||||
import com.b44t.ui.Cells.UserCell;
|
||||
import com.b44t.ui.ActionBar.ActionBar;
|
||||
import com.b44t.ui.ActionBar.ActionBarMenu;
|
||||
@@ -86,7 +74,7 @@ import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.Components.RecyclerListView;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
@@ -95,8 +83,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private int chat_id; // show the profile of a group
|
||||
|
||||
private final int typeEmpty = 0;
|
||||
private final int typeDivider = 1;
|
||||
private final int typeTextDetailCell = 2;
|
||||
private final int typeTextCell = 3;
|
||||
private final int typeContactCell = 4;
|
||||
private final int typeSection = 5;
|
||||
@@ -104,35 +90,22 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private BackupImageView avatarImage;
|
||||
private SimpleTextView nameTextView[] = new SimpleTextView[2];
|
||||
private SimpleTextView onlineTextView[] = new SimpleTextView[2];
|
||||
private ImageView writeButton;
|
||||
private AnimatorSet writeButtonAnimation;
|
||||
private SimpleTextView nameTextView;
|
||||
private SimpleTextView subtitleTextView;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private ActionBarMenuItem animatingItem;
|
||||
private TopView topView;
|
||||
|
||||
private long dialog_id;
|
||||
|
||||
private boolean openAnimationInProgress;
|
||||
private boolean playProfileAnimation;
|
||||
private boolean allowProfileAnimation = true;
|
||||
private int extraHeight;
|
||||
private int initialAnimationExtraHeight;
|
||||
|
||||
private AvatarUpdater avatarUpdater;
|
||||
private int[] sortedUserIds;
|
||||
|
||||
private final static int ID_STOP_ENCRYPTION_FOR_THIS_USER = 2;
|
||||
private final static int ID_BLOCK_CONTACT = 3;
|
||||
private final static int ID_DELETE_CONTACT = 5;
|
||||
private final static int ID_INVITE_TO_GROUP = 9;
|
||||
private final static int ID_ADD_SHORTCUT = 14;
|
||||
private final static int ID_COPY_EMAIL_TO_CLIPBOARD = 15;
|
||||
|
||||
private int emptyRow = -1;
|
||||
private int userSectionRow = -1;
|
||||
private int sectionRow = -1;
|
||||
private int settingsNotificationsRow = -1;
|
||||
private int changeNameRow = -1;
|
||||
private int startChatRow = -1;
|
||||
@@ -187,8 +160,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
user_id = arguments.getInt("user_id", 0);
|
||||
chat_id = getArguments().getInt("chat_id", 0);
|
||||
if (user_id != 0) {
|
||||
dialog_id = arguments.getLong("dialog_id", 0);
|
||||
|
||||
TLRPC.User user = MrMailbox.getUser(user_id);
|
||||
if (user == null) {
|
||||
return false;
|
||||
@@ -200,11 +171,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
sortedUserIds = MrMailbox.getChatContacts(chat_id);
|
||||
|
||||
avatarUpdater = new AvatarUpdater();
|
||||
avatarUpdater.returnOnly = true;
|
||||
avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() {
|
||||
@Override
|
||||
public void didUploadedPhoto(TLRPC.InputFile file, TLRPC.PhotoSize small, TLRPC.PhotoSize big) {
|
||||
if (chat_id != 0) {
|
||||
//MessagesController.getInstance().changeChatAvatar(chat_id, file);
|
||||
if (user_id==0 && chat_id > MrChat.MR_CHAT_ID_LAST_SPECIAL) {
|
||||
String nameonly = big.location.volume_id + "_" + big.location.local_id + ".jpg";
|
||||
File fileobj = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), nameonly);
|
||||
String fullpath = fileobj.getAbsolutePath();
|
||||
MrMailbox.setChatImage(chat_id, fullpath);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -245,7 +220,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
actionBar.setBackButtonDrawable(new BackDrawable(false));
|
||||
actionBar.setCastShadows(false);
|
||||
actionBar.setAddToContainer(false);
|
||||
actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
|
||||
actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21);
|
||||
return actionBar;
|
||||
}
|
||||
|
||||
@@ -264,10 +239,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
}
|
||||
else if( id==ID_STOP_ENCRYPTION_FOR_THIS_USER )
|
||||
{
|
||||
Toast.makeText(getParentActivity(), context.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if( id==ID_COPY_EMAIL_TO_CLIPBOARD )
|
||||
{
|
||||
AndroidUtilities.addToClipboard(MrMailbox.getContact(user_id).getAddr());
|
||||
@@ -281,14 +252,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AreYouSureBlockContact));
|
||||
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) {
|
||||
MrMailbox.blockContact(user_id, 1);
|
||||
finishFragment(); /* got to the parent, this is important eg. when editing blocking in the BlockedUserActivitiy. Moreover, this saves us updating all the states in the profile */
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
@@ -296,7 +267,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AreYouSureDeleteContact));
|
||||
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.deleteContact(user_id)==0 ) {
|
||||
@@ -308,7 +279,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
else if (id == ID_ADD_SHORTCUT)
|
||||
@@ -408,14 +379,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
{
|
||||
String info_str = MrMailbox.getContactEncrInfo(user_id);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(ApplicationLoader.applicationContext.getString(R.string.Encryption));
|
||||
builder.setTitle(R.string.Encryption);
|
||||
builder.setMessage(AndroidUtilities.replaceTags(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());
|
||||
}
|
||||
else if(position==startChatRow)
|
||||
@@ -432,7 +398,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
String name = MrMailbox.getContact(user_id).getNameNAddr();
|
||||
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);
|
||||
@@ -446,7 +412,7 @@ public class ProfileActivity 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());
|
||||
}
|
||||
@@ -464,14 +430,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
else {
|
||||
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) {
|
||||
MrMailbox.addContactToChat(chat_id, added_user_id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_CHAT_MEMBERS);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
String name = MrMailbox.getContact(added_user_id).getDisplayName();
|
||||
builder.setMessage(AndroidUtilities.replaceTags(String.format(context.getString(R.string.AskAddMemberToGroup), name)));
|
||||
showDialog(builder.create());
|
||||
@@ -511,14 +477,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
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) {
|
||||
MrMailbox.removeContactFromChat(chat_id, curr_user_id);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MrMailbox.UPDATE_MASK_CHAT_MEMBERS);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
String name = MrMailbox.getContact(curr_user_id).getDisplayName();
|
||||
builder.setMessage(AndroidUtilities.replaceTags(String.format(context.getString(R.string.AskRemoveMemberFromGroup), name)));
|
||||
showDialog(builder.create());
|
||||
@@ -550,100 +516,64 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (user_id != 0) {
|
||||
TLRPC.User user = MrMailbox.getUser(user_id);
|
||||
if (user.photo != null && user.photo.photo_big != null) {
|
||||
PhotoViewer.getInstance().setParentActivity(getParentActivity());
|
||||
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this);
|
||||
}
|
||||
} else if (chat_id != 0) {
|
||||
TLRPC.Chat chat = MrChat.chatId2chat(chat_id);
|
||||
if (chat.photo != null && chat.photo.photo_big != null) {
|
||||
PhotoViewer.getInstance().setParentActivity(getParentActivity());
|
||||
PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, ProfileActivity.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (int a = 0; a < 2; a++) {
|
||||
if (!playProfileAnimation && a == 0) {
|
||||
continue;
|
||||
}
|
||||
nameTextView[a] = new SimpleTextView(context);
|
||||
nameTextView[a].setTextColor(Theme.ACTION_BAR_TITLE_COLOR);
|
||||
nameTextView[a].setTextSize(18);
|
||||
nameTextView[a].setGravity(Gravity.START);
|
||||
nameTextView[a].setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
|
||||
nameTextView[a].setRightDrawableTopPadding(-AndroidUtilities.dp(1.3f));
|
||||
nameTextView[a].setPivotX(0);
|
||||
nameTextView[a].setPivotY(0);
|
||||
frameLayout.addView(nameTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 118-ANIM_OFF, 0, a == 0 ? 48 : 0, 0));
|
||||
|
||||
onlineTextView[a] = new SimpleTextView(context);
|
||||
onlineTextView[a].setTextColor(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
onlineTextView[a].setTextSize(14);
|
||||
onlineTextView[a].setGravity(Gravity.START);
|
||||
frameLayout.addView(onlineTextView[a], LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 118-ANIM_OFF, 0, a == 0 ? 48 : 8, 0));
|
||||
}
|
||||
|
||||
if ( chat_id != 0 && chat_id!= MrChat.MR_CHAT_ID_DEADDROP ) {
|
||||
/* TODO: let the user select a photo for the group
|
||||
writeButton = new ImageView(context);
|
||||
try {
|
||||
writeButton.setBackgroundResource(R.drawable.floating_user_states);
|
||||
} catch (Throwable e) {
|
||||
|
||||
}
|
||||
writeButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||
writeButton.setImageResource(R.drawable.floating_camera);
|
||||
|
||||
frameLayout.addView(writeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.END | Gravity.TOP, 0, 0, 16, 0));
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
StateListAnimator animator = new StateListAnimator();
|
||||
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
|
||||
animator.addState(new int[]{}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
|
||||
writeButton.setStateListAnimator(animator);
|
||||
writeButton.setOutlineProvider(new ViewOutlineProvider() {
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
||||
}
|
||||
});
|
||||
}
|
||||
writeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (user_id==0 && chat_id > MrChat.MR_CHAT_ID_LAST_SPECIAL) {
|
||||
// show menu to change the group image
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
CharSequence[] items;
|
||||
TLRPC.Chat chat = MrChat.chatId2chat(chat_id);
|
||||
if (chat.photo == null || chat.photo.photo_big == null ) {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
|
||||
boolean hasPhoto = MrMailbox.getChat(chat_id).getParam(MrChat.MRP_PROFILE_IMAGE, null)!=null;
|
||||
if ( !hasPhoto ) {
|
||||
items = new CharSequence[]{context.getString(R.string.FromCamera), context.getString(R.string.FromGalley)};
|
||||
} else {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
|
||||
items = new CharSequence[]{context.getString(R.string.FromCamera), context.getString(R.string.FromGalley), context.getString(R.string.Delete)};
|
||||
}
|
||||
|
||||
builder.setTitle(R.string.EditImage);
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
avatarUpdater.openCamera();
|
||||
avatarUpdater.openCamera(); // results in a call to didUploadedPhoto()
|
||||
} else if (i == 1) {
|
||||
avatarUpdater.openGallery();
|
||||
avatarUpdater.openGallery(); // results in a call to didUploadedPhoto()
|
||||
} else if (i == 2) {
|
||||
MessagesController.getInstance().changeChatAvatar(chat_id, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AskDeleteGroupImage));
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if( MrMailbox.setChatImage(chat_id, null)!=0 ) {
|
||||
AndroidUtilities.showDoneHint(getParentActivity());
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
nameTextView = new SimpleTextView(context);
|
||||
nameTextView.setTextColor(Theme.ACTION_BAR_TITLE_COLOR);
|
||||
nameTextView.setTextSize(18);
|
||||
nameTextView.setGravity(Gravity.START);
|
||||
nameTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
|
||||
nameTextView.setRightDrawableTopPadding(-AndroidUtilities.dp(1.3f));
|
||||
nameTextView.setPivotX(0);
|
||||
nameTextView.setPivotY(0);
|
||||
frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 118-ANIM_OFF, 0, 0, 0));
|
||||
|
||||
subtitleTextView = new SimpleTextView(context);
|
||||
subtitleTextView.setTextColor(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
subtitleTextView.setTextSize(14);
|
||||
subtitleTextView.setGravity(Gravity.START);
|
||||
frameLayout.addView(subtitleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.TOP, 118-ANIM_OFF, 0, 8, 0));
|
||||
|
||||
needLayout();
|
||||
|
||||
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@@ -683,7 +613,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
|
||||
private void checkListViewScroll() {
|
||||
if (listView.getChildCount() <= 0 || openAnimationInProgress) {
|
||||
if (listView.getChildCount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -697,9 +627,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
if (extraHeight != newOffset) {
|
||||
extraHeight = newOffset;
|
||||
topView.invalidate();
|
||||
if (playProfileAnimation) {
|
||||
allowProfileAnimation = extraHeight != 0;
|
||||
}
|
||||
needLayout();
|
||||
}
|
||||
}
|
||||
@@ -707,7 +634,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private void needLayout() {
|
||||
FrameLayout.LayoutParams layoutParams;
|
||||
int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight();
|
||||
if (listView != null && !openAnimationInProgress) {
|
||||
if (listView != null) {
|
||||
layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
|
||||
if (layoutParams.topMargin != newTop) {
|
||||
layoutParams.topMargin = newTop;
|
||||
@@ -719,53 +646,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
float diff = extraHeight / (float) AndroidUtilities.dp(88);
|
||||
listView.setTopGlowOffset(extraHeight);
|
||||
|
||||
if (writeButton != null) {
|
||||
writeButton.setTranslationY((actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f));
|
||||
|
||||
if (!openAnimationInProgress) {
|
||||
final boolean setVisible = diff > 0.2f;
|
||||
boolean currentVisible = writeButton.getTag() == null;
|
||||
if (setVisible != currentVisible) {
|
||||
if (setVisible) {
|
||||
writeButton.setTag(null);
|
||||
} else {
|
||||
writeButton.setTag(0);
|
||||
}
|
||||
if (writeButtonAnimation != null) {
|
||||
AnimatorSet old = writeButtonAnimation;
|
||||
writeButtonAnimation = null;
|
||||
old.cancel();
|
||||
}
|
||||
writeButtonAnimation = new AnimatorSet();
|
||||
if (setVisible) {
|
||||
writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f),
|
||||
ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f),
|
||||
ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f)
|
||||
);
|
||||
} else {
|
||||
writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f),
|
||||
ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f),
|
||||
ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f)
|
||||
);
|
||||
}
|
||||
writeButtonAnimation.setDuration(150);
|
||||
writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
|
||||
writeButtonAnimation = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
writeButtonAnimation.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)
|
||||
+ ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff)
|
||||
- 21 * AndroidUtilities.density + 12 * AndroidUtilities.density * diff;
|
||||
@@ -773,38 +653,28 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
avatarImage.setScaleY((42 + 40 * diff) / 42.0f);
|
||||
avatarImage.setTranslationX(-AndroidUtilities.dp(42) * diff);
|
||||
avatarImage.setTranslationY((float) Math.ceil(avatarY));
|
||||
for (int a = 0; a < 2; a++) {
|
||||
if (nameTextView[a] == null) {
|
||||
continue;
|
||||
}
|
||||
nameTextView[a].setTranslationX(/*-21 * AndroidUtilities.density * diff*/1);
|
||||
nameTextView[a].setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(1.3f) + AndroidUtilities.dp(14) * diff);
|
||||
onlineTextView[a].setTranslationX(/*-21 * AndroidUtilities.density * diff*/1);
|
||||
onlineTextView[a].setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(24) + (float) Math.floor(25 * AndroidUtilities.density) * diff);
|
||||
nameTextView[a].setScaleX(1.0f + 0.4f * diff);
|
||||
nameTextView[a].setScaleY(1.0f + 0.4f * diff);
|
||||
if (a == 1 && !openAnimationInProgress) {
|
||||
int width;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
width = AndroidUtilities.dp(490);
|
||||
} else {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
}
|
||||
width = (int) (width - AndroidUtilities.dp(118 + 8 + 40 * (1.0f - diff)) - nameTextView[a].getTranslationX());
|
||||
float width2 = nameTextView[a].getPaint().measureText(nameTextView[a].getText().toString()) * nameTextView[a].getScaleX() + nameTextView[a].getSideDrawablesSize();
|
||||
layoutParams = (FrameLayout.LayoutParams) nameTextView[a].getLayoutParams();
|
||||
if (width < width2) {
|
||||
layoutParams.width = (int) Math.ceil(width / nameTextView[a].getScaleX());
|
||||
} else {
|
||||
layoutParams.width = LayoutHelper.WRAP_CONTENT;
|
||||
}
|
||||
nameTextView[a].setLayoutParams(layoutParams);
|
||||
|
||||
layoutParams = (FrameLayout.LayoutParams) onlineTextView[a].getLayoutParams();
|
||||
layoutParams.rightMargin = (int) Math.ceil(onlineTextView[a].getTranslationX() + AndroidUtilities.dp(8) + AndroidUtilities.dp(40) * (1.0f - diff));
|
||||
onlineTextView[a].setLayoutParams(layoutParams);
|
||||
}
|
||||
nameTextView.setTranslationX(/*-21 * AndroidUtilities.density * diff*/1);
|
||||
nameTextView.setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(1.3f) + AndroidUtilities.dp(14) * diff);
|
||||
subtitleTextView.setTranslationX(/*-21 * AndroidUtilities.density * diff*/1);
|
||||
subtitleTextView.setTranslationY((float) Math.floor(avatarY) + AndroidUtilities.dp(24) + (float) Math.floor(25 * AndroidUtilities.density) * diff);
|
||||
nameTextView.setScaleX(1.0f + 0.4f * diff);
|
||||
nameTextView.setScaleY(1.0f + 0.4f * diff);
|
||||
int width;
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
width = (int) (width - AndroidUtilities.dp(118 + 8 + 40 * (1.0f - diff)) - nameTextView.getTranslationX());
|
||||
float width2 = nameTextView.getPaint().measureText(nameTextView.getText().toString()) * nameTextView.getScaleX() + nameTextView.getSideDrawablesSize();
|
||||
layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
if (width < width2) {
|
||||
layoutParams.width = (int) Math.ceil(width / nameTextView.getScaleX());
|
||||
} else {
|
||||
layoutParams.width = LayoutHelper.WRAP_CONTENT;
|
||||
}
|
||||
nameTextView.setLayoutParams(layoutParams);
|
||||
|
||||
layoutParams = (FrameLayout.LayoutParams) subtitleTextView.getLayoutParams();
|
||||
layoutParams.rightMargin = (int) Math.ceil(subtitleTextView.getTranslationX() + AndroidUtilities.dp(8) + AndroidUtilities.dp(40) * (1.0f - diff));
|
||||
subtitleTextView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -875,173 +745,17 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
public void setPlayProfileAnimation(boolean value) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
if (!AndroidUtilities.isTablet() && preferences.getBoolean("view_animations2", true)) {
|
||||
playProfileAnimation = value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransitionAnimationStart(boolean isOpen, boolean backward) {
|
||||
if (!backward && playProfileAnimation && allowProfileAnimation) {
|
||||
openAnimationInProgress = true;
|
||||
}
|
||||
NotificationCenter.getInstance().setAllowedNotificationsDutingAnimation(new int[]{NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats});
|
||||
NotificationCenter.getInstance().setAnimationInProgress(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
if (!backward && playProfileAnimation && allowProfileAnimation) {
|
||||
openAnimationInProgress = false;
|
||||
}
|
||||
NotificationCenter.getInstance().setAnimationInProgress(false);
|
||||
}
|
||||
|
||||
public void setAnimationProgress(float progress) {
|
||||
//animationProgress = progress;
|
||||
listView.setAlpha(progress);
|
||||
|
||||
listView.setTranslationX(AndroidUtilities.dp(48) - AndroidUtilities.dp(48) * progress);
|
||||
int color = Theme.ACTION_BAR_COLOR;
|
||||
|
||||
int r = Color.red(Theme.ACTION_BAR_COLOR);
|
||||
int g = Color.green(Theme.ACTION_BAR_COLOR);
|
||||
int b = Color.blue(Theme.ACTION_BAR_COLOR);
|
||||
|
||||
int rD = (int) ((Color.red(color) - r) * progress);
|
||||
int gD = (int) ((Color.green(color) - g) * progress);
|
||||
int bD = (int) ((Color.blue(color) - b) * progress);
|
||||
topView.setBackgroundColor(Color.rgb(r + rD, g + gD, b + bD));
|
||||
color = Theme.ACTION_BAR_SUBTITLE_COLOR;
|
||||
|
||||
r = Color.red(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
g = Color.green(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
b = Color.blue(Theme.ACTION_BAR_SUBTITLE_COLOR);
|
||||
|
||||
rD = (int) ((Color.red(color) - r) * progress);
|
||||
gD = (int) ((Color.green(color) - g) * progress);
|
||||
bD = (int) ((Color.blue(color) - b) * progress);
|
||||
for (int a = 0; a < 2; a++) {
|
||||
if (onlineTextView[a] == null) {
|
||||
continue;
|
||||
}
|
||||
onlineTextView[a].setTextColor(Color.rgb(r + rD, g + gD, b + bD));
|
||||
}
|
||||
extraHeight = (int) (initialAnimationExtraHeight * progress);
|
||||
color = AvatarDrawable.getColorForId(user_id != 0 ? user_id : chat_id);
|
||||
int color2 = AvatarDrawable.getColorForId(user_id != 0 ? user_id : chat_id);
|
||||
if (color != color2) {
|
||||
rD = (int) ((Color.red(color) - Color.red(color2)) * progress);
|
||||
gD = (int) ((Color.green(color) - Color.green(color2)) * progress);
|
||||
bD = (int) ((Color.blue(color) - Color.blue(color2)) * progress);
|
||||
avatarDrawable.setColor_(Color.rgb(Color.red(color2) + rD, Color.green(color2) + gD, Color.blue(color2) + bD));
|
||||
avatarImage.invalidate();
|
||||
}
|
||||
|
||||
needLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AnimatorSet onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) {
|
||||
if (playProfileAnimation && allowProfileAnimation) {
|
||||
final AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.setDuration(180);
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
listView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
if (menu.getItem(10) == null) {
|
||||
if (animatingItem == null) {
|
||||
animatingItem = menu.addItem(10, R.drawable.ic_ab_other);
|
||||
}
|
||||
}
|
||||
if (isOpen) {
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) onlineTextView[1].getLayoutParams();
|
||||
layoutParams.rightMargin = (int) (-21 * AndroidUtilities.density + AndroidUtilities.dp(8));
|
||||
onlineTextView[1].setLayoutParams(layoutParams);
|
||||
|
||||
int width = (int) Math.ceil(AndroidUtilities.displaySize.x - AndroidUtilities.dp(118 + 8) + 21 * AndroidUtilities.density);
|
||||
float width2 = nameTextView[1].getPaint().measureText(nameTextView[1].getText().toString()) * 1.12f + nameTextView[1].getSideDrawablesSize();
|
||||
layoutParams = (FrameLayout.LayoutParams) nameTextView[1].getLayoutParams();
|
||||
if (width < width2) {
|
||||
layoutParams.width = (int) Math.ceil(width / 1.12f);
|
||||
} else {
|
||||
layoutParams.width = LayoutHelper.WRAP_CONTENT;
|
||||
}
|
||||
nameTextView[1].setLayoutParams(layoutParams);
|
||||
|
||||
initialAnimationExtraHeight = AndroidUtilities.dp(88);
|
||||
fragmentView.setBackgroundColor(0);
|
||||
setAnimationProgress(0);
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 0.0f, 1.0f));
|
||||
if (writeButton != null) {
|
||||
writeButton.setScaleX(0.2f);
|
||||
writeButton.setScaleY(0.2f);
|
||||
writeButton.setAlpha(0.0f);
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 1.0f));
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
onlineTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
|
||||
nameTextView[a].setAlpha(a == 0 ? 1.0f : 0.0f);
|
||||
animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 0.0f : 1.0f));
|
||||
}
|
||||
if (animatingItem != null) {
|
||||
animatingItem.setAlpha(1.0f);
|
||||
animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 0.0f));
|
||||
}
|
||||
animatorSet.playTogether(animators);
|
||||
} else {
|
||||
initialAnimationExtraHeight = extraHeight;
|
||||
ArrayList<Animator> animators = new ArrayList<>();
|
||||
animators.add(ObjectAnimator.ofFloat(this, "animationProgress", 1.0f, 0.0f));
|
||||
if (writeButton != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "scaleX", 0.2f));
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "scaleY", 0.2f));
|
||||
animators.add(ObjectAnimator.ofFloat(writeButton, "alpha", 0.0f));
|
||||
}
|
||||
for (int a = 0; a < 2; a++) {
|
||||
animators.add(ObjectAnimator.ofFloat(onlineTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
|
||||
animators.add(ObjectAnimator.ofFloat(nameTextView[a], "alpha", a == 0 ? 1.0f : 0.0f));
|
||||
}
|
||||
if (animatingItem != null) {
|
||||
animatingItem.setAlpha(0.0f);
|
||||
animators.add(ObjectAnimator.ofFloat(animatingItem, "alpha", 1.0f));
|
||||
}
|
||||
animatorSet.playTogether(animators);
|
||||
}
|
||||
animatorSet.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (Build.VERSION.SDK_INT > 15) {
|
||||
listView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
if (animatingItem != null) {
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.clearItems();
|
||||
animatingItem = null;
|
||||
}
|
||||
callback.run();
|
||||
}
|
||||
});
|
||||
animatorSet.setInterpolator(new DecelerateInterpolator());
|
||||
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
animatorSet.start();
|
||||
}
|
||||
}, 50);
|
||||
return animatorSet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePhotoAtIndex(int index) {
|
||||
|
||||
@@ -1180,6 +894,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
mrContact = MrMailbox.getContact(user_id);
|
||||
newString = mrContact.getDisplayName();
|
||||
newString2 = mrContact.getAddr();
|
||||
/*if( !newString.equals(mrContact.getAuthName()) ) { -- not sure if it is really useful to display the auth-name here
|
||||
newString += " (" + mrContact.getAuthName() + ")";
|
||||
}*/
|
||||
}
|
||||
else {
|
||||
mrChat = MrMailbox.getChat(chat_id);
|
||||
@@ -1187,16 +904,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
newString2 = mrChat.getSubtitle();
|
||||
}
|
||||
|
||||
for (int a = 0; a < 2; a++) {
|
||||
if (nameTextView[a] == null) {
|
||||
continue;
|
||||
}
|
||||
if (!nameTextView[a].getText().equals(newString)) {
|
||||
nameTextView[a].setText(newString);
|
||||
}
|
||||
if (!onlineTextView[a].getText().equals(newString2)) {
|
||||
onlineTextView[a].setText(newString2);
|
||||
}
|
||||
if (!nameTextView.getText().equals(newString)) {
|
||||
nameTextView.setText(newString);
|
||||
}
|
||||
if (!subtitleTextView.getText().equals(newString2)) {
|
||||
subtitleTextView.setText(newString2);
|
||||
}
|
||||
|
||||
ContactsController.setupAvatar(avatarImage, avatarImage.imageReceiver, avatarDrawable, mrContact, mrChat);
|
||||
@@ -1205,7 +917,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private void createActionBarMenu() {
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.clearItems();
|
||||
animatingItem = null;
|
||||
|
||||
ActionBarMenuItem item = menu.addItem(10, R.drawable.ic_ab_other);
|
||||
|
||||
@@ -1215,7 +926,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
if (user_id != 0) {
|
||||
item.addSubItem(ID_COPY_EMAIL_TO_CLIPBOARD, ApplicationLoader.applicationContext.getString(R.string.CopyToClipboard), 0);
|
||||
//item.addSubItem(ID_STOP_ENCRYPTION_FOR_THIS_USER, ApplicationLoader.applicationContext.getString(R.string.ResetContactsKey), 0); -- not needed by Autocrypt (?)
|
||||
item.addSubItem(ID_BLOCK_CONTACT, userBlocked()? ApplicationLoader.applicationContext.getString(R.string.UnblockContact) : ApplicationLoader.applicationContext.getString(R.string.BlockContact), 0);
|
||||
item.addSubItem(ID_DELETE_CONTACT, ApplicationLoader.applicationContext.getString(R.string.DeleteContact), 0);
|
||||
}
|
||||
@@ -1251,23 +961,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
case typeEmpty:
|
||||
view = new EmptyCell(mContext);
|
||||
break;
|
||||
case typeDivider:
|
||||
view = new DividerCell(mContext);
|
||||
view.setPadding(AndroidUtilities.dp(72), 0, 0, 0);
|
||||
break;
|
||||
case typeTextDetailCell:
|
||||
view = new TextDetailCell(mContext) {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (Build.VERSION.SDK_INT >= 21 && getBackground() != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
getBackground().setHotspot(event.getX(), event.getY());
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
};
|
||||
break;
|
||||
case typeTextCell:
|
||||
view = new TextCell(mContext) {
|
||||
@Override
|
||||
@@ -1310,12 +1003,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
if (i == emptyRowChat || i == emptyRowChat2) {
|
||||
((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(8));
|
||||
} else {
|
||||
((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(14)); // was 36 when we used the "writeButton" for taking photos etc.
|
||||
((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(14));
|
||||
}
|
||||
break;
|
||||
case typeTextDetailCell:
|
||||
TextDetailCell textDetailCell = (TextDetailCell) holder.itemView;
|
||||
break;
|
||||
case typeTextCell:
|
||||
TextCell textCell = (TextCell) holder.itemView;
|
||||
textCell.setTextColor(0xff212121);
|
||||
@@ -1379,8 +1069,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
public int getItemViewType(int i) {
|
||||
if (i == emptyRow || i == emptyRowChat || i == emptyRowChat2) {
|
||||
return typeEmpty;
|
||||
} else if (i == sectionRow || i == userSectionRow) {
|
||||
return typeDivider;
|
||||
} else if ( i == changeNameRow || i==compareKeysRow || i==startChatRow || i == settingsNotificationsRow || i == addMemberRow) {
|
||||
return typeTextCell;
|
||||
} else if (i >= firstMemberRow && i <= lastMemberRow) {
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (i == settingsVibrateRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.Vibrate));
|
||||
builder.setTitle(R.string.Vibrate);
|
||||
builder.setItems(new CharSequence[]{
|
||||
context.getString(R.string.Disabled),
|
||||
context.getString(R.string.Default),
|
||||
@@ -177,7 +177,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
if (getParentActivity() == null) {
|
||||
@@ -212,7 +212,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.notificationsSettingsUpdated);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (i == settingsSoundRow) {
|
||||
try {
|
||||
@@ -261,9 +261,9 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.LedColor));
|
||||
builder.setTitle(R.string.LedColor);
|
||||
builder.setView(linearLayout);
|
||||
builder.setPositiveButton(context.getString(R.string.Set), new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(R.string.Set, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -273,7 +273,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(context.getString(R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
builder.setNeutralButton(R.string.Disabled, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -283,7 +283,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Default), new DialogInterface.OnClickListener() {
|
||||
builder.setNegativeButton(R.string.Default, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -296,7 +296,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
showDialog(builder.create());
|
||||
} else if (i == settingsPriorityRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.NotificationsPriority));
|
||||
builder.setTitle(R.string.NotificationsPriority);
|
||||
builder.setItems(new CharSequence[]{
|
||||
context.getString(R.string.Default),
|
||||
context.getString(R.string.NotificationsPriorityDefault),
|
||||
@@ -317,7 +317,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (i == smartRow) {
|
||||
if (getParentActivity() == null) {
|
||||
@@ -412,9 +412,9 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
textView.setLayoutParams(layoutParams1);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.SmartNotifications));
|
||||
builder.setTitle(R.string.SmartNotifications);
|
||||
builder.setView(linearLayout);
|
||||
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -425,7 +425,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
builder.setNegativeButton(R.string.Disabled, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
|
||||
@@ -54,8 +54,6 @@ import com.b44t.ui.Cells.TextInfoCell;
|
||||
import com.b44t.ui.Cells.TextSettingsCell;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
|
||||
import static android.app.ProgressDialog.STYLE_HORIZONTAL;
|
||||
|
||||
|
||||
public class SettingsAccountActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
@@ -250,7 +248,7 @@ public class SettingsAccountActivity extends BaseFragment implements Notificatio
|
||||
else if( i==rowMailSecurity || i==rowSendSecurity )
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(ApplicationLoader.applicationContext.getString(R.string.SecurityTitle));
|
||||
builder.setTitle(R.string.SecurityTitle);
|
||||
builder.setItems(new CharSequence[]{
|
||||
ApplicationLoader.applicationContext.getString(R.string.Automatic),
|
||||
"SSL/TLS", /*1*/
|
||||
@@ -278,7 +276,7 @@ public class SettingsAccountActivity extends BaseFragment implements Notificatio
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
|
||||
}
|
||||
@@ -393,10 +391,6 @@ public class SettingsAccountActivity extends BaseFragment implements Notificatio
|
||||
if( (int)args[0]==1 ) {
|
||||
if (fromIntro) {
|
||||
presentFragment(new DialogsActivity(null), true);
|
||||
LaunchActivity la = ((LaunchActivity) getParentActivity());
|
||||
if (la != null) {
|
||||
la.drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
}
|
||||
} else {
|
||||
finishFragment();
|
||||
}
|
||||
@@ -406,12 +400,7 @@ public class SettingsAccountActivity extends BaseFragment implements Notificatio
|
||||
else if( ! MrMailbox.m_lastErrorString.isEmpty() ){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(errorString);
|
||||
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.OK, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
@@ -419,6 +408,7 @@ public class SettingsAccountActivity extends BaseFragment implements Notificatio
|
||||
|
||||
@Override
|
||||
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
// if the address is empty, automatically show the keyboard
|
||||
if (isOpen && addrCell!=null) {
|
||||
if(addrCell.getValue().isEmpty()) {
|
||||
addrCell.getEditTextView().requestFocus();
|
||||
|
||||
@@ -26,18 +26,13 @@
|
||||
|
||||
package com.b44t.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
@@ -46,24 +41,22 @@ import com.b44t.messenger.UserConfig;
|
||||
import com.b44t.messenger.browser.Browser;
|
||||
import com.b44t.ui.ActionBar.ActionBar;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.ActionBar.DrawerLayoutContainer;
|
||||
import com.b44t.ui.Adapters.BaseFragmentAdapter;
|
||||
import com.b44t.ui.Cells.DrawerProfileCell;
|
||||
import com.b44t.ui.Cells.SettingsProfileCell;
|
||||
import com.b44t.ui.Cells.HeaderCell;
|
||||
import com.b44t.ui.Cells.ShadowSectionCell;
|
||||
import com.b44t.ui.Cells.TextCheckCell;
|
||||
import com.b44t.ui.Cells.TextDetailSettingsCell;
|
||||
import com.b44t.ui.Cells.TextSettingsCell;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.Components.NumberPicker;
|
||||
|
||||
|
||||
public class SettingsActivity extends BaseFragment {
|
||||
|
||||
// the list
|
||||
private int profileRow, accountHeaderRow, usernameRow, accountShadowRow;
|
||||
private int settingsHeaderRow, notificationRow, backgroundRow, textSizeRow, advRow, settingsShadowRow;
|
||||
private int readReceiptsRow, blockedRow, passcodeRow;
|
||||
private int profileRow, nameAndStatusRow;
|
||||
private int notificationRow, backgroundRow, advRow, settingsShadowRow;
|
||||
private int readReceiptsRow, passcodeRow;
|
||||
private int aboutHeaderRow, aboutRow, inviteRow, helpRow, aboutShadowRow;
|
||||
private int rowCount;
|
||||
|
||||
@@ -75,6 +68,8 @@ public class SettingsActivity extends BaseFragment {
|
||||
private static final int ROWTYPE_CHECK = 5;
|
||||
private static final int ROWTYPE_COUNT = 6;
|
||||
|
||||
public final int MR_MDNS_DEFAULT_ENABLED = 1;
|
||||
|
||||
private ListView listView;
|
||||
|
||||
@Override
|
||||
@@ -84,50 +79,19 @@ public class SettingsActivity extends BaseFragment {
|
||||
|
||||
rowCount = 0;
|
||||
|
||||
if (DrawerLayoutContainer.USE_DRAWER) {
|
||||
profileRow = -1;
|
||||
accountHeaderRow = rowCount++;
|
||||
} else {
|
||||
profileRow = rowCount++;
|
||||
accountHeaderRow = -1;
|
||||
}
|
||||
|
||||
usernameRow = rowCount++;
|
||||
if (DrawerLayoutContainer.USE_DRAWER) {
|
||||
accountShadowRow = rowCount++;
|
||||
settingsHeaderRow = rowCount++;
|
||||
}
|
||||
else {
|
||||
accountShadowRow = -1;
|
||||
settingsHeaderRow = -1;
|
||||
}
|
||||
|
||||
if (DrawerLayoutContainer.USE_DRAWER) {
|
||||
notificationRow = rowCount++;
|
||||
backgroundRow = rowCount++;
|
||||
textSizeRow = rowCount++;
|
||||
}
|
||||
else {
|
||||
notificationRow = rowCount++;
|
||||
backgroundRow = rowCount++;
|
||||
textSizeRow = rowCount++;
|
||||
}
|
||||
readReceiptsRow=-1;
|
||||
passcodeRow = rowCount++;
|
||||
blockedRow = rowCount++;
|
||||
advRow = rowCount++;
|
||||
profileRow = rowCount++;
|
||||
nameAndStatusRow = rowCount++;
|
||||
notificationRow = rowCount++;
|
||||
backgroundRow = rowCount++;
|
||||
passcodeRow = rowCount++;
|
||||
readReceiptsRow = rowCount++;
|
||||
advRow = rowCount++;
|
||||
settingsShadowRow = rowCount++;
|
||||
|
||||
aboutHeaderRow = rowCount++;
|
||||
aboutRow = rowCount++;
|
||||
if( DrawerLayoutContainer.USE_DRAWER ) {
|
||||
inviteRow = -1;
|
||||
helpRow = -1;
|
||||
}
|
||||
else {
|
||||
inviteRow = rowCount++;
|
||||
helpRow = rowCount++;
|
||||
}
|
||||
inviteRow = rowCount++;
|
||||
helpRow = rowCount++;
|
||||
aboutShadowRow = rowCount++;
|
||||
|
||||
return true;
|
||||
@@ -168,12 +132,9 @@ public class SettingsActivity extends BaseFragment {
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) {
|
||||
if (i == usernameRow) {
|
||||
if (i == nameAndStatusRow) {
|
||||
presentFragment(new SettingsNameActivity());
|
||||
}
|
||||
else if (i == blockedRow) {
|
||||
presentFragment(new BlockedUsersActivity());
|
||||
}
|
||||
else if (i == passcodeRow) {
|
||||
if (UserConfig.passcodeHash.length() > 0) {
|
||||
presentFragment(new PasscodeActivity(PasscodeActivity.SCREEN2_ENTER_CODE2));
|
||||
@@ -183,7 +144,16 @@ public class SettingsActivity extends BaseFragment {
|
||||
}
|
||||
else if(i==readReceiptsRow )
|
||||
{
|
||||
Toast.makeText(getParentActivity(), ApplicationLoader.applicationContext.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
int oldval = MrMailbox.getConfigInt("mdns_enabled", MR_MDNS_DEFAULT_ENABLED);
|
||||
if( oldval == 1 ) {
|
||||
MrMailbox.setConfig("mdns_enabled", "0");
|
||||
}
|
||||
else {
|
||||
MrMailbox.setConfig("mdns_enabled", "1");
|
||||
}
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(oldval == 0);
|
||||
}
|
||||
}
|
||||
else if (i == notificationRow) {
|
||||
presentFragment(new SettingsNotificationsActivity());
|
||||
@@ -191,50 +161,11 @@ public class SettingsActivity extends BaseFragment {
|
||||
else if (i == backgroundRow) {
|
||||
presentFragment(new WallpapersActivity());
|
||||
}
|
||||
if (i == textSizeRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(ApplicationLoader.applicationContext.getString(R.string.TextSize));
|
||||
final NumberPicker numberPicker = new NumberPicker(getParentActivity());
|
||||
final int MIN_VAL = 12;
|
||||
final int MAX_VAL = 30;
|
||||
final int DEF_VAL = SettingsAdvActivity.defMsgFontSize();
|
||||
String displayValues[] = new String[MAX_VAL-MIN_VAL+1];
|
||||
for( int v = MIN_VAL; v <= MAX_VAL; v++ ) {
|
||||
String cur = String.format("%d", v);
|
||||
if( v==DEF_VAL ) {
|
||||
cur += " (" +ApplicationLoader.applicationContext.getString(R.string.Default)+ ")";
|
||||
}
|
||||
displayValues[v-MIN_VAL] = cur;
|
||||
}
|
||||
numberPicker.setMinValue(MIN_VAL);
|
||||
numberPicker.setMaxValue(MAX_VAL);
|
||||
numberPicker.setDisplayedValues(displayValues);
|
||||
numberPicker.setWrapSelectorWheel(false);
|
||||
numberPicker.setValue(ApplicationLoader.fontSize);
|
||||
builder.setView(numberPicker);
|
||||
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("msg_font_size", numberPicker.getValue());
|
||||
ApplicationLoader.fontSize = numberPicker.getValue();
|
||||
editor.apply();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
else if (i == advRow) {
|
||||
presentFragment(new SettingsAdvActivity());
|
||||
}
|
||||
else if (i == aboutRow ) {
|
||||
Intent intent2 = new Intent(getParentActivity(), IntroActivity.class);
|
||||
Intent intent2 = new Intent(getParentActivity(), WelcomeActivity.class);
|
||||
intent2.putExtra("com.b44t.ui.IntroActivity.isAbout", true);
|
||||
getParentActivity().startActivity(intent2);
|
||||
}
|
||||
@@ -272,8 +203,8 @@ public class SettingsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return i == textSizeRow || i == usernameRow ||
|
||||
i == blockedRow || i==passcodeRow || i==readReceiptsRow || i == notificationRow || i == backgroundRow || i == advRow ||
|
||||
return i == nameAndStatusRow ||
|
||||
i==passcodeRow || i==readReceiptsRow || i == notificationRow || i == backgroundRow || i == advRow ||
|
||||
i == aboutRow || i == inviteRow || i == helpRow;
|
||||
}
|
||||
|
||||
@@ -302,9 +233,9 @@ public class SettingsActivity extends BaseFragment {
|
||||
int type = getItemViewType(i);
|
||||
if( type == ROWTYPE_PROFILE ) {
|
||||
if (view == null) {
|
||||
view = new DrawerProfileCell(mContext);
|
||||
view = new SettingsProfileCell(mContext);
|
||||
}
|
||||
((DrawerProfileCell) view).updateUserName();
|
||||
((SettingsProfileCell) view).updateUserName();
|
||||
}
|
||||
else if (type == ROWTYPE_SHADOW) {
|
||||
if (view == null) {
|
||||
@@ -318,11 +249,7 @@ public class SettingsActivity extends BaseFragment {
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
TextSettingsCell textCell = (TextSettingsCell) view;
|
||||
if (i == blockedRow) {
|
||||
String cntStr = String.format("%d", MrMailbox.getBlockedCount());
|
||||
textCell.setTextAndValue(ApplicationLoader.applicationContext.getString(R.string.BlockedContacts), cntStr, true);
|
||||
}
|
||||
else if (i == passcodeRow) {
|
||||
if (i == passcodeRow) {
|
||||
String val = UserConfig.passcodeHash.length() > 0? mContext.getString(R.string.Enabled) : mContext.getString(R.string.Disabled);
|
||||
textCell.setTextAndValue(mContext.getString(R.string.Passcode), val, true);
|
||||
}
|
||||
@@ -337,11 +264,6 @@ public class SettingsActivity extends BaseFragment {
|
||||
else if (i == backgroundRow) {
|
||||
textCell.setText(mContext.getString(R.string.ChatBackground), true);
|
||||
}
|
||||
else if (i == textSizeRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int size = preferences.getInt("msg_font_size", SettingsAdvActivity.defMsgFontSize());
|
||||
textCell.setTextAndValue(mContext.getString(R.string.TextSize), String.format("%d", size), true);
|
||||
}
|
||||
else if (i == advRow) {
|
||||
textCell.setText(mContext.getString(R.string.AdvancedSettings), false);
|
||||
}
|
||||
@@ -351,12 +273,8 @@ public class SettingsActivity extends BaseFragment {
|
||||
else if(i == helpRow) {
|
||||
textCell.setText(mContext.getString(R.string.Help), false);
|
||||
}
|
||||
else if (i == usernameRow) {
|
||||
String value = MrMailbox.getConfig("displayname", "");
|
||||
if( value.isEmpty()) {
|
||||
value = mContext.getString(R.string.NotSet);
|
||||
}
|
||||
textCell.setTextAndValue(mContext.getString(R.string.MyName), value, true);
|
||||
else if (i == nameAndStatusRow) {
|
||||
textCell.setText(mContext.getString(R.string.NameAndStatus), true);
|
||||
}
|
||||
}
|
||||
else if (type == ROWTYPE_HEADER) {
|
||||
@@ -364,15 +282,9 @@ public class SettingsActivity extends BaseFragment {
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
if (i == settingsHeaderRow) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.Settings));
|
||||
}
|
||||
else if (i == aboutHeaderRow) {
|
||||
if (i == aboutHeaderRow) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.Info));
|
||||
}
|
||||
else if (i == accountHeaderRow) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.MyAccount));
|
||||
}
|
||||
}
|
||||
else if (type == ROWTYPE_DETAIL_SETTINGS) {
|
||||
if (view == null) {
|
||||
@@ -380,15 +292,8 @@ public class SettingsActivity extends BaseFragment {
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
TextDetailSettingsCell textCell = (TextDetailSettingsCell) view;
|
||||
if (i == usernameRow) {
|
||||
String subtitle = MrMailbox.getConfig("displayname", "");
|
||||
if( subtitle.isEmpty()) {
|
||||
subtitle = mContext.getString(R.string.NotSet);
|
||||
}
|
||||
textCell.setTextAndValue(mContext.getString(R.string.MyName), subtitle, true);
|
||||
}
|
||||
else if (i == aboutRow) {
|
||||
textCell.setTextAndValue(mContext.getString(R.string.AboutThisProgram), "v" + IntroActivity.getVersion(), true);
|
||||
if (i == aboutRow) {
|
||||
textCell.setTextAndValue(mContext.getString(R.string.AboutThisProgram), "v" + WelcomeActivity.getVersion(), true);
|
||||
}
|
||||
}
|
||||
else if (type == ROWTYPE_CHECK ) {
|
||||
@@ -399,7 +304,7 @@ public class SettingsActivity extends BaseFragment {
|
||||
TextCheckCell textCell = (TextCheckCell) view;
|
||||
if( i == readReceiptsRow ) {
|
||||
textCell.setTextAndCheck(mContext.getString(R.string.SendNRcvReadReceipts),
|
||||
MrMailbox.getConfigInt("read_receipts", 0)!=0, true);
|
||||
MrMailbox.getConfigInt("mdns_enabled", MR_MDNS_DEFAULT_ENABLED)!=0, true);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
@@ -410,13 +315,13 @@ public class SettingsActivity extends BaseFragment {
|
||||
if( i == profileRow ) {
|
||||
return ROWTYPE_PROFILE;
|
||||
}
|
||||
else if (i == accountShadowRow || i == settingsShadowRow || i == aboutShadowRow ) {
|
||||
else if ( i == settingsShadowRow || i == aboutShadowRow ) {
|
||||
return ROWTYPE_SHADOW;
|
||||
}
|
||||
else if ( (DrawerLayoutContainer.USE_DRAWER && (i==usernameRow)) || i==aboutRow ) {
|
||||
else if ( i==aboutRow ) {
|
||||
return ROWTYPE_DETAIL_SETTINGS;
|
||||
}
|
||||
else if (i == settingsHeaderRow || i == aboutHeaderRow || i == accountHeaderRow) {
|
||||
else if (i == aboutHeaderRow) {
|
||||
return ROWTYPE_HEADER;
|
||||
}
|
||||
else if( i==readReceiptsRow ) {
|
||||
|
||||
@@ -25,64 +25,90 @@ package com.b44t.ui;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.media.MediaScannerConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.text.InputType;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.MediaController;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.MrChat;
|
||||
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.HeaderCell;
|
||||
import com.b44t.ui.Cells.ShadowSectionCell;
|
||||
import com.b44t.ui.Cells.TextCheckCell;
|
||||
import com.b44t.ui.Cells.TextSettingsCell;
|
||||
import com.b44t.ui.ActionBar.ActionBar;
|
||||
import com.b44t.ui.ActionBar.BaseFragment;
|
||||
import com.b44t.ui.Components.LayoutHelper;
|
||||
import com.b44t.ui.Components.NumberPicker;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class SettingsAdvActivity extends BaseFragment {
|
||||
public class SettingsAdvActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
// the list
|
||||
private int directShareRow, cacheRow, raiseToSpeakRow, sendByEnterRow, autoplayGifsRow, showUnknownSendersRow, finalShadowRow;
|
||||
private int accountSettingsRow;
|
||||
private int directShareRow;
|
||||
private int cacheRow;
|
||||
private int autoplayGifsRow;
|
||||
private int textSizeRow;
|
||||
private int showUnknownSendersRow;
|
||||
private int sendByEnterRow;
|
||||
private int raiseToSpeakRow;
|
||||
private int blockedRow;
|
||||
private int e2eEncryptionRow;
|
||||
private int settingsShadowRow;
|
||||
|
||||
private int imexHeaderRow;
|
||||
private int manageKeysRow;
|
||||
private int backupRow;
|
||||
private int backupShadowRow;
|
||||
private int rowCount;
|
||||
|
||||
private static final int ROWTYPE_SHADOW = 0;
|
||||
private static final int ROWTYPE_TEXT_SETTINGS = 1;
|
||||
private static final int ROWTYPE_CHECK = 2;
|
||||
private static final int ROWTYPE_COUNT = 3;
|
||||
private static final int ROWTYPE_HEADER = 3;
|
||||
private static final int ROWTYPE_COUNT = 4;
|
||||
|
||||
private ListView listView;
|
||||
|
||||
public final int MR_E2EE_DEFAULT_ENABLED = 1; // when changing this constant, also change it in the C-part
|
||||
|
||||
private File imexDir;
|
||||
|
||||
public static int defMsgFontSize() {
|
||||
return AndroidUtilities.isTablet() ? 18 : 16;
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.imexEnded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.imexProgress);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.imexFileWritten);
|
||||
|
||||
rowCount = 0;
|
||||
accountSettingsRow = rowCount++;
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
@@ -91,19 +117,32 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
else {
|
||||
directShareRow = -1;
|
||||
}
|
||||
autoplayGifsRow = rowCount++;
|
||||
autoplayGifsRow = rowCount++;
|
||||
textSizeRow = rowCount++; // for now, we have the font size in the advanced settings; this is because the numberical selection is a little bit weird and does only affect the message text. It would be better to use the font size defined by the system with "sp" (Scale-independent Pixels which included the user's font size preference)
|
||||
showUnknownSendersRow = rowCount++;
|
||||
sendByEnterRow = rowCount++;
|
||||
raiseToSpeakRow = rowCount++; // outgoing message
|
||||
cacheRow = -1;// for now, the - non-functional - page is reachable by the "storage settings" in the "android App Settings" only
|
||||
sendByEnterRow = rowCount++;
|
||||
raiseToSpeakRow = rowCount++; // outgoing message
|
||||
cacheRow = -1;// for now, the - non-functional - page is reachable by the "storage settings" in the "android App Settings" only
|
||||
blockedRow = rowCount++;
|
||||
e2eEncryptionRow = rowCount++;
|
||||
settingsShadowRow = rowCount++;
|
||||
|
||||
imexHeaderRow = rowCount++;
|
||||
manageKeysRow = rowCount++;
|
||||
backupRow = rowCount++;
|
||||
finalShadowRow = rowCount++;
|
||||
backupRow = rowCount++;
|
||||
backupShadowRow = rowCount++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.imexEnded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.imexProgress);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.imexFileWritten);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context)
|
||||
{
|
||||
@@ -164,6 +203,9 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
} else if (i == cacheRow) {
|
||||
presentFragment(new CacheControlActivity());
|
||||
}
|
||||
else if (i == blockedRow) {
|
||||
presentFragment(new BlockedUsersActivity());
|
||||
}
|
||||
else if( i==showUnknownSendersRow) {
|
||||
int oldval = MrMailbox.getConfigInt("show_deaddrop", 0);
|
||||
if( oldval == 1 ) {
|
||||
@@ -202,52 +244,54 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
}
|
||||
else if(i==manageKeysRow )
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); // was: BottomSheet.Builder
|
||||
builder.setTitle(ApplicationLoader.applicationContext.getString(R.string.E2EManagePrivateKeys));
|
||||
CharSequence[] items = new CharSequence[]{
|
||||
ApplicationLoader.applicationContext.getString(R.string.ImportPrivateKeys),
|
||||
ApplicationLoader.applicationContext.getString(R.string.ExportPrivateKeys),
|
||||
};
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if( i== 0/*import*/ ) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder2 = new AlertDialog.Builder(getParentActivity());
|
||||
builder2.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
int cnt = MrMailbox.importStuff(MrMailbox.MR_IMEX_SELF_KEYS, downloadsDir.getAbsolutePath());
|
||||
String cntStr = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.ImportKeysDone, cnt, cnt);
|
||||
AndroidUtilities.showHint(ApplicationLoader.applicationContext, cntStr);
|
||||
}
|
||||
});
|
||||
builder2.setNegativeButton(ApplicationLoader.applicationContext.getString(R.string.Cancel), null);
|
||||
builder2.setMessage(ApplicationLoader.applicationContext.getString(R.string.ImportPrivateKeysAsk));
|
||||
showDialog(builder2.create());
|
||||
}
|
||||
else /*export*/ {
|
||||
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
downloadsDir.mkdirs();
|
||||
MrMailbox.exportStuff(MrMailbox.MR_IMEX_SELF_KEYS, downloadsDir.getAbsolutePath());
|
||||
AndroidUtilities.showDoneHint(ApplicationLoader.applicationContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
showDialog(builder.create());
|
||||
imexShowMenu(ApplicationLoader.applicationContext.getString(R.string.E2EManagePrivateKeys),
|
||||
MrMailbox.MR_IMEX_EXPORT_SELF_KEYS, ApplicationLoader.applicationContext.getString(R.string.ExportPrivateKeys),
|
||||
MrMailbox.MR_IMEX_IMPORT_SELF_KEYS, ApplicationLoader.applicationContext.getString(R.string.ImportPrivateKeys));
|
||||
}
|
||||
else if( i == backupRow )
|
||||
{
|
||||
Toast.makeText(getParentActivity(), ApplicationLoader.applicationContext.getString(R.string.NotYetImplemented), Toast.LENGTH_SHORT).show();
|
||||
imexShowMenu(ApplicationLoader.applicationContext.getString(R.string.Backup),
|
||||
MrMailbox.MR_IMEX_EXPORT_BACKUP, ApplicationLoader.applicationContext.getString(R.string.ExportBackup),
|
||||
0, ApplicationLoader.applicationContext.getString(R.string.ImportBackup));
|
||||
}
|
||||
else if (i == textSizeRow) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(R.string.TextSize);
|
||||
final NumberPicker numberPicker = new NumberPicker(getParentActivity());
|
||||
final int MIN_VAL = 12;
|
||||
final int MAX_VAL = 30;
|
||||
final int DEF_VAL = SettingsAdvActivity.defMsgFontSize();
|
||||
String displayValues[] = new String[MAX_VAL-MIN_VAL+1];
|
||||
for( int v = MIN_VAL; v <= MAX_VAL; v++ ) {
|
||||
String cur = String.format("%d", v);
|
||||
if( v==DEF_VAL ) {
|
||||
cur += " (" +ApplicationLoader.applicationContext.getString(R.string.Default)+ ")";
|
||||
}
|
||||
displayValues[v-MIN_VAL] = cur;
|
||||
}
|
||||
numberPicker.setMinValue(MIN_VAL);
|
||||
numberPicker.setMaxValue(MAX_VAL);
|
||||
numberPicker.setDisplayedValues(displayValues);
|
||||
numberPicker.setWrapSelectorWheel(false);
|
||||
numberPicker.setValue(ApplicationLoader.fontSize);
|
||||
builder.setView(numberPicker);
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("msg_font_size", numberPicker.getValue());
|
||||
ApplicationLoader.fontSize = numberPicker.getValue();
|
||||
editor.apply();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -255,6 +299,192 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
static public File getImexDir()
|
||||
{
|
||||
// DIRECTORY_DOCUMENTS is only available since KitKat; as we also support Ice Cream Sandwich and Jellybean (2017: 11% in total), this is no option
|
||||
// moreover, DIRECTORY_DOWNLOADS is easier accessible.
|
||||
// CAVE: do not use DownloadManager to add the file as it is deleted on uninstall then ...
|
||||
File imexDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||
return imexDir;
|
||||
}
|
||||
|
||||
private void imexShowMenu(String title, final int exportCommand, final String exportMenuEntry, final int importCommand, final String importMenuEntry)
|
||||
{
|
||||
imexDir = getImexDir();
|
||||
imexDir.mkdirs();
|
||||
imexDir.setExecutable(true);
|
||||
imexDir.setReadable(true);
|
||||
imexDir.setWritable(true);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); // was: BottomSheet.Builder
|
||||
builder.setTitle(title);
|
||||
CharSequence[] items = new CharSequence[]{exportMenuEntry, importMenuEntry};
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
/* when and why do we ask for a password on import/export?
|
||||
- we ask for a password on exporting private keys to prevent them from being stolen
|
||||
if the user hands out the device for a moment.
|
||||
this is important as esp. the user won't even recognise keys stolen this way.
|
||||
- we do _not_ ask for a password on import - of course, this can result in data loss, however,
|
||||
if the device is under control of an attacker he can also just delete all data.
|
||||
in difference to export, all these attacks are typically visible to the user.
|
||||
so, asking for a password here won't increase the security significally. */
|
||||
|
||||
if( i==0 ) /*export*/ {
|
||||
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builderPw = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
final EditText input = new EditText(getParentActivity());
|
||||
input.setSingleLine();
|
||||
|
||||
FrameLayout container = new FrameLayout(getParentActivity());
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.leftMargin = AndroidUtilities.dp(24);
|
||||
params.rightMargin = AndroidUtilities.dp(24);
|
||||
params.topMargin = AndroidUtilities.dp(16);
|
||||
input.setLayoutParams(params);
|
||||
input.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS| InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
container.addView(input);
|
||||
|
||||
builderPw.setView(container);
|
||||
builderPw.setTitle(exportMenuEntry);
|
||||
String enterPwMsg = String.format(ApplicationLoader.applicationContext.getString(R.string.ImportExportExplain)+"\n\n"+ApplicationLoader.applicationContext.getString(R.string.EnterPasswordToContinue), MrMailbox.getConfig("addr", ""));
|
||||
builderPw.setMessage(enterPwMsg);
|
||||
builderPw.setNegativeButton(R.string.Cancel, null);
|
||||
builderPw.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
String pw = input.getText().toString().trim();
|
||||
if( MrMailbox.checkPassword(pw)!=0 ) {
|
||||
startImex(exportCommand);
|
||||
}
|
||||
else {
|
||||
AndroidUtilities.showHint(ApplicationLoader.applicationContext, ApplicationLoader.applicationContext.getString(R.string.IncorrectPassword));
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builderPw.create());
|
||||
}
|
||||
else /*import*/ {
|
||||
if( importCommand ==MrMailbox.MR_IMEX_IMPORT_SELF_KEYS ) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder3 = new AlertDialog.Builder(getParentActivity());
|
||||
builder3.setTitle(importMenuEntry);
|
||||
builder3.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.ImportPrivateKeysAsk2), imexDir.getAbsolutePath())));
|
||||
builder3.setNegativeButton(R.string.Cancel, null);
|
||||
builder3.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
startImex(importCommand);
|
||||
}
|
||||
});
|
||||
showDialog(builder3.create());
|
||||
}
|
||||
else {
|
||||
AlertDialog.Builder builder3 = new AlertDialog.Builder(getParentActivity());
|
||||
builder3.setTitle(importMenuEntry);
|
||||
builder3.setPositiveButton(R.string.OK, null);
|
||||
builder3.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.ImportBackupExplain2), imexDir.getAbsolutePath())));
|
||||
showDialog(builder3.create());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
|
||||
private ProgressDialog progressDialog = null;
|
||||
private int progressWhat = 0;
|
||||
private void startImex(int what)
|
||||
{
|
||||
if( progressDialog!=null ) {
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
progressWhat = what;
|
||||
progressDialog = new ProgressDialog(getParentActivity());
|
||||
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment));
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, ApplicationLoader.applicationContext.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MrMailbox.imex(0, null);
|
||||
}
|
||||
});
|
||||
progressDialog.show();
|
||||
|
||||
synchronized (MrMailbox.m_lastErrorLock) {
|
||||
MrMailbox.m_showNextErrorAsToast = false;
|
||||
MrMailbox.m_lastErrorString = "";
|
||||
}
|
||||
|
||||
MrMailbox.imex(what, imexDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if( id==NotificationCenter.imexProgress ) {
|
||||
if( progressDialog!=null ) {
|
||||
// we want the spinner together with a progress info
|
||||
int percent = (Integer)args[0] / 10;
|
||||
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment)+String.format(" %d%%", percent));
|
||||
}
|
||||
}
|
||||
else if( id==NotificationCenter.imexFileWritten ) {
|
||||
// Force media scanner to scan the new file - otherwise, it may not be visible eg. via USB/MTP.
|
||||
// Do _not_ add the file with DownloadManager.addCompletedDownload() as the file would be deleted when the app is uninstalled. This frustrates the usecase export-uninstall-install-import.
|
||||
Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||
File permFile = new File((String)args[0]);
|
||||
Uri fileContentUri = Uri.fromFile(permFile);
|
||||
mediaScannerIntent.setData(fileContentUri);
|
||||
getParentActivity().sendBroadcast(mediaScannerIntent);
|
||||
}
|
||||
else if( id==NotificationCenter.imexEnded ) {
|
||||
final String errorString;
|
||||
|
||||
synchronized (MrMailbox.m_lastErrorLock) {
|
||||
MrMailbox.m_showNextErrorAsToast = true;
|
||||
errorString = MrMailbox.m_lastErrorString;
|
||||
}
|
||||
|
||||
if( progressDialog!=null ) {
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
|
||||
if( (int)args[0]==1 ) {
|
||||
// success
|
||||
if( progressWhat==MrMailbox.MR_IMEX_EXPORT_SELF_KEYS || progressWhat==MrMailbox.MR_IMEX_EXPORT_BACKUP ) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.FilesSuccessfullyExported), imexDir.getAbsoluteFile()) + "\n\n" + ApplicationLoader.applicationContext.getString(R.string.ImportExportExplain)));
|
||||
builder.setPositiveButton(R.string.OK, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
else {
|
||||
AndroidUtilities.showDoneHint(ApplicationLoader.applicationContext);
|
||||
}
|
||||
}
|
||||
else if( !errorString.isEmpty() ) {
|
||||
// error (errorString is empty when the user has cancelled the export manually, don't show a message in this case)
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(errorString);
|
||||
builder.setPositiveButton(R.string.OK, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
@@ -270,7 +500,7 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
int type = getItemViewType(i);
|
||||
return type!=ROWTYPE_SHADOW;
|
||||
return (type!=ROWTYPE_SHADOW && type!=ROWTYPE_HEADER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,9 +530,7 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
if (view == null) {
|
||||
view = new ShadowSectionCell(mContext);
|
||||
}
|
||||
if( i==finalShadowRow ) {
|
||||
view.setBackgroundResource(R.drawable.greydivider_bottom);
|
||||
}
|
||||
view.setBackgroundResource(i==backupShadowRow? R.drawable.greydivider_bottom : R.drawable.greydivider);
|
||||
} else if (type == ROWTYPE_TEXT_SETTINGS) {
|
||||
if (view == null) {
|
||||
view = new TextSettingsCell(mContext);
|
||||
@@ -312,6 +540,10 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
if (i == cacheRow) {
|
||||
textCell.setText(mContext.getString(R.string.CacheSettings), true);
|
||||
}
|
||||
else if (i == blockedRow) {
|
||||
String cntStr = String.format("%d", MrMailbox.getBlockedCount());
|
||||
textCell.setTextAndValue(ApplicationLoader.applicationContext.getString(R.string.BlockedContacts), cntStr, true);
|
||||
}
|
||||
else if( i==manageKeysRow ) {
|
||||
textCell.setText(mContext.getString(R.string.E2EManagePrivateKeys), true);
|
||||
}
|
||||
@@ -321,6 +553,11 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
else if( i == accountSettingsRow ) {
|
||||
textCell.setText(mContext.getString(R.string.AccountSettings), true);
|
||||
}
|
||||
else if (i == textSizeRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int size = preferences.getInt("msg_font_size", SettingsAdvActivity.defMsgFontSize());
|
||||
textCell.setTextAndValue(mContext.getString(R.string.TextSize), String.format("%d", size), true);
|
||||
}
|
||||
} else if (type == ROWTYPE_CHECK) {
|
||||
if (view == null) {
|
||||
view = new TextCheckCell(mContext);
|
||||
@@ -343,17 +580,29 @@ public class SettingsAdvActivity extends BaseFragment {
|
||||
MrMailbox.getConfigInt("show_deaddrop", 0)!=0, true);
|
||||
}
|
||||
else if( i == e2eEncryptionRow ) {
|
||||
textCell.setTextAndCheck(mContext.getString(R.string.E2EEncryption),
|
||||
MrMailbox.getConfigInt("e2ee_enabled", MR_E2EE_DEFAULT_ENABLED)!=0, true);
|
||||
textCell.setTextAndCheck(mContext.getString(R.string.PreferE2EEncryption),
|
||||
MrMailbox.getConfigInt("e2ee_enabled", MR_E2EE_DEFAULT_ENABLED)!=0, false);
|
||||
}
|
||||
}
|
||||
else if (type == ROWTYPE_HEADER) {
|
||||
if (view == null) {
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
if (i == imexHeaderRow) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.ExportImportHeader));
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == finalShadowRow ) {
|
||||
if (i== settingsShadowRow || i==backupShadowRow ) {
|
||||
return ROWTYPE_SHADOW;
|
||||
} else if( i==imexHeaderRow ) {
|
||||
return ROWTYPE_HEADER;
|
||||
} else if ( i == sendByEnterRow || i == raiseToSpeakRow || i == autoplayGifsRow || i==showUnknownSendersRow || i == directShareRow || i==e2eEncryptionRow) {
|
||||
return ROWTYPE_CHECK;
|
||||
} else {
|
||||
|
||||
@@ -56,16 +56,16 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
// the list
|
||||
private ListAdapter listAdapter;
|
||||
|
||||
private int rowNameTitle;
|
||||
private int rowDisplayname;
|
||||
private int rowDisplaynameInfo;
|
||||
private int rowDisplaynameHeadline, rowDisplayname, rowDisplaynameInfo;
|
||||
private int rowStatusHeadline, rowStatus, rowStatusInfo;
|
||||
private int rowCount;
|
||||
|
||||
private final int typeInfo = 0; // no gaps here!
|
||||
private final int typeTextEntry = 1;
|
||||
private final int typeSection = 2;
|
||||
private final int ROWTYPE_INFO = 0; // no gaps here!
|
||||
private final int ROWTYPE_TEXT_ENTRY = 1;
|
||||
private final int ROWTYPE_HEADLINE = 2;
|
||||
|
||||
EditTextCell displaynameCell; // warning all these objects may be null!
|
||||
private EditTextCell displaynameCell; // warning all these objects may be null!
|
||||
private EditTextCell statusCell;
|
||||
|
||||
// misc.
|
||||
private final static int done_button = 1;
|
||||
@@ -75,9 +75,14 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
super.onFragmentCreate();
|
||||
|
||||
rowCount = 0;
|
||||
rowNameTitle = -1; // rowCount++;
|
||||
rowDisplayname = rowCount++;
|
||||
rowDisplaynameInfo = rowCount++;
|
||||
|
||||
rowDisplaynameHeadline = rowCount++;
|
||||
rowDisplayname = rowCount++;
|
||||
rowDisplaynameInfo = rowCount++;
|
||||
|
||||
rowStatusHeadline = rowCount++;
|
||||
rowStatus = rowCount++;
|
||||
rowStatusInfo = rowCount++;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -93,7 +98,7 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
// create action bar
|
||||
actionBar.setBackButtonImage(R.drawable.ic_close_white);
|
||||
actionBar.setAllowOverlayTitle(true);
|
||||
actionBar.setTitle(context.getString(R.string.MyName));
|
||||
actionBar.setTitle(context.getString(R.string.NameAndStatus));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
@@ -143,11 +148,7 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(execute_result);
|
||||
builder.setPositiveButton(ApplicationLoader.applicationContext.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(R.string.OK, null);
|
||||
showDialog(builder.create());
|
||||
return;
|
||||
}
|
||||
@@ -155,21 +156,22 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
MrMailbox.setConfig("displayname", v.isEmpty() ? null : v);
|
||||
}
|
||||
|
||||
if( statusCell != null ) {
|
||||
String newstatus = statusCell.getValue().trim();
|
||||
String defstatus = ApplicationLoader.applicationContext.getString(R.string.DefaultStatusText);
|
||||
if( newstatus.equals(defstatus)) {
|
||||
MrMailbox.setConfig("selfstatus", null); // use default status
|
||||
}
|
||||
else {
|
||||
MrMailbox.setConfig("selfstatus", newstatus); // if v is empty, no status is send
|
||||
}
|
||||
}
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
|
||||
|
||||
finishFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
if (isOpen && displaynameCell!=null) {
|
||||
if(displaynameCell.getValue().isEmpty()) {
|
||||
displaynameCell.getEditTextView().requestFocus();
|
||||
AndroidUtilities.showKeyboard(displaynameCell.getEditTextView());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
@@ -184,7 +186,7 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return (i == rowDisplayname);
|
||||
return (i == rowDisplayname || i==rowStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,33 +212,51 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
int type = getItemViewType__(i);
|
||||
if (type == typeSection) {
|
||||
if (type == ROWTYPE_HEADLINE) {
|
||||
if (view == null) {
|
||||
view = new HeaderCell(mContext);
|
||||
view.setBackgroundColor(0xffffffff);
|
||||
}
|
||||
if (i == rowNameTitle) {
|
||||
if (i == rowDisplaynameHeadline) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.MyName));
|
||||
}
|
||||
else if (i == rowStatusHeadline) {
|
||||
((HeaderCell) view).setText(mContext.getString(R.string.MyStatus));
|
||||
}
|
||||
}
|
||||
else if (type == typeTextEntry) {
|
||||
else if (type == ROWTYPE_TEXT_ENTRY) {
|
||||
if (i == rowDisplayname) {
|
||||
if(displaynameCell==null) {
|
||||
displaynameCell = new EditTextCell(mContext);
|
||||
displaynameCell = new EditTextCell(mContext, false/*useLabel*/);
|
||||
displaynameCell.getEditTextView().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
|
||||
displaynameCell.setValueHintAndLabel(MrMailbox.getConfig("displayname", ""),
|
||||
"", "", true);
|
||||
}
|
||||
view = displaynameCell;
|
||||
}
|
||||
} else if (type == typeInfo) {
|
||||
else if (i == rowStatus) {
|
||||
if(statusCell==null) {
|
||||
String statusText = MrMailbox.getConfig("selfstatus", null);
|
||||
if( statusText == null ) {
|
||||
statusText = mContext.getString(R.string.DefaultStatusText);
|
||||
}
|
||||
statusCell = new EditTextCell(mContext, false/*useLabel*/, true/*multiLine*/);
|
||||
statusCell.setValueHintAndLabel(statusText, "", "", true);
|
||||
}
|
||||
view = statusCell;
|
||||
}
|
||||
} else if (type == ROWTYPE_INFO) {
|
||||
if (view == null) {
|
||||
view = new TextInfoCell(mContext);
|
||||
}
|
||||
if( i==rowDisplaynameInfo) {
|
||||
((TextInfoCell) view).setText(mContext.getString(R.string.MyNameExplain));
|
||||
view.setBackgroundResource(R.drawable.greydivider);
|
||||
}
|
||||
else if( i==rowStatusInfo) {
|
||||
((TextInfoCell) view).setText(mContext.getString(R.string.MyStatusExplain));
|
||||
view.setBackgroundResource(R.drawable.greydivider_bottom);
|
||||
}
|
||||
view.setBackgroundResource(R.drawable.greydivider_bottom);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@@ -247,13 +267,13 @@ public class SettingsNameActivity extends BaseFragment {
|
||||
}
|
||||
|
||||
private int getItemViewType__(int i) {
|
||||
if (i == rowDisplayname) {
|
||||
return typeTextEntry;
|
||||
if (i == rowDisplayname|| i==rowStatus ) {
|
||||
return ROWTYPE_TEXT_ENTRY;
|
||||
}
|
||||
else if(i==rowNameTitle) {
|
||||
return typeSection;
|
||||
else if(i==rowDisplaynameHeadline || i==rowStatusHeadline) {
|
||||
return ROWTYPE_HEADLINE;
|
||||
}
|
||||
return typeInfo;
|
||||
return ROWTYPE_INFO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -228,8 +228,8 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AskResetNotifications));
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setPositiveButton(context.getString(R.string.OK), new DialogInterface.OnClickListener() {
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -284,9 +284,9 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
colorPickerView.setColor(preferences.getInt(i == messageLedRow? "MessagesLed" : "GroupLed", NotificationsController.DEF_LED_COLOR));
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.LedColor));
|
||||
builder.setTitle(R.string.LedColor);
|
||||
builder.setView(linearLayout);
|
||||
builder.setPositiveButton(context.getString(R.string.Set), new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(R.string.Set, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -300,7 +300,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(context.getString(R.string.Disabled), new DialogInterface.OnClickListener() {
|
||||
builder.setNeutralButton(R.string.Disabled, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -314,7 +314,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
listView.invalidateViews();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Default), new DialogInterface.OnClickListener() {
|
||||
builder.setNegativeButton(R.string.Default, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
@@ -331,7 +331,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
showDialog(builder.create());
|
||||
} else if (i == messageVibrateRow || i == groupVibrateRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.Vibrate));
|
||||
builder.setTitle(R.string.Vibrate);
|
||||
builder.setItems(new CharSequence[]{
|
||||
context.getString(R.string.Disabled),
|
||||
context.getString(R.string.Default),
|
||||
@@ -364,11 +364,11 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (i == messagePriorityRow || i == groupPriorityRow || i == inappPriorityRow ) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.NotificationsPriority));
|
||||
builder.setTitle(R.string.NotificationsPriority);
|
||||
builder.setItems(new CharSequence[]{
|
||||
context.getString(R.string.NotificationsPriorityDefault),
|
||||
context.getString(R.string.NotificationsPriorityHigh),
|
||||
@@ -389,11 +389,11 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
} else if (i == repeatRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(context.getString(R.string.RepeatNotifications));
|
||||
builder.setTitle(R.string.RepeatNotifications);
|
||||
builder.setItems(new CharSequence[]{
|
||||
context.getString(R.string.Disabled),
|
||||
context.getResources().getQuantityString(R.plurals.Minutes, 5, 5),
|
||||
@@ -426,7 +426,7 @@ public class SettingsNotificationsActivity extends BaseFragment implements Notif
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(context.getString(R.string.Cancel), null);
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
if (view instanceof TextCheckCell) {
|
||||
|
||||
@@ -452,25 +452,16 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
||||
return;
|
||||
}
|
||||
int viewHeight;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
viewHeight = AndroidUtilities.dp(472);
|
||||
} else {
|
||||
viewHeight = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - ActionBar.getCurrentActionBarHeight();
|
||||
}
|
||||
viewHeight = AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - ActionBar.getCurrentActionBarHeight();
|
||||
|
||||
int width;
|
||||
int height;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
width = AndroidUtilities.dp(490);
|
||||
height = viewHeight - AndroidUtilities.dp(276);
|
||||
if (getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
width = AndroidUtilities.displaySize.x / 3 - AndroidUtilities.dp(24);
|
||||
height = viewHeight - AndroidUtilities.dp(32);
|
||||
} else {
|
||||
if (getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
width = AndroidUtilities.displaySize.x / 3 - AndroidUtilities.dp(24);
|
||||
height = viewHeight - AndroidUtilities.dp(32);
|
||||
} else {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
height = viewHeight - AndroidUtilities.dp(276);
|
||||
}
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
height = viewHeight - AndroidUtilities.dp(276);
|
||||
}
|
||||
|
||||
int vwidth = originalRotationValue == 90 || originalRotationValue == 270 ? originalHeight : originalWidth;
|
||||
@@ -499,7 +490,7 @@ public class VideoEditorActivity extends BaseFragment implements TextureView.Sur
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if (!AndroidUtilities.isTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
// landscape orientation
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) videoContainerView.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(16);
|
||||
|
||||
@@ -0,0 +1,390 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* 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.ui;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.b44t.messenger.AndroidUtilities;
|
||||
import com.b44t.messenger.ApplicationLoader;
|
||||
import com.b44t.messenger.BuildConfig;
|
||||
import com.b44t.messenger.LocaleController;
|
||||
import com.b44t.messenger.MrMailbox;
|
||||
import com.b44t.messenger.NotificationCenter;
|
||||
import com.b44t.messenger.R;
|
||||
import com.b44t.ui.ActionBar.Theme;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static java.lang.Math.min;
|
||||
|
||||
public class WelcomeActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private boolean isAbout = false;
|
||||
private final static int NUM_PAGES = 7;
|
||||
private final static int REQ_PERMISSION_CODE = 42;
|
||||
|
||||
private static final String TAG = "WelcomeActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(R.style.Theme_MessengerProj);
|
||||
super.onCreate(savedInstanceState);
|
||||
Theme.loadRecources(this);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.imexProgress);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.imexEnded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.configureEnded);
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if( extras != null && extras.getBoolean("com.b44t.ui.IntroActivity.isAbout") ) {
|
||||
isAbout = true;
|
||||
}
|
||||
|
||||
float heightOnLandscape = min(AndroidUtilities.displaySize.x,AndroidUtilities.displaySize.y)/AndroidUtilities.density;
|
||||
if( heightOnLandscape < 450 ) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
|
||||
setContentView(R.layout.welcome_layout);
|
||||
|
||||
ViewPager viewPager = (ViewPager) findViewById(R.id.welcome_pager);
|
||||
Button primaryButton = (Button) findViewById(R.id.welcome_primary_button);
|
||||
TextView secondaryButton = (TextView) findViewById(R.id.welcome_secondary_button);
|
||||
|
||||
if( isAbout ) {
|
||||
primaryButton.setText(ApplicationLoader.applicationContext.getString(R.string.OK));
|
||||
primaryButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
secondaryButton.setText("v" + getVersion() + " | " + ApplicationLoader.applicationContext.getString(R.string.Info));
|
||||
secondaryButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new AlertDialog.Builder(WelcomeActivity.this)
|
||||
.setTitle(ApplicationLoader.applicationContext.getString(R.string.AppName) + " v" + getVersion())
|
||||
.setMessage("© 2017 Delta Chat contributors" + "\n\n" + MrMailbox.getInfo() + "\n\n" + getAndroidInfo())
|
||||
.setPositiveButton(R.string.OK, null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
primaryButton.setText(ApplicationLoader.applicationContext.getString(R.string.IntroStartMessaging));
|
||||
primaryButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent2 = new Intent(WelcomeActivity.this, LaunchActivity.class);
|
||||
intent2.putExtra("fromIntro", true);
|
||||
startActivity(intent2);
|
||||
}
|
||||
});
|
||||
|
||||
secondaryButton.setText(ApplicationLoader.applicationContext.getString(R.string.ImportBackup));
|
||||
secondaryButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQ_PERMISSION_CODE);
|
||||
return;
|
||||
}
|
||||
tryToStartImport();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
viewPager.setAdapter(new IntroAdapter());
|
||||
viewPager.setPageMargin(0);
|
||||
viewPager.setCurrentItem(LocaleController.isRTL? NUM_PAGES-1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.imexProgress);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.imexEnded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.configureEnded);
|
||||
}
|
||||
|
||||
private class IntroAdapter extends PagerAdapter {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NUM_PAGES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = View.inflate(container.getContext(), R.layout.welcome_page_layout, null);
|
||||
ImageView imgView = (ImageView)view.findViewById(R.id.welcome_img);
|
||||
TextView titleView = (TextView) view.findViewById(R.id.welcome_title);
|
||||
TextView msgView = (TextView) view.findViewById(R.id.welcome_msg);
|
||||
container.addView(view, 0);
|
||||
|
||||
int icons[] = new int[]{R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4, R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 };
|
||||
int titles[] = new int[]{ R.string.Intro1Headline, R.string.Intro2Headline, R.string.Intro3Headline, R.string.Intro4Headline, R.string.Intro5Headline, R.string.Intro6Headline, R.string.Intro7Headline };
|
||||
int messages[] = new int[]{ R.string.Intro1Message, R.string.Intro2Message, R.string.Intro3Message,R.string.Intro4Message, R.string.Intro5Message, R.string.Intro6Message, R.string.Intro7Message };
|
||||
|
||||
if( LocaleController.isRTL ) {
|
||||
position = NUM_PAGES-1-position;
|
||||
}
|
||||
|
||||
imgView.setImageResource(icons[position]);
|
||||
titleView.setText(getString(titles[position]));
|
||||
msgView.setText(AndroidUtilities.replaceTags(getString(messages[position])));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
||||
super.setPrimaryItem(container, position, object);
|
||||
ViewGroup bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
|
||||
int count = bottomPages.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = bottomPages.getChildAt(a);
|
||||
if (a == position) {
|
||||
child.setBackgroundColor(0xff2ca5e0);
|
||||
} else {
|
||||
child.setBackgroundColor(0xffcccccc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view.equals(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
container.removeView((View) object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Specials for the use as the about-screen
|
||||
**********************************************************************************************/
|
||||
|
||||
public static String getVersion()
|
||||
{
|
||||
try {
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
return pInfo.versionName;
|
||||
}
|
||||
catch(Exception e) {
|
||||
return "ErrVersion";
|
||||
}
|
||||
}
|
||||
|
||||
private String getAndroidInfo()
|
||||
{
|
||||
String abi = "ErrAbi";
|
||||
int versionCode = 0, ignoreBatteryOptimizations = -1;
|
||||
try {
|
||||
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
||||
versionCode = pInfo.versionCode;
|
||||
switch (versionCode % 10) {
|
||||
case 0:
|
||||
abi = "arm";
|
||||
break;
|
||||
case 1:
|
||||
abi = "arm-v7a";
|
||||
break;
|
||||
case 2:
|
||||
abi = "x86";
|
||||
break;
|
||||
case 3:
|
||||
abi = "universal";
|
||||
break;
|
||||
}
|
||||
if( Build.VERSION.SDK_INT >= 23 ) {
|
||||
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
ignoreBatteryOptimizations = pm.isIgnoringBatteryOptimizations(ApplicationLoader.applicationContext.getPackageName())? 1 : 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Cannot get package info.", e);
|
||||
}
|
||||
|
||||
return "SDK_INT=" + Build.VERSION.SDK_INT
|
||||
+ "\nMANUFACTURER=" + Build.MANUFACTURER
|
||||
+ "\nMODEL=" + Build.MODEL
|
||||
+ "\nAPPLICATION_ID=" + BuildConfig.APPLICATION_ID
|
||||
+ "\nBUILD_TYPE=" + BuildConfig.BUILD_TYPE
|
||||
+ "\nABI=" + abi // ABI = Application Binary Interface
|
||||
+ "\nignoreBatteryOptimizations=" + ignoreBatteryOptimizations
|
||||
+ "\nversionCode=" + versionCode;
|
||||
}
|
||||
|
||||
|
||||
/* Specials for importing and configuration
|
||||
**********************************************************************************************/
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); // this may forward the notification to fragments
|
||||
if (requestCode == REQ_PERMISSION_CODE
|
||||
&& grantResults.length > 0
|
||||
&& grantResults[0]==PackageManager.PERMISSION_GRANTED ) {
|
||||
tryToStartImport();
|
||||
}
|
||||
else {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(ApplicationLoader.applicationContext.getString(R.string.PermissionStorage))
|
||||
.setPositiveButton(R.string.PermissionOpenSettings, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
// the settings button is needed as the user may have selected "do not ask again" and
|
||||
// may get in trouble to activate the feature otherwise ...
|
||||
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Cannot open app settings.", e);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.Cancel, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void tryToStartImport() {
|
||||
File imexDir = SettingsAdvActivity.getImexDir();
|
||||
final String backupFile = MrMailbox.imexHasBackup(imexDir.getAbsolutePath());
|
||||
if (backupFile != null) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.ImportBackup)
|
||||
.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.ImportBackupAsk), backupFile)))
|
||||
.setNegativeButton(R.string.Cancel, null)
|
||||
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
startImport(backupFile);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
else {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.ImportBackup)
|
||||
.setMessage(AndroidUtilities.replaceTags(String.format(ApplicationLoader.applicationContext.getString(R.string.NoBackupFound), imexDir.getAbsolutePath())))
|
||||
.setPositiveButton(R.string.OK, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
private ProgressDialog progressDialog = null;
|
||||
private void startImport(String backupFile)
|
||||
{
|
||||
if( progressDialog!=null ) {
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
|
||||
progressDialog = new ProgressDialog(this);
|
||||
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment));
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, ApplicationLoader.applicationContext.getString(R.string.Cancel), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
MrMailbox.imex(0, null);
|
||||
}
|
||||
});
|
||||
progressDialog.show();
|
||||
|
||||
synchronized (MrMailbox.m_lastErrorLock) {
|
||||
MrMailbox.m_showNextErrorAsToast = false;
|
||||
MrMailbox.m_lastErrorString = "";
|
||||
}
|
||||
|
||||
MrMailbox.imex(MrMailbox.MR_IMEX_IMPORT_BACKUP, backupFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == NotificationCenter.imexProgress) {
|
||||
// we want the spinner together with a progress info
|
||||
int percent = (Integer)args[0] / 10;
|
||||
progressDialog.setMessage(ApplicationLoader.applicationContext.getString(R.string.OneMoment)+String.format(" %d%%", percent));
|
||||
} else if (id == NotificationCenter.imexEnded) {
|
||||
|
||||
final String errorString;
|
||||
|
||||
synchronized (MrMailbox.m_lastErrorLock) {
|
||||
MrMailbox.m_showNextErrorAsToast = true;
|
||||
errorString = MrMailbox.m_lastErrorString;
|
||||
}
|
||||
|
||||
if( progressDialog!=null ) {
|
||||
progressDialog.dismiss();
|
||||
progressDialog = null;
|
||||
}
|
||||
|
||||
if( (int)args[0]==1 ) {
|
||||
startActivity(new Intent(WelcomeActivity.this, LaunchActivity.class));
|
||||
finish();
|
||||
}
|
||||
else if( !errorString.isEmpty() /*usually empty if export is cancelled by the user*/ ) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.ImportBackup)
|
||||
.setMessage(errorString)
|
||||
.setPositiveButton(R.string.OK, null)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
else if(id == NotificationCenter.configureEnded ) {
|
||||
// no need to start a new activitiy, this is done in SettingsAccountActivity(), just close self
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha android:fromAlpha="0.0"
|
||||
android:toAlpha="1.0"
|
||||
android:duration="200"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
|
||||
</set>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<alpha android:fromAlpha="1.0"
|
||||
android:toAlpha="0.0"
|
||||
android:duration="200"
|
||||
android:interpolator="@android:anim/accelerate_decelerate_interpolator"/>
|
||||
</set>
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 689 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 436 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 193 B |
|
Before Width: | Height: | Size: 466 B |
|
Before Width: | Height: | Size: 942 B |
|
After Width: | Height: | Size: 369 B |
|
After Width: | Height: | Size: 304 B |
|
After Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 459 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 306 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 935 B |