Compare commits

...

206 Commits

Author SHA1 Message Date
B. Petersen e4b24b0d99 Typo 2017-10-08 23:26:15 +02:00
B. Petersen 989fcd9564 Update messenger-backend submodule. 2017-10-08 23:22:46 +02:00
B. Petersen 4877ef1407 Changelog. 2017-10-08 23:21:26 +02:00
B. Petersen c1487e3f74 Language fixes. 2017-10-08 23:08:40 +02:00
B. Petersen 6d4650bba9 Update Portuguese. 2017-10-08 23:02:56 +02:00
B. Petersen fb6f02696d Update Italian. 2017-10-08 22:59:56 +02:00
B. Petersen 8ed4abebb7 Update French. 2017-10-08 22:58:45 +02:00
B. Petersen f90de9c0de Update Ukrainian. 2017-10-08 22:57:22 +02:00
B. Petersen 206d2a58d2 Update polish. 2017-10-08 22:55:02 +02:00
B. Petersen 6001d2fb3a Update russian. 2017-10-08 22:53:29 +02:00
B. Petersen 1ceab73dfe Update German. 2017-10-08 22:52:29 +02:00
B. Petersen dc38b949a8 Changelog 2017-10-08 22:52:19 +02:00
B. Petersen 96b740d4da Make exported files visible to USB/MTP. 2017-10-08 21:58:41 +02:00
B. Petersen 1455f7849b The 'Back' button works in the welcome-screen as expected. 2017-10-08 14:01:37 +02:00
B. Petersen 7f14a4da90 Code cleanup. 2017-10-08 12:09:51 +02:00
B. Petersen 0d04064969 Code cleanup. 2017-10-08 12:06:12 +02:00
B. Petersen 37fbda3126 Changelog 2017-10-08 00:23:26 +02:00
B. Petersen 023e62fbd4 Import backups. 2017-10-08 00:22:40 +02:00
B. Petersen b818007398 Update messenger-backend submodule. 2017-10-06 00:58:57 +02:00
B. Petersen 7c1bb82dd4 Prepare import functionality. 2017-10-06 00:58:43 +02:00
B. Petersen e3a6fa4cac Code cleanup. 2017-10-03 22:35:23 +02:00
B. Petersen 6e6aa88b3a Do not query password before import. 2017-10-03 18:12:12 +02:00
B. Petersen c266bd6eba Query password before import. 2017-10-03 14:46:37 +02:00
B. Petersen e383c2b79a Clearify string meaning. 2017-10-03 13:12:34 +02:00
B. Petersen 56a5b23d98 Cleanup 2017-10-03 00:14:41 +02:00
B. Petersen 10eb41aca7 Merge branch 'master' of https://github.com/deltachat/deltachat-android 2017-10-02 21:11:57 +02:00
B. Petersen a0a50e3433 Query password before exporting anything. 2017-10-02 21:11:43 +02:00
Björn Petersen 07449e9018 Merge pull request #171 from Ampli-fier/master
Intro5 Message updates in strings.xml (de)
2017-10-02 16:35:50 +02:00
Ampli-fier 5027373b54 Intro5 Message updates in strings.xml (de)
To align with (coming) web updates
2017-09-30 19:51:24 +02:00
B. Petersen 1d1e08fc15 Add backup function. 2017-09-29 18:30:15 +02:00
Björn Petersen 6eabf32464 Update README.md 2017-09-28 22:04:28 +02:00
B. Petersen acb4a2e5a0 Update messenger-backend submodule. 2017-09-24 21:42:39 +02:00
B. Petersen ba1b5211a2 Try to improve battery usage. 2017-09-24 14:02:29 +02:00
B. Petersen eb8d248fd9 Update messenger-backend submodule. 2017-09-19 11:37:16 +02:00
B. Petersen f248a86ce2 Add C file. 2017-09-19 11:36:26 +02:00
B. Petersen 8e9b55958d Changelog 2017-09-18 00:16:21 +02:00
B. Petersen 6decd0ee76 Changelog 2017-09-12 19:52:52 +02:00
B. Petersen 16384c12c2 Update grade. 2017-09-04 13:18:33 +02:00
B. Petersen 9be5c50e31 Add a section about how to setup a development environment. 2017-09-03 01:50:19 +02:00
B. Petersen 46421d8821 A little hack: Disable sqlite's WAL (Write-ahead-log) as it uses a possibly weired pointer reference to mmap 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) 2017-09-03 01:47:13 +02:00
B. Petersen 13cb356aef Bump version. 2017-09-03 01:44:56 +02:00
B. Petersen b210b72460 APP_PLATFORM android-9 is unsupported. Using minimum supported version android-14 (same as used for the Java part). 2017-09-03 00:30:22 +02:00
B. Petersen 6aa63f48e1 Add URL to default footer. 2017-08-27 14:13:14 +02:00
B. Petersen eaba4a4ab7 Changelog 2017-08-26 13:23:07 +02:00
B. Petersen fbc61bce2a Update messenger-backend submodule. 2017-08-23 21:58:26 +02:00
B. Petersen 5c98e34966 Changelog. 2017-08-23 21:58:00 +02:00
B. Petersen 9b461d372d Update German, Spanish, French, Hungarian, Italian, Polish, Portuguese and Russian translations from Transifex. 2017-08-23 21:48:41 +02:00
B. Petersen b57a81c7c2 Add Catalan translation. 2017-08-23 21:46:46 +02:00
B. Petersen 7cf41805ec Add Telugu translation. 2017-08-23 21:42:29 +02:00
B. Petersen 59efa059fd Add Ukrainian translation. 2017-08-23 21:35:46 +02:00
Björn Petersen e462d66746 Update README.md 2017-08-23 18:50:42 +02:00
Björn Petersen cd0c3f533a Merge pull request #147 from Poussinou/master
Update README.md
2017-08-23 18:49:18 +02:00
B. Petersen 0027b17ef9 Remove badge counter on app restart. 2017-08-23 18:42:06 +02:00
Poussinou 9ee5325f29 Update README.md 2017-07-31 16:34:46 +02:00
B. Petersen ac433edcf8 Do no spread the original authors name nor address when forwarding messages. 2017-07-28 17:56:13 +02:00
B. Petersen f71e7e58e1 Clearify submodule usage. 2017-07-28 14:47:52 +02:00
B. Petersen 4af1e9263a Add submodule hint to readme. 2017-07-28 11:53:36 +02:00
B. Petersen 01d3a75faa Changelog 2017-07-27 10:56:23 +02:00
B. Petersen d015ab4e93 Typo 2017-07-26 22:12:38 +02:00
B. Petersen abcf3600a6 Add 'Blocked users' to advanced settings as it is no preferred way to block users from here or to unblock some. The preferred way is to use the 'Block user' option in the profile of the user to block. 2017-07-26 20:19:19 +02:00
Björn Petersen ac6c497721 Merge pull request #131 from vitalyster/debugkeystore
gradle: use default debug keystore if there is no configured one
2017-07-26 17:38:06 +02:00
Vitaly Takmazov 2dafecc665 gradle: use default debug keystore if there is no configured one 2017-07-26 11:53:57 +03:00
B. Petersen 3a48f0a04a Allow emoticons in avatars. 2017-07-26 01:27:01 +02:00
B. Petersen 1caf3a8956 Explain why debug.keyfile is in separate directory. 2017-07-26 01:00:45 +02:00
B. Petersen ba1dd07b01 Revert "gradle: use default debug keystore path" because it allows using the same debug.keystore file on different machines which is needed to use testing devices with chats wich will be lost when using different debug.keystore files on different developer machines.
This reverts commit e357786980.
2017-07-26 00:48:12 +02:00
Björn Petersen 695a97276f Merge pull request #128 from vitalyster/debugkeystore
gradle: use default debug keystore path
2017-07-26 00:15:04 +02:00
B. Petersen 0d50753754 Cleanup AvatarDrawable code. 2017-07-26 00:06:10 +02:00
Vitaly Takmazov e357786980 gradle: use default debug keystore path 2017-07-25 22:36:32 +03:00
B. Petersen 54ab0ba860 Update messenger-backend submodule. 2017-07-25 21:28:39 +02:00
B. Petersen 44675fffe5 Cleanup code. 2017-07-25 20:04:35 +02:00
B. Petersen e5c6fb0e50 Wording 2017-07-25 15:39:40 +02:00
B. Petersen 82666fb5f0 Ask before deleting the group image. 2017-07-25 15:28:26 +02:00
B. Petersen 9ab86ca310 Use group profile image. 2017-07-22 19:37:35 +02:00
B. Petersen 7153b4c7be Let the user select group images and send message. 2017-07-22 14:47:18 +02:00
B. Petersen e73f4f30cb Add an extra text for 'Group image deleted'. 2017-07-22 14:09:54 +02:00
B. Petersen e365a20d6e Show text 'Group image changed.' beside such action images. 2017-07-22 13:32:58 +02:00
B. Petersen 4a9f9eefd2 Remove dead code. 2017-07-22 12:55:29 +02:00
B. Petersen 2ff632bb87 Do not edit avatar of contact requests & Co. 2017-07-21 17:43:59 +02:00
B. Petersen f5be0708be Add 'Edit image' menu to profile. 2017-07-21 17:32:54 +02:00
B. Petersen 92908ab673 Remove unused resources. 2017-07-21 16:53:33 +02:00
B. Petersen c20f8699f3 Comment 2017-07-21 16:47:30 +02:00
B. Petersen 81e60a3916 Simplify profile animation. 2017-07-21 16:23:19 +02:00
B. Petersen 4f8e25a6c0 Simplify profile animation. 2017-07-21 16:12:26 +02:00
B. Petersen 4038088c5f Remove dead code. 2017-07-21 15:39:47 +02:00
B. Petersen bc972faf2a Allow status text being in the state 'default status'. 2017-07-21 12:29:31 +02:00
B. Petersen 0720fec295 Do not change cursors etc., just use the system defaults. 2017-07-21 02:11:47 +02:00
B. Petersen fba37c7c12 Check for null-pointers. 2017-07-21 01:58:04 +02:00
B. Petersen debaa48e58 Simplify create/rename contact/groups dialogs. 2017-07-21 01:34:22 +02:00
Björn Petersen c4a63657cd Merge pull request #122 from deltachat/newstatus
Newstatus
2017-07-20 21:55:38 +02:00
Björn Petersen a723783c01 Update README.md 2017-07-20 21:00:38 +02:00
B. Petersen 26a922e16a Remove avatar from group creation (This and other secondary settings can be done in the group profile later). 2017-07-17 14:31:28 +02:00
B. Petersen 9a20d33d55 Remove unused resources. 2017-07-17 13:32:14 +02:00
B. Petersen 3abe9946d4 Make status text editable. 2017-07-17 00:40:35 +02:00
B. Petersen dcf4857b6e Remove tablet conditions from launcher.
Remove some isTablet()-calls.

Remove rest isTablet() code.
2017-07-16 22:01:06 +02:00
B. Petersen 701ae43bd6 Remove drawer functionality.
Remove open/close drawer functions.

Remove MenuDrawable.

Remove DrawerLayoutContainer.drawChild(), not sure, if this is needed.

Remove DrawerLayoutAdapter.

Remove menu_shadow drawable.

Cleanup drawer drawing.

Remove ManageSpaceActivity.

Rename DrawerProfileCell to SettingsProfileCell.

Remove title overlay.

Remove drawer from action bar.

Rename DrawerLayoutContainer to LaunchLayoutContainer.

Add LaunchLayoutContainer file.
2017-07-15 19:48:28 +02:00
B. Petersen cb67d0a45b Changelog. 2017-07-15 13:10:41 +02:00
B. Petersen 1684bc3acc Bump version. 2017-07-14 13:52:55 +02:00
B. Petersen ee32ef2f09 Update messenger-backend submodule. 2017-07-13 23:32:56 +02:00
B. Petersen c9ed86a81a Update Polish. 2017-07-13 23:30:50 +02:00
B. Petersen 8421e85229 Wording. 2017-07-13 23:12:15 +02:00
B. Petersen 0b2eead1be Changelog 2017-07-13 18:16:36 +02:00
B. Petersen 0d30d4a4f3 Changelog 2017-07-12 18:16:43 +02:00
B. Petersen ac55638e46 Update Portuguese. 2017-07-07 13:48:13 +02:00
B. Petersen e57c45da71 Rename 'Read receipt' to 'MDN'. 2017-07-05 17:00:27 +02:00
B. Petersen 4b93e2e57c Wording 2017-07-05 14:08:55 +02:00
B. Petersen 2bab5a65f4 Localize. 2017-07-04 23:07:41 +02:00
B. Petersen 66f379f80b Move MIME creation to new mrmimefactory class. 2017-07-04 01:40:32 +02:00
B. Petersen 4a8749349f Changing incoming message states from unseen/seen to fresh/noticed/seen. 2017-07-03 23:35:16 +02:00
B. Petersen 54fe2accb6 Wording 2017-06-29 22:27:40 +02:00
B. Petersen ec21b57106 Request read receipts. 2017-06-29 16:39:29 +02:00
B. Petersen 9e62523b6d Bump version. 2017-06-29 14:24:00 +02:00
B. Petersen 2b69ba5716 Correct russian plural forms, thanks to @guland2000 2017-06-29 00:51:25 +02:00
B. Petersen dadfecf8f3 Changelog. 2017-06-28 18:48:04 +02:00
B. Petersen e5695194d5 Update messenger-backend submodule. 2017-06-28 18:42:56 +02:00
B. Petersen e1c192ddd3 Changelog. 2017-06-28 18:40:41 +02:00
B. Petersen ee5e6cb125 Add deprecated export routines, for now. 2017-06-28 18:28:01 +02:00
Björn Petersen 5ca9bbff28 Update README.md 2017-06-28 12:49:08 +02:00
B. Petersen 1761335092 Add missing russian plural forms. 2017-06-27 14:03:31 +02:00
Björn Petersen b87e135b3c Update CHANGELOG.md 2017-06-26 01:20:43 +02:00
Björn Petersen c1154a87cc Update CHANGELOG.md 2017-06-23 18:29:01 +02:00
B. Petersen a683880f7e Changelog 2017-06-23 15:16:41 +02:00
B. Petersen 23acff2a87 Encrypt group chats. 2017-06-22 17:35:30 +02:00
B. Petersen 484d723c75 Cleanup chat list: As we encrypt messages, not chats, there is not need for a chat-encrypted state. 2017-06-21 12:22:38 +02:00
B. Petersen ecab439d0a Unify error icon. 2017-06-21 12:08:47 +02:00
B. Petersen d02732c16d Refactor E2EE. 2017-06-21 11:58:12 +02:00
B. Petersen f55106612c Typo 2017-06-19 21:29:01 +02:00
B. Petersen efde505eb5 Pimp lock-screen icon and text. 2017-06-19 12:57:08 +02:00
B. Petersen 7ae296dcac Use lock icon for locking the app. 2017-06-19 01:15:04 +02:00
B. Petersen 8a20f439c0 Fix french apostrophs. 2017-06-19 01:14:36 +02:00
B. Petersen 57a8251313 Merge branch 'master' of https://github.com/deltachat/deltachat-android 2017-06-19 00:51:42 +02:00
B. Petersen 6039a4e6b1 Use a lock-icon for end-to-end-encrypted messages. 2017-06-19 00:51:17 +02:00
Björn Petersen ea59519c09 Merge pull request #106 from Almtesh/patch-1
French translation
2017-06-18 20:08:02 +02:00
Gilles Émilien MOREL 84e7345607 French translation
Added new translations
Corrected my and other's mistaken translations.
2017-06-18 17:13:40 +02:00
B. Petersen 4357817faf Wording 2017-06-18 00:59:56 +02:00
B. Petersen fb4f378b86 Merge branch 'master' of https://github.com/deltachat/deltachat-android 2017-06-17 15:01:15 +02:00
B. Petersen ee081b3037 End-to-end-encrypted messages are marked by a sign beside the timestamp. 2017-06-17 15:01:06 +02:00
Dr. Tobias Quathamer 33d3d92f62 Update URLs, fix typo 2017-06-16 22:48:20 +02:00
B. Petersen 9ba8659536 Update Portuguese translation. 2017-06-15 16:53:38 +02:00
B. Petersen 3c14d32e19 Set help URL for Spanish locale to Spanish homepage. 2017-06-13 13:24:07 +02:00
B. Petersen 6cb866233b Wording 2017-06-12 10:30:08 +02:00
B. Petersen e98bffdacc Cleanup import/export interface. 2017-06-07 08:51:44 +02:00
B. Petersen 96400768b5 Make the backup task cancellable. 2017-06-06 14:10:15 +02:00
B. Petersen dd8474cecf Add backup export function. 2017-06-06 13:42:16 +02:00
B. Petersen 7b98265a2a Update Polish translation. 2017-06-05 00:40:18 +02:00
B. Petersen 03a20c26db Changelog. 2017-06-04 16:26:39 +02:00
B. Petersen fd0731c52a Update messenger-backend submodule. 2017-06-04 16:25:44 +02:00
B. Petersen 7856fb22e4 Improved video quality of short clips. 2017-06-04 16:06:45 +02:00
B. Petersen d38a4535bb Pimp settings. 2017-06-04 14:40:25 +02:00
B. Petersen 757ad7266f Simplify settings structure and avoid an additional action bar menu. 2017-06-04 11:26:00 +02:00
B. Petersen da8274de1b Add backup menu entry. 2017-06-04 02:13:01 +02:00
B. Petersen 22bd12cfd6 Improve encryption state dialog. 2017-06-04 01:44:37 +02:00
B. Petersen 6d868cb541 Changelog. 2017-06-03 00:57:49 +02:00
Björn Petersen ca2ad6fa68 Merge pull request #92 from guland2000/patch-2
Update strings.xml
2017-06-03 00:40:15 +02:00
guland2000 718dd6d1a9 Update strings.xml
374 and 375
2017-06-02 17:12:50 +02:00
guland2000 b4db0d7d70 Update strings.xml
1. Fix some error, linguistic and semantic (contextual) : strings 86,118,129,223,343,345,351 
2. and added New strings 377, 378, 379,380,381,382,383,384,385.
2017-06-02 00:58:09 +02:00
B. Petersen 0de45907ff Update messenger-backend submodule. 2017-06-01 20:00:05 +02:00
B. Petersen 9fbc3773b6 Update changelog. 2017-06-01 19:59:28 +02:00
B. Petersen 4707d43e84 Show the number of imported keys. 2017-06-01 18:39:17 +02:00
B. Petersen dabae2d63a Ask before importing private keys (as this may change the default). 2017-06-01 13:40:12 +02:00
B. Petersen 3c9204da0f Move 'Privacy/Key-settings' to 'Advanced settings' and 'Privacy/PIN+Blocked users' to 'Settings'; we do no longer have a 'Privacy dialog'; Delta Chat regards the user's privacy everywhere with every bit. 2017-06-01 11:53:42 +02:00
B. Petersen 4b11524fcf Add Import and Export key options. 2017-06-01 01:33:11 +02:00
B. Petersen 7a8c279e4f Force added downloads to be scanned; if left out, at least on my Nexus 4/Mashmallow, downloads do not appear via USB. With scan=true it works. 2017-06-01 01:32:50 +02:00
B. Petersen b3708d1bd4 Enable E2EE by default. 2017-05-31 18:03:19 +02:00
B. Petersen 3ffb476aa9 Bump version. 2017-05-31 17:47:26 +02:00
B. Petersen 7641975cc6 Do not print a message summary in the subject of encrypted messages. 2017-05-29 00:48:58 +02:00
B. Petersen dbc23af348 Prepare encrypted MIME-Messages. 2017-05-27 17:57:45 +02:00
B. Petersen dac8dbd330 Correct OpenSSL bindings. 2017-05-26 15:18:45 +02:00
B. Petersen a47dd34500 Enable Camellia cryptographic algorithm. 2017-05-18 14:22:31 +02:00
B. Petersen b160d1b1e9 Add option to enable E2E-Encryption (for now, it is disabled by default). 2017-05-18 02:39:27 +02:00
B. Petersen 90d5c4fd2c Prepare OpenSSL to be used for E2E-Encryption. 2017-05-18 02:38:48 +02:00
B. Petersen 3311bb56e4 Enable CAST5 cryptographic algorithm (default cipher in some versions of GPG and PGP). 2017-05-18 02:37:54 +02:00
B. Petersen d6ff7e4480 Typo 2017-05-15 11:08:49 +02:00
B. Petersen b7ea939ac7 Change header notice to real name. 2017-05-15 11:07:28 +02:00
B. Petersen 46a2930fa0 Debug prints. 2017-05-14 18:20:18 +02:00
B. Petersen e8c6309e93 Add title to 'Compare keys' dialog. 2017-05-12 17:11:55 +02:00
B. Petersen b9a72db110 Call 'Compare keys' core-code. 2017-05-12 15:45:28 +02:00
B. Petersen a6d8d0e3b6 Remove currently unneeded options. 2017-05-10 14:42:36 +02:00
B. Petersen a7a7e66bb8 Wording. 2017-05-10 13:42:38 +02:00
B. Petersen a2ad1d35e7 Wording. 2017-05-10 13:22:44 +02:00
B. Petersen dd16cc7d89 Show 'Notifications and sounds' settings preview. 2017-05-10 13:03:12 +02:00
B. Petersen 9673ec1a96 Show name preview or 'Not set' in settings dialog. 2017-05-10 11:30:17 +02:00
B. Petersen 8d8c9b808b Move text size option from 'Advanced settings' to 'Settings'. 2017-05-10 11:27:43 +02:00
B. Petersen d379d66751 Wording 2017-05-10 11:10:57 +02:00
B. Petersen f44989a18d Move 'Advanced settings' to the action bar menu. 2017-05-10 11:10:44 +02:00
B. Petersen 7a5b880a7a Move option 'Show contact requests in chatlist' from 'Privacy' to 'Advanced options' (we want the 'Advanced options' to hold all options that are not needed by the main audience). 2017-05-10 10:58:06 +02:00
B. Petersen c859e9bf70 Bump version. 2017-05-09 19:31:52 +02:00
Björn Petersen 6e4361d129 Merge pull request #87 from signorsayyed/fix-typos
Fix some typos in english intro
2017-05-09 00:27:29 +02:00
arshad e5cd1be194 Fix some typos in intro
*Fixed some typos and grammatical errors that are displayed during intro.

Signed-off-by: arshad <me@signorsayyed.com>
2017-05-08 22:11:00 +05:30
B. Petersen 5a3faba0a3 Simplify 'Contact requests' activity. 2017-05-08 15:11:36 +02:00
B. Petersen 0b15b5b55f Move 'Account settings' to the action bar menu. 2017-05-08 11:59:59 +02:00
B. Petersen ecd06e4b0f Add user wallpaper and user name above settings dialog. 2017-05-07 01:57:51 +02:00
B. Petersen 8bf5d98d04 Pimp settings dialog. 2017-05-06 15:05:10 +02:00
B. Petersen b73b1e430e Profile: Option to copy the email address to the clipboard. 2017-05-06 12:54:25 +02:00
B. Petersen 563ec61d52 Pimp profile view. 2017-05-06 12:45:05 +02:00
B. Petersen ba02fae57f Comment 2017-05-06 01:17:22 +02:00
B. Petersen 5c61abe256 Show larger profile photo. 2017-05-06 01:15:36 +02:00
B. Petersen 0d93f9a678 Align search fields together with the new back button width. 2017-05-05 23:59:48 +02:00
B. Petersen bff79e1c34 Revert 'Contact requests' subtitle change. 2017-05-05 23:02:56 +02:00
B. Petersen 68db96483c Rename 'Mailbox' to 'Contact requests' which seems to be much clearer in most cases (except if the 'Contact requests' are shown in the chatlist as a separate group, however, even this is okay for me). 2017-05-05 22:59:22 +02:00
B. Petersen 2bdf88373d Narrow the back button slightly. 2017-05-05 16:47:31 +02:00
B. Petersen cdb43876bf Show deaddrop subtitle hint below option to show deaddrop in chat overview. 2017-05-05 16:08:03 +02:00
B. Petersen 6f1cecdaa9 Deaddrop subtitle: Show a hint instead of uninteresting contact count. 2017-05-05 15:57:05 +02:00
B. Petersen 363d78d61c Simplify menu in new non-drawer-mode. 2017-05-05 15:14:26 +02:00
B. Petersen 02d9258c9c Add a separate 'View profile' menu entry to chat view (does the same as the click on the avatar) 2017-05-05 14:43:05 +02:00
B. Petersen 8a567c63b1 Use a menu instead of a drawer; for now, you can get the drawer back by entering '.set drawer 1' into the 'Settings / My Name' field. 2017-05-05 12:46:49 +02:00
B. Petersen 880139b1ff Check back-button against null-pointers. 2017-05-05 11:33:24 +02:00
267 changed files with 3961 additions and 5429 deletions
+71
View File
@@ -1,5 +1,76 @@
# Delta Chat Changelog
## 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 encryption-dialog localizable
* Update Russian translation
## v0.9.0
2017-06-01
* Add end-to-end-encrypting following the OpenPGP and Autocrypt standards
* Add a function to compare keys
* Profile: Add option to copy the email address to the clipboard
* Pimp GUI
## v0.1.36
2017-05-04
+6 -3
View File
@@ -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 = 36
defaultConfig.versionCode = 44
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.1.36" // do NOT forget to increase defaultConfig.versionCode!
versionName "0.9.5" // do NOT forget to increase defaultConfig.versionCode!
}
}
+44 -3
View File
@@ -493,6 +493,19 @@ local_src_files := \
./openssl/crypto/buffer/buf_err.c \
./openssl/crypto/buffer/buf_str.c \
./openssl/crypto/buffer/buffer.c \
./openssl/crypto/camellia/camellia.c \
./openssl/crypto/camellia/cmll_cbc.c \
./openssl/crypto/camellia/cmll_cfb.c \
./openssl/crypto/camellia/cmll_ctr.c \
./openssl/crypto/camellia/cmll_ecb.c \
./openssl/crypto/camellia/cmll_misc.c \
./openssl/crypto/camellia/cmll_ofb.c \
./openssl/crypto/camellia/cmll_utl.c \
./openssl/crypto/cast/c_cfb64.c \
./openssl/crypto/cast/c_ecb.c \
./openssl/crypto/cast/c_enc.c \
./openssl/crypto/cast/c_ofb64.c \
./openssl/crypto/cast/c_skey.c \
./openssl/crypto/cmac/cm_ameth.c \
./openssl/crypto/cmac/cm_pmeth.c \
./openssl/crypto/cmac/cmac.c \
@@ -610,6 +623,8 @@ local_src_files := \
./openssl/crypto/evp/e_aes.c \
./openssl/crypto/evp/e_aes_cbc_hmac_sha1.c \
./openssl/crypto/evp/e_bf.c \
./openssl/crypto/evp/e_camellia.c \
./openssl/crypto/evp/e_cast.c \
./openssl/crypto/evp/e_des.c \
./openssl/crypto/evp/e_des3.c \
./openssl/crypto/evp/e_null.c \
@@ -1188,6 +1203,7 @@ LOCAL_SRC_FILES := \
./messenger-backend/libs/libetpan/src/low-level/smtp/mailsmtp_ssl.c \
./messenger-backend/libs/libetpan/src/main/libetpan_version.c \
./messenger-backend/libs/libetpan/src/driver/implementation/data-message/data_message_driver.c \
./messenger-backend/libs/libetpan/src/driver/implementation/mime-message/mime_message_driver.c \
./messenger-backend/libs/libetpan/src/driver/interface/maildriver.c \
./messenger-backend/libs/libetpan/src/driver/interface/maildriver_tools.c \
./messenger-backend/libs/libetpan/src/driver/interface/maildriver_types.c \
@@ -1197,7 +1213,9 @@ LOCAL_SRC_FILES := \
./messenger-backend/libs/libetpan/src/driver/interface/mailmessage_tools.c \
./messenger-backend/libs/libetpan/src/driver/interface/mailmessage_types.c \
./messenger-backend/libs/libetpan/src/driver/interface/mailstorage.c \
./messenger-backend/libs/libetpan/src/driver/interface/mailstorage_tools.c
./messenger-backend/libs/libetpan/src/driver/interface/mailstorage_tools.c \
./messenger-backend/libs/libetpan/src/engine/mailprivacy.c \
./messenger-backend/libs/libetpan/src/engine/mailprivacy_tools.c
LOCAL_C_INCLUDES = \
$(LOCAL_PATH)/messenger-backend/libs/libetpan/src \
$(LOCAL_PATH)/messenger-backend/libs/libetpan/src/data-types \
@@ -1220,7 +1238,6 @@ LOCAL_C_INCLUDES = \
include $(BUILD_STATIC_LIBRARY)
################################################################################
# cyrus sasl
################################################################################
@@ -1294,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
@@ -1492,6 +1510,7 @@ $(LOCAL_PATH)/breakpad/common/android/include \
$(LOCAL_PATH)/breakpad \
$(LOCAL_PATH)/ffmpeg \
$(LOCAL_PATH)/messenger-backend/libs/libetpan/include \
$(LOCAL_PATH)/messenger-backend/libs/netpgp/include \
$(LOCAL_PATH)/messenger-backend/libs/sqlite
#LOCAL_SRC_FILES += \
@@ -1599,21 +1618,43 @@ LOCAL_SRC_FILES += \
./image.c \
./video.c \
./gifvideo.cpp \
./messenger-backend/libs/netpgp/src/compress.c \
./messenger-backend/libs/netpgp/src/create.c \
./messenger-backend/libs/netpgp/src/crypto.c \
./messenger-backend/libs/netpgp/src/keyring.c \
./messenger-backend/libs/netpgp/src/misc.c \
./messenger-backend/libs/netpgp/src/openssl_crypto.c \
./messenger-backend/libs/netpgp/src/packet-parse.c \
./messenger-backend/libs/netpgp/src/packet-show.c \
./messenger-backend/libs/netpgp/src/reader.c \
./messenger-backend/libs/netpgp/src/signature.c \
./messenger-backend/libs/netpgp/src/symmetric.c \
./messenger-backend/libs/netpgp/src/validate.c \
./messenger-backend/libs/netpgp/src/writer.c \
./messenger-backend/src/mraheader.c \
./messenger-backend/src/mrapeerstate.c \
./messenger-backend/src/mrchat.c \
./messenger-backend/src/mrchatlist.c \
./messenger-backend/src/mrcmdline.c \
./messenger-backend/src/mrcontact.c \
./messenger-backend/src/mre2ee.c \
./messenger-backend/src/mrdehtml.c \
./messenger-backend/src/mrimap.c \
./messenger-backend/src/mrjob.c \
./messenger-backend/src/mrkey.c \
./messenger-backend/src/mrkeyring.c \
./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 -1
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+91 -23
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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 */
}
@@ -511,6 +527,15 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getInfo(JNIEnv *env, jclass
}
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_getContactEncrInfo(JNIEnv *env, jclass cls, jint contact_id)
{
char* temp = mrmailbox_get_contact_encrinfo(get_mrmailbox_t(env, cls), contact_id);
jstring ret = JSTRING_NEW(temp);
free(temp);
return ret;
}
JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_cmdline(JNIEnv *env, jclass cls, jstring cmd)
{
CHAR_REF(cmd);
@@ -522,6 +547,37 @@ JNIEXPORT jstring Java_com_b44t_messenger_MrMailbox_cmdline(JNIEnv *env, jclass
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_imex(JNIEnv *env, jclass cls, jint what, jstring dir)
{
CHAR_REF(dir);
mrmailbox_imex(get_mrmailbox_t(env, cls), what, dirPtr, "");
CHAR_UNREF(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);
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! */
}
JNIEXPORT void Java_com_b44t_messenger_MrMailbox_heartbeat(JNIEnv *env, jclass cls)
{
mrmailbox_heartbeat(get_mrmailbox_t(env, cls));
@@ -622,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);
@@ -653,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));
}
@@ -747,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);
}
@@ -845,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;
}
+1 -1
View File
@@ -8,7 +8,7 @@
LOCAL_CFLAGS += -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN #-DTERMIO
# From DEPFLAG=
LOCAL_CFLAGS += -DOPENSSL_NO_CAMELLIA -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_CAST -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_SHA0 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SEED -DOPENSSL_NO_STORE -DOPENSSL_NO_WHIRLPOOL
LOCAL_CFLAGS += -DOPENSSL_NO_CAPIENG -DOPENSSL_NO_CMS -DOPENSSL_NO_GMP -DOPENSSL_NO_IDEA -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_SHA0 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SEED -DOPENSSL_NO_STORE -DOPENSSL_NO_WHIRLPOOL
# Extra
LOCAL_CFLAGS += -DOPENSSL_NO_HW -DOPENSSL_NO_ENGINE -DZLIB
+1 -1
View File
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
+1 -8
View File
@@ -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
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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);
}
@@ -1018,7 +976,7 @@ public class AndroidUtilities {
if (copied) {
if ( add_to_download_manager ) {
DownloadManager downloadManager = (DownloadManager) ApplicationLoader.applicationContext.getSystemService(Context.DOWNLOAD_SERVICE);
downloadManager.addCompletedDownload(destPathNFile.getName(), destPathNFile.getName(), false, getMimetype(msg_file_name, msg_mime), destPathNFile.getAbsolutePath(), destPathNFile.length(), true);
downloadManager.addCompletedDownload(destPathNFile.getName(), destPathNFile.getName(), true, getMimetype(msg_file_name, msg_mime), destPathNFile.getAbsolutePath(), destPathNFile.length(), true);
} else {
addMediaToGallery(Uri.fromFile(destPathNFile));
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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();
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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();
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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) {
;
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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);
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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;
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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();
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -29,16 +29,16 @@ package com.b44t.messenger;
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;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@@ -69,6 +69,15 @@ public class MrMailbox {
public native static String getInfo();
public native static String cmdline(String cmd);
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();
private static long m_hMailbox = 0; // do not rename this, is used in C-part
@@ -91,6 +100,8 @@ public class MrMailbox {
return MrMailboxBlockContact(m_hMailbox, id, block);
}
public native static String getContactEncrInfo(int contact_id);
public static int deleteContact(int id) {
return MrMailboxDeleteContact(m_hMailbox, id);
}
@@ -115,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
@@ -126,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);
@@ -182,6 +194,10 @@ 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_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;
public final static int MR_EVENT_GET_QUANTITIY_STRING = 2092;
@@ -215,6 +231,35 @@ public class MrMailbox {
});
return 0;
case MR_EVENT_IMEX_ENDED:
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
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);
}
});
}
return 0;
case MR_EVENT_MSGS_CHANGED:
case MR_EVENT_INCOMING_MSG:
AndroidUtilities.runOnUIThread(new Runnable() {
@@ -327,6 +372,16 @@ public class MrMailbox {
case 21: s = ApplicationLoader.applicationContext.getString(R.string.ErrSelfNotInGroup); break;
case 22: s = ApplicationLoader.applicationContext.getString(R.string.NoNetwork); break;
case 23: s = ApplicationLoader.applicationContext.getString(R.string.AttachGif); break;
case 24: s = ApplicationLoader.applicationContext.getString(R.string.EncryptedMessage); break;
case 25: s = ApplicationLoader.applicationContext.getString(R.string.EncrinfoE2E); break;
case 26: s = "<c#808080>"+ApplicationLoader.applicationContext.getString(R.string.EncrinfoE2EExplain)+"</c>"; break;
case 27: s = ApplicationLoader.applicationContext.getString(R.string.EncrinfoTransport); break;
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);
@@ -370,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();
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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;
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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) {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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++ ) {
@@ -752,6 +754,7 @@ public class NotificationsController {
cv.put("count", count);
ApplicationLoader.applicationContext.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
} catch (Throwable e) {
e.printStackTrace();
}
try {
@@ -771,12 +774,12 @@ public class NotificationsController {
intent.putExtra("badge_count_class_name", launcherClassName);
ApplicationLoader.applicationContext.sendBroadcast(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} catch (Throwable e) {
e.printStackTrace();
}
}
});
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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 {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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()
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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();
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -56,6 +56,10 @@ public class ActionBar extends FrameLayout {
}
}
public static final int TITLE_WITHOUT_BACK_X = 16; /*original value: 18*/
public static final int TITLE_AFTER_BACK_X = 58; /*original value: 72*/
public static final int AVATAR_AFTER_BACK_X = 48; /*original value: 56, you have also to adapt the animation, if you change this value (see ProfileActivity.ANIM_OFF) */
private ImageView backButtonImageView;
private SimpleTextView titleTextView;
private SimpleTextView subtitleTextView;
@@ -374,10 +378,6 @@ public class ActionBar extends FrameLayout {
if (subtitleTextView != null) {
subtitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
}
Drawable drawable = backButtonImageView.getDrawable();
if (drawable != null && drawable instanceof MenuDrawable) {
((MenuDrawable) drawable).setRotation(visible ? 1 : 0, true);
}
}
public void setInterceptTouches(boolean value) {
@@ -410,15 +410,15 @@ public class ActionBar extends FrameLayout {
int textLeft;
if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) {
backButtonImageView.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(54), MeasureSpec.EXACTLY), actionBarHeightSpec);
textLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 80 : 72);
textLeft = AndroidUtilities.dp(TITLE_AFTER_BACK_X);
} else {
textLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
textLeft = AndroidUtilities.dp(TITLE_WITHOUT_BACK_X);
}
if (menu != null && menu.getVisibility() != GONE) {
int menuWidth;
if (isSearchFieldVisible) {
menuWidth = MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 74 : 66), MeasureSpec.EXACTLY);
menuWidth = MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(TITLE_AFTER_BACK_X), MeasureSpec.EXACTLY);
} else {
menuWidth = MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST);
}
@@ -429,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));
}
}
@@ -456,27 +455,27 @@ public class ActionBar extends FrameLayout {
int textLeft;
if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) {
backButtonImageView.layout(0, additionalTop, backButtonImageView.getMeasuredWidth(), additionalTop + backButtonImageView.getMeasuredHeight());
textLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 80 : 72);
textLeft = AndroidUtilities.dp(TITLE_AFTER_BACK_X);
} else {
textLeft = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
textLeft = AndroidUtilities.dp(TITLE_WITHOUT_BACK_X);
}
if (menu != null && menu.getVisibility() != GONE) {
int menuLeft = isSearchFieldVisible ? AndroidUtilities.dp(AndroidUtilities.isTablet() ? 74 : 66) : (right - left) - menu.getMeasuredWidth();
int menuLeft = isSearchFieldVisible ? AndroidUtilities.dp(TITLE_AFTER_BACK_X) : (right - left) - menu.getMeasuredWidth();
menu.layout(menuLeft, additionalTop, menuLeft + menu.getMeasuredWidth(), additionalTop + menu.getMeasuredHeight());
}
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());
}
@@ -547,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;
}
@@ -599,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);
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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;
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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 ) {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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() {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -286,10 +286,6 @@ public class BaseFragment {
}
protected AnimatorSet onCustomTransitionAnimation(boolean isOpen, final Runnable callback) {
return null;
}
public void onLowMemory() {
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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,510 +0,0 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (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.R;
import com.b44t.messenger.AnimatorListenerAdapterProxy;
public class DrawerLayoutContainer extends FrameLayout {
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);
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) {
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 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (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);
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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);
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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);
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (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;
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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;
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (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 @@
/*******************************************************************************
*
* Messenger Android Frontend
* (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) {
}
}
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
*
@@ -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) {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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 {
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -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));
}
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com
@@ -1,6 +1,6 @@
/*******************************************************************************
*
* Messenger Android Frontend
* Delta Chat Android
* (C) 2013-2016 Nikolai Kudashov
* (C) 2017 Björn Petersen
* Contact: r10s@b44t.com, http://b44t.com

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