Compare commits

...
Author SHA1 Message Date
jessopb fdd759b241 Merge pull request #1236 from ktprograms/readme-google-services
deploy.yml (push) Invalid workflow file
Add google-services.json instructions to README
2022-11-29 13:07:52 -05:00
jessopb 57cd649c02 Update README.md 2022-11-29 13:07:30 -05:00
jessopb 7250435d7f Create deploy.yml 2022-11-25 14:03:02 -05:00
jessopb b81abf74a1 Merge pull request #1244 from Coolguy3289/patch-1
Update LBRY_TV_CONNECTION_STRING to new Odysee Backend
2022-11-23 13:59:38 -05:00
Ralph 208e2c2d42 Update LBRY_TV_CONNECTION_STRING to new Odysee Backend 2022-11-23 11:29:52 -05:00
kt programs a5bdd1c042 Add google-services.json instructions to README 2022-04-18 12:14:25 +08:00
Alex Grin 1e3a74cae1 Update README.md 2021-09-28 10:19:37 -04:00
Akinwale Ariwodola ca08f71a72 sdk 0.102.0 2021-08-20 15:32:14 +01:00
Akinwale Ariwodola b60ca39df1 fix crash bug when trying to play content 2021-08-19 12:27:18 +01:00
soup-jingle 696bc86b7c Added QR scanner to wallet send card (#1194)
* Added QR scanner to wallet send card

* * app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java:

Changed orientation of QR scanner, along with some style corrections

* Revert "* app/src/main/java/io/lbry/browser/ui/wallet/WalletFragment.java:"

This reverts commit 519c45ae0dfaee556de909bf65cea8c3b38c34ab.

* Fixed orientation of QR scanner activity, plus style corrections
2021-08-13 09:01:53 +01:00
Akinwale Ariwodola 4c163c6244 Merge pull request #1216 from lbryio/new_cdn_url
Use the new CDN url scheme for thumbnails
2021-08-13 09:01:09 +01:00
Akinwale Ariwodola 2ad49ca281 Merge pull request #1208 from lbryio/claimid-modifier-char
Accept colon or octoshape as claimID modifier character
2021-08-11 10:20:58 +01:00
Javi Rueda 56caeef72b Use the new CDN url scheme for thumbnails 2021-08-10 18:28:20 +02:00
Javi Rueda 84bb014557 Accept colon or octoshape as claimID modifier character and add unit tests 2021-07-29 00:55:45 +02:00
Akinwale Ariwodola 9278e74e85 remove reference to bintray 2021-06-25 19:34:58 +01:00
Akinwale Ariwodola cf6f09c60d fix gitlab CI script 2021-06-25 19:25:29 +01:00
Akinwale Ariwodola f2cbed48d9 fix git-secret install source 2021-06-25 19:23:30 +01:00
Akinwale Ariwodola f1ead0c247 bumpversion 0.17.0 --> 0.17.1 2021-06-25 19:08:30 +01:00
Akinwale Ariwodola 5f2c72ec4d sdk 0.100.0 / switch to maven central for lbrysdk Gradle dependency 2021-06-25 19:07:47 +01:00
Javi Rueda a6869eb2e6 Fix crash for anonymous content or without tags (#1190) 2021-05-10 17:14:22 +02:00
Javi Rueda cbae6c476a Claim has source (#1188)
* Pass has_source parameter to claim_search to ignore livestreamings

* Update to SDK 0.94.1 and allow user to view livestream content on Odysee
2021-05-10 17:13:28 +02:00
Javi Rueda 48d257ceaf Show total wallet balance in USD instead of spendable balance conversion (#1186) 2021-04-19 19:55:49 +02:00
Javi Rueda 5355456498 Don't show link to Bittrex (#1181) 2021-04-12 18:53:59 +02:00
Javi Rueda 1436895ace Copy file to public Downloads directory (#1180) 2021-04-12 18:53:13 +02:00
Javi Rueda 6e32f7724f Notification improvements (#1175)
* Stop showing notification list when going from notification's content to related content

* Add is_app_readable parameter to notification_list call

* Return current fragment on main activity
2021-03-29 17:39:27 +02:00
Javi Rueda 3f5104d60a Hide floating wallet on the Channel fragment (#1177)
* Hide floating wallet on the Channel fragment

* Unregister OnPageChangeCallback when exiting channel fragment
2021-03-29 17:38:51 +02:00
Javi Rueda d8fdb3b818 Decode and encode urls with non-authorized characters (#1174)
* Decode URL encoded links and unit test it

* Encode UTF8 characters on LBRY.TV links and unit test it
2021-03-19 11:00:24 +01:00
Akinwale Ariwodola 5c187e7a8d Merge branch 'master' of https://github.com/lbryio/lbry-android 2021-03-16 09:24:53 +01:00
Akinwale Ariwodola 24862550a1 bumpversion 0.16.14 --> 0.17.0 2021-03-16 09:24:33 +01:00
Akinwale Ariwodola 146fced44e Merge pull request #1162 from kekkyojin/wallet-total
Use total wallet balance instead of spendable
2021-03-16 09:22:57 +01:00
Akinwale Ariwodola d535ed8c98 Merge pull request #1168 from lbryio/enable-phone-verification
Enable phone verification
2021-03-16 09:22:35 +01:00
Akinwale Ariwodola b675dbad9b Merge branch 'master' of https://github.com/lbryio/lbry-android 2021-03-16 08:59:42 +01:00
Javi Rueda dabe9fe691 Disable Javascript (#1171) 2021-03-15 20:08:18 +01:00
Javi Rueda 9ac216504d Use ':' as separator for LBRY.TV sharing links (#1169) 2021-03-15 16:22:18 +01:00
Javi Rueda 911ca998e7 Use total wallet balance instead of spendable 2021-03-15 12:48:51 +01:00
Javi Rueda 36c105d3a7 Enable phone verification
Show the Close button after phone number has been verified
2021-03-11 17:46:17 +01:00
Akinwale AriwodolaandPatric Karlström a655d0112b PR cleanup (#1164)
* simplify code for readability
* code-cleanup. Make non-changing variables final
* Bump buildToolsVersion 29.0.1 -> 29.0.2 for FDroid build compability
* Set gradle version to static 3.6.4 instead of dynamic 3.+
* Use StandardCharsets.UTF_8 instead of string UTF8
* Remove unused imports
* Add missing null check

Co-authored-by: Patric Karlström <patric@pkcab.eu>
2021-03-08 20:15:23 +01:00
Akinwale Ariwodola 493c771e94 sdk 0.91.0 2021-03-08 19:52:15 +01:00
Akinwale Ariwodola e9d70dbf87 Merge pull request #1163 from lbryio/iap-check
allow users to initiate a purchase flow check
2021-03-08 19:40:19 +01:00
Akinwale Ariwodola 0849ce2b66 allow users to initiate a purchase flow check 2021-03-08 19:38:00 +01:00
Javi Rueda d0a8b3b218 Fix mass tips unlocking (#1157) 2021-03-06 00:32:12 +01:00
Javi Rueda a8cdc4a771 Move the wallet floating button away when scroll gets to the bottom at FileViewFragment (#1155) 2021-03-04 19:11:19 +01:00
Javi Rueda 67b883660f Hide support button and comments consistently with claim tags (#1152)
* Hide support button and comments consistently with claim tags

* Set visibility to GONE instead of INVISIBLE for the tipping button
2021-02-26 19:31:11 +01:00
Javi Rueda f328efb831 Allow media to be played automatically (#1153)
* Allow media to be played automatically

* Fix for media been always autoplayed when opened from miniplayer
2021-02-26 19:24:17 +01:00
Javi Rueda b2f56364d6 Use commentron instead of Comment SDK calls (#1149)
* Use commentron instead of Comment SDK calls

* Use current timestamp as 'id' for comment server request
2021-02-24 16:23:33 +01:00
Akinwale Ariwodola 2761857fe8 Merge pull request #1135 from kekkyojin/totvstring-unittest
Add unit test for LbryUri.toTvString
2021-02-22 20:07:55 +01:00
Akinwale Ariwodola d439260d69 Merge pull request #1132 from kekkyojin/ignore_helpertest
Change HelperTest to JUnit4 and remove example test class
2021-02-16 17:02:48 +01:00
Akinwale Ariwodola f0f0a5028b Merge pull request #1123 from kekkyojin/style-code-tag
Styling <code> tag for Markdown content
2021-02-16 16:59:36 +01:00
Javi Rueda 13e170cb61 Add unit test for LbryUri.toTvString 2021-02-16 16:42:05 +01:00
Javi Rueda 127d8052ca Change HelperTest to JUnit4 and remove example test class 2021-02-12 01:28:22 +01:00
Javi Rueda 1b3086572f Styling <code> tag for Markdown content 2021-02-02 19:00:17 +01:00
Akinwale Ariwodola 6fa308ef96 bumpversion 0.16.13 --> 0.16.14 2021-01-25 18:54:00 +01:00
Akinwale Ariwodola f3e513fc2d Update translations and content filters 2021-01-25 18:52:21 +01:00
Akinwale Ariwodola d72a8faec4 sdk 0.88.0 2021-01-23 19:23:11 +01:00
Akinwale Ariwodola fdb4578349 Merge pull request #1119 from kekkyojin/remove-sha256
Remove Helper.SHA256() method
2021-01-18 20:24:22 +01:00
Javi Rueda c08237d399 Remove Helper.SHA256() method 2021-01-14 13:04:43 +01:00
Akinwale Ariwodola bdf8a58818 bumpversion 0.16.12 --> 0.16.13 2021-01-12 09:11:26 +01:00
Akinwale Ariwodola e1d51c881a Fix crash bug for anonymous repost claim results. Better handle channel repost navigation. 2021-01-12 09:07:33 +01:00
Akinwale Ariwodola 28212808f8 Merge pull request #1115 from pakar/master
Upgrade ExoPlayer from 2.11.4 to 2.12.2
2021-01-12 08:35:04 +01:00
Akinwale Ariwodola 74f08f8f98 Merge pull request #1102 from kekkyojin/fix-markdown-rendering
Use Base64 to encode html when rendering Markdown files
2021-01-12 08:33:40 +01:00
Akinwale Ariwodola cb5c29fbce Merge pull request #1117 from kekkyojin/fix-nosuchmethod-commons
Fix NoSuchMethod exception for HelperSHA256 on API Level prior to P
2021-01-12 08:32:08 +01:00
Javi Rueda 4d775d3a17 Fix NoSuchMethod exception for HelperSHA256 on API Level prior to P 2021-01-11 20:44:03 +01:00
Patric Karlström fd94ef9fa7 Upgrade ExoPlayer from 2.11.4 to 2.12.2 2021-01-11 01:10:23 +01:00
Javi Rueda 2e0331305a Use Base64 to encode html when rendering Markdown files 2020-12-29 11:30:05 +01:00
Akinwale Ariwodola fb560f8f01 fix last resource build error 2020-12-29 07:20:46 +01:00
Akinwale Ariwodola ef80c9f7fd fix resource build error 2020-12-29 07:13:57 +01:00
Akinwale Ariwodola 99a4a0a22f Remove comment post confirmation. Fix resources build error. 2020-12-29 07:07:53 +01:00
Akinwale Ariwodola 136853853a bumpversion 0.16.11 --> 0.16.12 2020-12-29 07:02:13 +01:00
Akinwale Ariwodola ebf3299c30 add scrollbars attribute to listview 2020-12-29 07:00:45 +01:00
Akinwale Ariwodola 036b49a871 Merge pull request #1097 from kekkyojin/remove_stages_scrollbar
Avoid showing vertical scroll bar on stage error listview
2020-12-29 07:00:02 +01:00
Akinwale Ariwodola 67d5f88d34 Merge pull request #1100 from clay53/master
Changed wallet send notification to accept 4 digit decimal
2020-12-29 06:52:16 +01:00
Akinwale Ariwodola b1e0b9af33 sdk 0.87.0. Show confirmation for unfollow. 2020-12-29 06:47:10 +01:00
Clayton Hickey c30b012787 Changed wallet send notification to accept 4 digit decimal 2020-12-27 03:54:36 -05:00
Javi Rueda c8c6305757 Avoid showing vertical scroll bar on stage error listview 2020-12-22 02:26:37 +01:00
Akinwale Ariwodola ee1d090e62 Merge pull request #1068 from kekkyojin/fix-lintproblems
Some fixes for lint
2020-12-21 19:43:08 +01:00
Javi Rueda 9e56a86492 Some fixes for lint 2020-12-18 14:30:48 +01:00
Akinwale Ariwodola e6b83877f1 Merge pull request #1063 from clay53/1042
Removed comment tips
2020-12-18 13:01:49 +01:00
Akinwale Ariwodola b567e39aef Merge pull request #1069 from kekkyojin/add-twitter-instructions
Provide instructions to add dummy Twitter API credentials
2020-12-18 12:22:03 +01:00
Akinwale Ariwodola ae62dba0a6 Merge pull request #1071 from kekkyojin/sha256-unittest
Add unit test for Helper.SHA256(String)
2020-12-18 12:21:39 +01:00
Akinwale Ariwodola df1e8abf50 Merge pull request #1067 from kekkyojin/use-apache-hex
Replace Hex class from GMS with the one from Apache
2020-12-18 12:20:42 +01:00
Javi Rueda 31cfb26c3b Add unit test for Helper.SHA256(String) 2020-12-15 13:45:32 +01:00
Javi Rueda e5f34dc464 Provide instructions to add dummy Twitter API credentials 2020-12-14 20:38:57 +01:00
Javi Rueda 601031e55d Replace Hex class from GMS with the one from Apache 2020-12-14 18:17:13 +01:00
Akinwale Ariwodola a9aadbe6a8 bumpversion 0.16.10 --> 0.16.11 2020-12-13 18:08:10 +01:00
Akinwale Ariwodola f9a4b71037 fix crash error when following doesn't exist in shared user state 2020-12-13 18:07:19 +01:00
Clayton Hickey 0f10e9dc1f Removed comment tips 2020-12-12 20:11:00 -05:00
Akinwale Ariwodola 0647deb06c Merge pull request #1061 from kekkyojin/startupstage-listview
Use ListView to show startup stage errors
2020-12-12 23:16:17 +01:00
Akinwale Ariwodola b2f5fec293 make the channel filter name alphabet uppercase 2020-12-10 09:57:27 +01:00
Javi Rueda daf4e5aca2 Use ListView to show startup stage errors 2020-12-09 21:05:21 +01:00
Akinwale Ariwodola c1324efb41 bumpversion 0.16.9 --> 0.16.10 2020-12-09 11:47:58 +01:00
Akinwale Ariwodola 6221de2d3c sync notificationsDisabled states for followed channels 2020-12-09 11:31:13 +01:00
Akinwale Ariwodola 983bc68af2 Merge branch 'master' of https://github.com/lbryio/lbry-android 2020-12-09 11:00:25 +01:00
Akinwale Ariwodola f1b167693d SDK 0.86.1. is_seen vs is_read swap. Fix error condition where wallet sync starts if the wallet is not ready. 2020-12-09 10:59:25 +01:00
Akinwale Ariwodola 68ac64b534 Merge pull request #1057 from kekkyojin/sort-commentreplies
Sort replies from oldest to newest
2020-12-05 04:32:41 +01:00
Javi Rueda 6819ae46f9 Sort replies from oldest to newest 2020-12-01 04:58:48 +01:00
Akinwale Ariwodola 6c406c5a85 share_usage_data setting 2020-11-29 05:07:54 +01:00
Akinwale Ariwodola c179243d22 update dependencies 2020-11-26 00:04:37 +01:00
Akinwale Ariwodola d0f5504c80 LbryUri parsing improvements. Remove duplicate code. 2020-11-15 09:11:50 +01:00
Akinwale Ariwodola 896c566a02 Merge pull request #1045 from kekkyojin/open-file-external
Offer opening unsupported filetypes with external app
2020-11-13 15:42:59 +01:00
Javi Rueda da9352cc68 Offer opening unsupported filetypes with external app 2020-10-27 14:28:15 +01:00
Akinwale Ariwodola b8d2375e20 Merge pull request #1044 from ycohen-dev/fix_issue_1043
Fix floating wallet/rewards bar for RTL layout
2020-10-23 13:25:07 +01:00
Akinwale Ariwodola dd52ff9d07 Merge pull request #1033 from kekkyojin/md-text-rendering
Fix for text not rendering after # in markdown
2020-10-23 13:23:15 +01:00
yuval d9891f8a8a Floating wallet balance/rewards now visible in RTL layout
(Fix issue #1043)
2020-10-22 22:22:44 +03:00
Akinwale Ariwodola ea5fe6842d Merge pull request #1041 from ycohen-dev/fix_issue_1040
fix issue 1040
2020-10-21 00:15:36 +01:00
Akinwale Ariwodola fc649187df Merge pull request #1039 from ycohen-dev/fix_issue_1038
fix issue 1038
2020-10-21 00:14:15 +01:00
yuval b0f7c41885 fix issue 1040
Transaction amount text Direction changed to LTR.
Transaction amount pinned to end of view
2020-10-17 22:18:14 +03:00
yuval 45935717c8 fix issue 1038
Replaced gravity pinning to "end" instead of "right"
Pinned claim id which could be in rtl and ltr scripts to the start of the layout
2020-10-16 23:40:28 +03:00
Akinwale Ariwodola ac5e666369 bumpversion 0.16.8 --> 0.16.9 2020-10-16 06:58:57 +01:00
Akinwale Ariwodola ffeb72a383 Publish mature tags. String resource updates. 2020-10-16 06:53:08 +01:00
Akinwale Ariwodola 0ec09d751c Merge pull request #1036 from ycohen-dev/fix_issue_1034
Fix issue #1034
2020-10-16 06:39:45 +01:00
Akinwale Ariwodola b8e4fcff92 Merge pull request #1037 from lbryio/follow-text
add follow text beside follow icon
2020-10-16 06:37:50 +01:00
Akinwale Ariwodola b79f0f4820 add follow text beside follow icon 2020-10-16 06:36:36 +01:00
yuval a1cd58a214 Fix issue #1034
Hide notifications when entering PiP mode
2020-10-16 00:11:08 +03:00
Javi Rueda cfca8facbe Use '%23' instead of '#' when rendering #hashtag style text from markdown 2020-10-15 01:49:53 +02:00
Akinwale Ariwodola 066a0a099c Merge pull request #1032 from lbryio/wallet-balance-page
use credits icon on wallet balance page
2020-10-14 15:33:25 +01:00
Akinwale Ariwodola afeee2e5df use credits icon on wallet balance page 2020-10-14 15:30:59 +01:00
Akinwale Ariwodola 76036acfc7 Merge branch 'master' of https://github.com/lbryio/lbry-android 2020-10-14 15:17:35 +01:00
Akinwale Ariwodola 897bfdaffd fix build error 2020-10-14 15:16:45 +01:00
Akinwale Ariwodola 7475ae323c Merge pull request #1031 from ycohen-dev/fix_issue_1030
Fix issue #1030
2020-10-14 15:12:34 +01:00
Akinwale Ariwodola faf7f3ccbf make credits translatable 2020-10-14 15:11:36 +01:00
Akinwale Ariwodola 4940d1ca33 Merge branch 'master' of https://github.com/lbryio/lbry-android 2020-10-14 15:10:25 +01:00
Akinwale Ariwodola 3d48fa5741 also check pending when checking if item is a placeholder 2020-10-14 15:09:59 +01:00
yuval f9887cffae Fix issue #1030
Dismiss all active dialog fragment when entering PiP mode
So that PiP window contain the video only
2020-10-13 23:17:58 +03:00
Akinwale Ariwodola 6644907665 Merge pull request #1027 from ycohen-dev/fix_issue_1025
Fix issue #1025
2020-10-12 19:25:48 +01:00
Akinwale Ariwodola 5f850685d6 bumpversion 0.16.7 --> 0.16.8 2020-10-12 11:48:24 +01:00
Akinwale Ariwodola 5f9674e49c do not open lbry.*/$/verify links in the app 2020-10-12 11:47:45 +01:00
yuval 0d185c6db3 Fix issue #1025
Increased size of currency selection spinner in publish form fragment
Now spinner is in proper size to display "LBRY Credits" default value
2020-10-10 16:58:29 +03:00
Akinwale Ariwodola 53d22dd22d remove debug logs 2020-10-09 07:43:38 +01:00
Akinwale Ariwodola ff8ffda3c6 bumpversion 0.16.6 --> 0.16.7 2020-10-09 07:39:46 +01:00
Akinwale Ariwodola 64bd540322 In-app notification options (#1023)
* pull-down to refresh in-app notifications
* support deleting notifications
2020-10-09 07:38:47 +01:00
Akinwale Ariwodola 919f9a48f3 Merge pull request #1022 from lbryio/bell-icon
per-channel subscribe notification toggle
2020-10-09 06:58:08 +01:00
Akinwale Ariwodola 746d442051 per-channel subscribe notification toggle 2020-10-09 06:56:13 +01:00
Akinwale Ariwodola 1877b75188 fix strings.xml 2020-10-06 07:14:42 +01:00
Akinwale Ariwodola 6e8c38cace update module versions 2020-10-05 16:56:17 +01:00
Akinwale Ariwodola eab7bab267 Credits icon (#1021)
* new credits icon
* remove references to LBC
2020-10-05 16:50:39 +01:00
Akinwale Ariwodola aab648c3cf Fix errors with deep link handling (#1019) 2020-10-02 12:39:37 +01:00
Javi Rueda f79ff509bd Support some lbry hosts to deep links. Add unit tests (#1008)
* Support lbry.tv and other supported hosts for deep links. Add unit tests for LbryUri parse() method
* add unit test for lbry protocol schema
* Add unit test for lbry.tv deep-link with only channel
2020-10-02 12:34:38 +01:00
Akinwale Ariwodola 1197e990ca cleanup debug logging 2020-10-02 12:09:33 +01:00
Akinwale Ariwodola dce1c0715e move Unpublish button 2020-10-02 12:08:33 +01:00
Akinwale Ariwodola 6a0263c5bc Merge pull request #1013 from clay53/987
Add ability to download & delete your own videos and move unpublish button to description
2020-10-02 11:05:44 +01:00
Akinwale Ariwodola ca64db0499 sdk 0.82.0 2020-10-01 12:42:48 +01:00
Akinwale Ariwodola a5d4eda4d1 bumpversion 0.16.5 --> 0.16.6 2020-09-25 14:45:48 +01:00
Akinwale Ariwodola 5d210961c1 apply mature filter to Editor's Choice 2020-09-25 14:41:40 +01:00
Akinwale Ariwodola 1b88f565af bumpversion 0.16.4 --> 0.16.5 2020-09-23 16:37:41 +01:00
Akinwale Ariwodola 991a98b571 fix shuffle mode player getting stuck 2020-09-23 16:35:59 +01:00
Akinwale Ariwodola 0073277d6e Merge pull request #1017 from lbryio/shuffle-random
keep track of watched content for subsequent shuffle sessions
2020-09-23 16:23:57 +01:00
Akinwale Ariwodola eeca602f7a keep track of watched content for subsequent shuffle sessions 2020-09-23 15:31:34 +01:00
Akinwale Ariwodola 6c171560fd remove Finnish strings 2020-09-18 14:56:35 +01:00
Akinwale Ariwodola 66c4c00215 bumpversion 0.16.3 --> 0.16.4 2020-09-18 14:54:59 +01:00
Akinwale Ariwodola 9b9ef9ab74 Surf mode experiment (#1003)
* surf mode implementation
* occupy entire vertical area
* fix onResume logic
* shuffle mode with selected channel ids
2020-09-18 14:53:19 +01:00
Clayton Hickey 39a289e7f1 Add ability to download & delete your own videos and move unpublish button to description 2020-09-16 14:31:03 -04:00
Akinwale Ariwodola 722c829502 fix paid content stream source 2020-09-14 18:21:31 +01:00
Akinwale Ariwodola 7ecb80d136 Merge pull request #1009 from lbryio/mini-player-margin
add setting for mini-player bottom spacing
2020-09-14 18:05:09 +01:00
Akinwale Ariwodola ea19af04d4 add setting for mini-player bottom spacing 2020-09-14 18:01:38 +01:00
Akinwale Ariwodola 8196b69211 bumpversion 0.16.2 --> 0.16.3 2020-09-14 11:20:47 +01:00
Akinwale Ariwodola dc861caf6c fix websocket for Android < 7.0 2020-09-14 11:19:50 +01:00
Akinwale Ariwodola adb5ffa8d0 exclude x86_64 lib from build 2020-09-14 11:06:39 +01:00
Akinwale Ariwodola d918cb28bd sdk 0.81.0 2020-09-11 13:50:16 +01:00
Akinwale Ariwodola 7ce7314ab9 bumpversion 0.16.1 --> 0.16.2 2020-09-11 13:41:30 +01:00
Javi Rueda 13e5caa0ef Use Start/End instead of Left/Right to support RTL (#1005)
* Use Start/End instead of Left/Right to support RTL
* Change it also for relative layout properties
2020-09-11 13:28:37 +01:00
Akinwale Ariwodola ff59a7a89f Merge pull request #1007 from lbryio/first-run-install-id
generate install_id natively
2020-09-11 13:22:42 +01:00
Akinwale Ariwodola c3efa4d004 generate install_id natively 2020-09-10 12:20:49 +01:00
Akinwale Ariwodola ed50e1300a real time notifications over websocket (#1000)
* real time notifications over websocket
* automatically re-establish websocket connections
2020-09-09 14:16:22 +01:00
Akinwale Ariwodola 86dbfd54d1 Merge pull request #1006 from lbryio/notification-back
proper back navigation to the notifications screen
2020-09-09 14:05:29 +01:00
Akinwale Ariwodola 535120eebd proper back navigation to the notifications screen 2020-09-09 14:03:36 +01:00
Akinwale Ariwodola c1106d7186 display correct playback speed for media 2020-09-04 12:50:22 +01:00
Akinwale Ariwodola 45be7f2c9b Merge pull request #1004 from lbryio/player-resume-black-screen
display player view correctly after dismissing PIP view
2020-09-04 12:33:53 +01:00
Akinwale Ariwodola d6baf3d1c8 display player view correctly after dismissing PIP view 2020-09-04 12:32:53 +01:00
Akinwale Ariwodola 08c38c1723 bumpversion 0.16.0 --> 0.16.1 2020-08-28 10:07:20 +01:00
Javi Rueda af4fa454d3 Add setting to enable sending buffering events (#993)
* Add setting to enable sending buffering events
* Use true as default value
2020-08-28 10:06:41 +01:00
Akinwale Ariwodola 0620582a4e fix in-app notification read background in dark mode 2020-08-28 10:04:10 +01:00
Akinwale Ariwodola b11c07e3d1 fix comment redirect from device notifications 2020-08-28 10:00:57 +01:00
268 changed files with 7131 additions and 3844 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -66,3 +66,4 @@ app/twitter.properties
*.hprof *.hprof
app/build app/build
bin bin
app/debuglib
+6 -6
View File
@@ -9,8 +9,8 @@ build apk:
image: lbry/android-base:platform-28 image: lbry/android-base:platform-28
before_script: before_script:
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list - echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
- wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add - - wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
- apt-get -y update && apt-get -y install build-essential ca-certificates curl git gpg-agent openjdk-8-jdk software-properties-common wget zipalign git-secret - apt-get -y update && apt-get -y install build-essential ca-certificates curl git gpg-agent openjdk-8-jdk software-properties-common wget zipalign git-secret
- git secret reveal - git secret reveal
- chmod u+x $CI_PROJECT_DIR/gradlew - chmod u+x $CI_PROJECT_DIR/gradlew
@@ -36,8 +36,8 @@ deploy build.lbry.io:
before_script: before_script:
- apt-get -y update && apt-get -y install apt-transport-https - apt-get -y update && apt-get -y install apt-transport-https
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list - echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
- wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add - - wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret - apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
- pip install awscli - pip install awscli
- chmod u+x $CI_PROJECT_DIR/gradlew - chmod u+x $CI_PROJECT_DIR/gradlew
@@ -60,8 +60,8 @@ release apk:
before_script: before_script:
- apt-get -y update && apt-get -y install apt-transport-https - apt-get -y update && apt-get -y install apt-transport-https
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import - echo "$PGP_PRIVATE_KEY" | gpg --batch --import
- echo "deb https://dl.bintray.com/sobolevn/deb git-secret main" | tee -a /etc/apt/sources.list - echo 'deb https://gitsecret.jfrog.io/artifactory/git-secret-deb git-secret main' >> /etc/apt/sources.list
- wget -O - https://api.bintray.com/users/sobolevn/keys/gpg/public.key | apt-key add - - wget -qO - 'https://gitsecret.jfrog.io/artifactory/api/gpg/key/public' | apt-key add -
- apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret - apt-get -y update && apt-get -y install openjdk-8-jdk git git-secret
- pip install awscli githubrelease - pip install awscli githubrelease
- git secret reveal - git secret reveal
+14 -2
View File
@@ -18,7 +18,19 @@ The minimum supported Android version is 5.0 Lollipop. There are two ways to ins
The app can be launched by opening **LBRY** from the device's app drawer or via the shortcut on the home screen if that was created upon installation. The app can be launched by opening **LBRY** from the device's app drawer or via the shortcut on the home screen if that was created upon installation.
## Running from Source ## Running from Source
Clone the repository and open the project in Android Studio. Android Studio will automatically run the initial build process. Click the Run button to launch the app on your simulator or connected debugging device after the build process is complete. Clone the repository and open the project in Android Studio. Android Studio will automatically run the initial build process.
Create file 'twitter.properties' in app/ folder with the following content:
```
twitterConsumerKey=XXXXXX
twitterConsumerSecret=XXXXXX
```
Copy the file 'google-services.sample.json' to 'google-services.json' in the app/ folder.
Click the Sync button and when process finishes, the Run button to launch the app on your simulator or connected debugging device after the build process is complete.
## Contributing ## Contributing
Contributions to this project are welcome, encouraged, and compensated. For more details, see https://lbry.io/faq/contributing Contributions to this project are welcome, encouraged, and compensated. For more details, see https://lbry.io/faq/contributing
@@ -27,7 +39,7 @@ Contributions to this project are welcome, encouraged, and compensated. For more
This project is MIT licensed. For the full license, see [LICENSE](LICENSE). This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
## Security ## Security
We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://keybase.io/lbry/key.asc) if you need it. We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://lbry.com/faq/pgp-key) if you need it.
## Contact ## Contact
The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com) The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com)
+32 -21
View File
@@ -4,7 +4,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.1" buildToolsVersion "29.0.2"
flavorDimensions "default" flavorDimensions "default"
compileOptions { compileOptions {
@@ -16,14 +16,14 @@ android {
applicationId "io.lbry.browser" applicationId "io.lbry.browser"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 29
versionCode 1600 versionCode 1701
versionName "0.16.0" versionName "0.17.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
packagingOptions { packagingOptions {
exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/DEPENDENCIES'
exclude 'lib/x86_64/darwin/libscrypt.dylib'
} }
productFlavors { productFlavors {
@@ -79,34 +79,35 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha01' implementation 'com.google.android.material:material:1.3.0-alpha01'
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment:2.2.2' implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.2.2' implementation 'androidx.navigation:navigation-ui:2.3.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.webkit:webkit:1.3.0-alpha03' implementation 'androidx.webkit:webkit:1.4.0-rc01'
implementation 'androidx.camera:camera-core:1.0.0-beta03' implementation 'androidx.camera:camera-core:1.0.0-beta03'
implementation 'androidx.camera:camera-camera2:1.0.0-beta03' implementation 'androidx.camera:camera-camera2:1.0.0-beta03'
implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03' implementation 'androidx.camera:camera-lifecycle:1.0.0-beta03'
implementation 'androidx.camera:camera-view:1.0.0-alpha10' implementation 'androidx.camera:camera-view:1.0.0-alpha10'
implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.browser:browser:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.11.0' implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.squareup.okhttp3:okhttp:4.4.1' implementation 'com.squareup.okhttp3:okhttp:4.4.1'
implementation 'com.google.firebase:firebase-analytics:17.4.2' implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.android.gms:play-services-base:17.2.1' implementation 'com.google.android.gms:play-services-base:17.5.0'
implementation 'com.google.firebase:firebase-messaging:20.2.0' implementation 'com.google.firebase:firebase-messaging:21.0.0'
implementation 'com.google.oauth-client:google-oauth-client:1.30.4' implementation 'com.google.oauth-client:google-oauth-client:1.30.4'
implementation 'com.android.billingclient:billing:3.0.0' implementation 'com.android.billingclient:billing:3.0.2'
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.android.exoplayer:exoplayer-core:2.11.4' implementation 'com.google.android.exoplayer:exoplayer-core:2.12.2'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.11.4' implementation 'com.google.android.exoplayer:exoplayer-dash:2.12.2'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.11.4' implementation 'com.google.android.exoplayer:exoplayer-ui:2.12.2'
implementation 'com.google.android.exoplayer:extension-cast:2.11.4' implementation 'com.google.android.exoplayer:extension-cast:2.12.2'
implementation 'com.google.android.exoplayer:extension-mediasession:2.11.4' implementation 'com.google.android.exoplayer:extension-mediasession:2.12.2'
implementation 'com.google.android:flexbox:2.0.1' implementation 'com.google.android:flexbox:2.0.1'
@@ -117,16 +118,26 @@ dependencies {
implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS' implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.3.1.LTS'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bitcoinj:bitcoinj-tools:0.14.7'
implementation 'org.java-websocket:Java-WebSocket:1.5.1'
implementation ('com.journeyapps:zxing-android-embedded:4.1.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'
compileOnly 'org.projectlombok:lombok:1.18.10' compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10' annotationProcessor 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
__32bitImplementation 'io.lbry:lbrysdk32:0.80.0' __32bitImplementation 'io.lbry:lbrysdk32:0.102.0'
__64bitImplementation 'io.lbry:lbrysdk64:0.80.0' __64bitImplementation 'io.lbry:lbrysdk64:0.102.0'
//__64bitImplementation(name: 'lbrysdk', ext: 'aar')
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
@@ -0,0 +1,12 @@
package io.lbry.browser.utils;
import androidx.test.filters.SmallTest;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@SmallTest
public class HelperTest {
}
+21
View File
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.lbry.browser" package="io.lbry.browser"
android:installLocation="auto"> android:installLocation="auto">
@@ -11,6 +12,9 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" /> <uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@@ -68,6 +72,18 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<data android:scheme="https" android:host="open.lbry.com"/> <data android:scheme="https" android:host="open.lbry.com"/>
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/..*/*" />
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/.*:.*" />
<data android:scheme="https" android:host="lbry.tv" android:pathPattern="/.*#.*" />
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/..*/*" />
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/.*:.*" />
<data android:scheme="https" android:host="lbry.lat" android:pathPattern="/.*#.*" />
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/..*/*" />
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/.*:.*" />
<data android:scheme="https" android:host="lbry.fr" android:pathPattern="/.*#.*" />
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/..*/*" />
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/.*:.*" />
<data android:scheme="https" android:host="lbry.in" android:pathPattern="/.*#.*" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
@@ -85,6 +101,11 @@
android:theme="@style/AppTheme.NoActionBarTranslucent" android:theme="@style/AppTheme.NoActionBarTranslucent"
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="fullSensor"
tools:replace="screenOrientation" />
<service <service
android:name="io.lbry.browser.LbrynetMessagingService" android:name="io.lbry.browser.LbrynetMessagingService"
android:exported="false"> android:exported="false">
@@ -15,12 +15,22 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.text.HtmlCompat; import androidx.core.text.HtmlCompat;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import io.lbry.browser.exceptions.AuthTokenInvalidatedException; import io.lbry.browser.exceptions.AuthTokenInvalidatedException;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryAnalytics; import io.lbry.browser.utils.LbryAnalytics;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import io.lbry.lbrysdk.LbrynetService; import io.lbry.lbrysdk.LbrynetService;
import io.lbry.lbrysdk.ServiceHelper;
import io.lbry.lbrysdk.Utils;
public class FirstRunActivity extends AppCompatActivity { public class FirstRunActivity extends AppCompatActivity {
@@ -44,12 +54,7 @@ public class FirstRunActivity extends AppCompatActivity {
}); });
registerAuthReceiver(); registerAuthReceiver();
if (!Lbry.SDK_READY) { findViewById(R.id.welcome_wait_container).setVisibility(View.VISIBLE);
findViewById(R.id.welcome_wait_container).setVisibility(View.VISIBLE);
} else {
authenticate();
}
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(MainActivity.ACTION_SDK_READY); filter.addAction(MainActivity.ACTION_SDK_READY);
filter.addAction(LbrynetService.ACTION_STOP_SERVICE); filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
@@ -62,10 +67,38 @@ public class FirstRunActivity extends AppCompatActivity {
authenticate(); authenticate();
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) { } else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
finish(); finish();
if (MainActivity.instance != null) {
MainActivity.instance.finish();
}
} }
} }
}; };
registerReceiver(sdkReceiver, filter); registerReceiver(sdkReceiver, filter);
CheckInstallIdTask task = new CheckInstallIdTask(this, new CheckInstallIdTask.InstallIdHandler() {
@Override
public void onInstallIdChecked(boolean result) {
// start the sdk from FirstRun
boolean serviceRunning = MainActivity.isServiceRunning(MainActivity.instance, LbrynetService.class);
if (!serviceRunning) {
Lbry.SDK_READY = false;
ServiceHelper.start(MainActivity.instance, "", LbrynetService.class, "lbrynetservice");
}
if (result) {
// install_id generated and validated, authenticate now
authenticate();
return;
}
// we weren't able to generate the install_id ourselves, depend on the sdk for that
if (Lbry.SDK_READY) {
authenticate();
return;
}
}
});
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }
public void onResume() { public void onResume() {
@@ -134,8 +167,76 @@ public class FirstRunActivity extends AppCompatActivity {
super.onDestroy(); super.onDestroy();
} }
private void generateIdAndAuthenticate() {
}
private static class CheckInstallIdTask extends AsyncTask<Void, Void, Boolean> {
private final Context context;
private final InstallIdHandler handler;
public CheckInstallIdTask(Context context, InstallIdHandler handler) {
this.context = context;
this.handler = handler;
}
protected Boolean doInBackground(Void... params) {
// Load the installation id from the file system
String lbrynetDir = String.format("%s/%s", Utils.getAppInternalStorageDir(context), "lbrynet");
File dir = new File(lbrynetDir);
boolean dirExists = dir.isDirectory();
if (!dirExists) {
dirExists = dir.mkdirs();
}
if (!dirExists) {
return false;
}
String installIdPath = String.format("%s/install_id", lbrynetDir);
File file = new File(installIdPath);
String installId = null;
if (!file.exists()) {
// generate the install_id
installId = Lbry.generateId();
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new FileWriter(file));
writer.write(installId);
} catch (IOException ex) {
return false;
} finally {
Helper.closeCloseable(writer);
}
} else {
// read the installation id from the file
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(installIdPath)));
installId = reader.readLine();
} catch (IOException ex) {
return false;
} finally {
Helper.closeCloseable(reader);
}
}
if (!Helper.isNullOrEmpty(installId)) {
Lbry.INSTALLATION_ID = installId;
}
return !Helper.isNullOrEmpty(installId);
}
protected void onPostExecute(Boolean result) {
if (handler != null) {
handler.onInstallIdChecked(result);
}
}
public interface InstallIdHandler {
void onInstallIdChecked(boolean result);
}
}
private static class AuthenticateTask extends AsyncTask<Void, Void, Void> { private static class AuthenticateTask extends AsyncTask<Void, Void, Void> {
private Context context; private final Context context;
public AuthenticateTask(Context context) { public AuthenticateTask(Context context) {
this.context = context; this.context = context;
} }
@@ -58,7 +58,7 @@ public class LbrynetMessagingService extends FirebaseMessagingService {
String name = payload.get("name"); // notification name String name = payload.get("name"); // notification name
String hash = payload.get("hash"); // comment hash String hash = payload.get("hash"); // comment hash
if (type != null && getEnabledTypes().indexOf(type) > -1 && body != null && body.trim().length() > 0) { if (type != null && getEnabledTypes().contains(type) && body != null && body.trim().length() > 0) {
// only log the receive event for valid notifications received // only log the receive event for valid notifications received
if (firebaseAnalytics != null) { if (firebaseAnalytics != null) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@@ -100,7 +100,7 @@ public class LbrynetMessagingService extends FirebaseMessagingService {
@Override @Override
public void onNewToken(String token) { public void onNewToken(String token) {
Log.d(TAG, "Refreshed token: " + token); //Log.d(TAG, "Refreshed token: " + token);
// If you want to send messages to this application instance or // If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the // manage this apps subscriptions on the server side, send the
File diff suppressed because it is too large. Load diff
@@ -31,6 +31,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import io.lbry.browser.adapter.VerificationPagerAdapter; import io.lbry.browser.adapter.VerificationPagerAdapter;
import io.lbry.browser.listener.SdkStatusListener;
import io.lbry.browser.listener.SignInListener; import io.lbry.browser.listener.SignInListener;
import io.lbry.browser.listener.WalletSyncListener; import io.lbry.browser.listener.WalletSyncListener;
import io.lbry.browser.model.lbryinc.RewardVerified; import io.lbry.browser.model.lbryinc.RewardVerified;
@@ -48,13 +49,14 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public static final int VERIFICATION_FLOW_REWARDS = 2; public static final int VERIFICATION_FLOW_REWARDS = 2;
public static final int VERIFICATION_FLOW_WALLET = 3; public static final int VERIFICATION_FLOW_WALLET = 3;
private List<SdkStatusListener> sdkStatusListeners;
private BillingClient billingClient; private BillingClient billingClient;
private BroadcastReceiver sdkReceiver; private BroadcastReceiver sdkReceiver;
private String email; private String email;
private boolean signedIn; private boolean signedIn;
private int flow; private int flow;
private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() { private final PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
@Override @Override
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) { public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
int responseCode = billingResult.getResponseCode(); int responseCode = billingResult.getResponseCode();
@@ -105,6 +107,8 @@ public class VerificationActivity extends FragmentActivity implements SignInList
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
sdkStatusListeners = new ArrayList<>();
signedIn = Lbryio.isSignedIn(); signedIn = Lbryio.isSignedIn();
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null) { if (intent != null) {
@@ -126,11 +130,18 @@ public class VerificationActivity extends FragmentActivity implements SignInList
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
filter.addAction(LbrynetService.ACTION_STOP_SERVICE); filter.addAction(LbrynetService.ACTION_STOP_SERVICE);
filter.addAction(MainActivity.ACTION_SDK_READY);
sdkReceiver = new BroadcastReceiver() { sdkReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); String action = intent.getAction();
if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) { if (MainActivity.ACTION_SDK_READY.equals(action)) {
for (SdkStatusListener listener : sdkStatusListeners) {
if (listener != null) {
listener.onSdkReady();
}
}
} else if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
finish(); finish();
} }
} }
@@ -193,15 +204,16 @@ public class VerificationActivity extends FragmentActivity implements SignInList
} else if (flow == VERIFICATION_FLOW_REWARDS) { } else if (flow == VERIFICATION_FLOW_REWARDS) {
User user = Lbryio.currentUser; User user = Lbryio.currentUser;
// disable phone verification for now // disable phone verification for now
/*if (!user.isIdentityVerified()) { if (!user.isIdentityVerified()) {
// phone number verification required // phone number verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
flowHandled = true; flowHandled = true;
} else */ } else {
if (!user.isRewardApproved()) { if (!user.isRewardApproved()) {
// manual verification required // manual verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
flowHandled = true; flowHandled = true;
}
} }
} }
@@ -214,6 +226,11 @@ public class VerificationActivity extends FragmentActivity implements SignInList
} }
} }
public void showPhoneVerification() {
ViewPager2 viewPager = findViewById(R.id.verification_pager);
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
}
public void showLoading() { public void showLoading() {
findViewById(R.id.verification_loading_progress).setVisibility(View.VISIBLE); findViewById(R.id.verification_loading_progress).setVisibility(View.VISIBLE);
findViewById(R.id.verification_pager).setVisibility(View.INVISIBLE); findViewById(R.id.verification_pager).setVisibility(View.INVISIBLE);
@@ -227,8 +244,12 @@ public class VerificationActivity extends FragmentActivity implements SignInList
@Override @Override
public void onBackPressed() { public void onBackPressed() {
// ignore back press ViewPager2 viewPager = findViewById(R.id.verification_pager);
return;
if (viewPager.getCurrentItem() != VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL)
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL);
else
super.onBackPressed();
} }
public void onEmailAdded(String email) { public void onEmailAdded(String email) {
@@ -285,20 +306,18 @@ public class VerificationActivity extends FragmentActivity implements SignInList
ViewPager2 viewPager = findViewById(R.id.verification_pager); ViewPager2 viewPager = findViewById(R.id.verification_pager);
// for rewards, (show phone verification if not done, or manual verification if required) // for rewards, (show phone verification if not done, or manual verification if required)
if (flow == VERIFICATION_FLOW_REWARDS) { if (flow == VERIFICATION_FLOW_REWARDS) {
// skipping phone verification if (!user.isIdentityVerified()) {
/*if (!user.isIdentityVerified()) {
// phone number verification required // phone number verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_PHONE, false);
} else
*/
if (!user.isRewardApproved()) {
// manual verification required
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
} else { } else {
// fully verified if (!user.isRewardApproved()) {
setResult(RESULT_OK); // manual verification required
finish(); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
} else {
// fully verified
setResult(RESULT_OK);
finish();
}
} }
} else if (flow == VERIFICATION_FLOW_WALLET) { } else if (flow == VERIFICATION_FLOW_WALLET) {
// for wallet sync, if password unlock is required, show password entry page // for wallet sync, if password unlock is required, show password entry page
@@ -336,6 +355,7 @@ public class VerificationActivity extends FragmentActivity implements SignInList
return; return;
} }
findViewById(R.id.verification_close_button).setVisibility(View.VISIBLE);
// show manual verification page if the user is still not reward approved // show manual verification page if the user is still not reward approved
ViewPager2 viewPager = findViewById(R.id.verification_pager); ViewPager2 viewPager = findViewById(R.id.verification_pager);
viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false); viewPager.setCurrentItem(VerificationPagerAdapter.PAGE_VERIFICATION_MANUAL, false);
@@ -436,4 +456,14 @@ public class VerificationActivity extends FragmentActivity implements SignInList
Helper.unregisterReceiver(sdkReceiver, this); Helper.unregisterReceiver(sdkReceiver, this);
super.onDestroy(); super.onDestroy();
} }
public void addSdkStatusListener(SdkStatusListener listener) {
if (!sdkStatusListeners.contains(listener)) {
sdkStatusListeners.add(listener);
}
}
public void removeSdkStatusListener(SdkStatusListener listener) {
sdkStatusListeners.remove(listener);
}
} }
@@ -23,7 +23,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilterListAdapter.ViewHolder> { public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilterListAdapter.ViewHolder> {
private Context context; private final Context context;
private List<Claim> items; private List<Claim> items;
@Getter @Getter
@Setter @Setter
@@ -42,12 +42,12 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected View mediaContainer; protected final View mediaContainer;
protected View alphaContainer; protected final View alphaContainer;
protected View allView; protected final View allView;
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected TextView alphaView; protected final TextView alphaView;
protected TextView titleView; protected final TextView titleView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
mediaContainer = v.findViewById(R.id.channel_filter_media_container); mediaContainer = v.findViewById(R.id.channel_filter_media_container);
@@ -95,13 +95,13 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE); vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle()); vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
String thumbnailUrl = claim.getThumbnailUrl(); String thumbnailUrl = claim.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) { if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} }
vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE); vh.alphaContainer.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.VISIBLE : View.GONE);
vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE); vh.thumbnailView.setVisibility(claim.isPlaceholder() || Helper.isNullOrEmpty(thumbnailUrl) ? View.GONE : View.VISIBLE);
vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2) : ""); vh.alphaView.setText(claim.isPlaceholder() ? null : claim.getName() != null ? claim.getName().substring(1, 2).toUpperCase() : "");
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId()); int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context); Helper.setIconViewBackgroundColor(vh.alphaContainer, bgColor, claim.isPlaceholder(), context);
@@ -21,7 +21,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.listener.SelectionModeListener; import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
@@ -37,18 +36,18 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
private static final int VIEW_TYPE_CHANNEL = 2; private static final int VIEW_TYPE_CHANNEL = 2;
private static final int VIEW_TYPE_FEATURED = 3; // featured search result private static final int VIEW_TYPE_FEATURED = 3; // featured search result
private Map<String, Claim> quickClaimIdMap; private final Map<String, Claim> quickClaimIdMap;
private Map<String, Claim> quickClaimUrlMap; private final Map<String, Claim> quickClaimUrlMap;
private Map<String, Boolean> notFoundClaimIdMap; private final Map<String, Boolean> notFoundClaimIdMap;
private Map<String, Boolean> notFoundClaimUrlMap; private final Map<String, Boolean> notFoundClaimUrlMap;
@Setter @Setter
private boolean hideFee; private boolean hideFee;
@Setter @Setter
private boolean canEnterSelectionMode; private boolean canEnterSelectionMode;
private Context context; private final Context context;
private List<Claim> items; private List<Claim> items;
private List<Claim> selectedItems; private final List<Claim> selectedItems;
@Setter @Setter
private ClaimListItemListener listener; private ClaimListItemListener listener;
@Getter @Getter
@@ -176,27 +175,27 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected View feeContainer; protected final View feeContainer;
protected TextView feeView; protected final TextView feeView;
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected View noThumbnailView; protected final View noThumbnailView;
protected TextView alphaView; protected final TextView alphaView;
protected TextView vanityUrlView; protected final TextView vanityUrlView;
protected TextView durationView; protected final TextView durationView;
protected TextView titleView; protected final TextView titleView;
protected TextView publisherView; protected final TextView publisherView;
protected TextView publishTimeView; protected final TextView publishTimeView;
protected TextView pendingTextView; protected final TextView pendingTextView;
protected View repostInfoView; protected final View repostInfoView;
protected TextView repostChannelView; protected final TextView repostChannelView;
protected View selectedOverlayView; protected final View selectedOverlayView;
protected TextView fileSizeView; protected final TextView fileSizeView;
protected ProgressBar downloadProgressView; protected final ProgressBar downloadProgressView;
protected TextView deviceView; protected final TextView deviceView;
protected View loadingImagePlaceholder; protected final View loadingImagePlaceholder;
protected View loadingTextPlaceholder1; protected final View loadingTextPlaceholder1;
protected View loadingTextPlaceholder2; protected final View loadingTextPlaceholder2;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
feeContainer = v.findViewById(R.id.claim_fee_container); feeContainer = v.findViewById(R.id.claim_fee_container);
@@ -323,7 +322,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
int paddingBottom = position == getItemCount() - 1 ? 16 : 8; int paddingBottom = position == getItemCount() - 1 ? 16 : 8;
int paddingTopScaled = Helper.getScaledValue(paddingTop, scale); int paddingTopScaled = Helper.getScaledValue(paddingTop, scale);
int paddingBottomScaled = Helper.getScaledValue(paddingBottom, scale); int paddingBottomScaled = Helper.getScaledValue(paddingBottom, scale);
vh.itemView.setPadding(vh.itemView.getPaddingLeft(), paddingTopScaled, vh.itemView.getPaddingRight(), paddingBottomScaled); vh.itemView.setPadding(vh.itemView.getPaddingStart(), paddingTopScaled, vh.itemView.getPaddingEnd(), paddingBottomScaled);
Claim original = items.get(position); Claim original = items.get(position);
boolean isRepost = Claim.TYPE_REPOST.equalsIgnoreCase(original.getValueType()); boolean isRepost = Claim.TYPE_REPOST.equalsIgnoreCase(original.getValueType());
@@ -335,7 +334,8 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
if (metadata instanceof Claim.StreamMetadata) { if (metadata instanceof Claim.StreamMetadata) {
streamMetadata = (Claim.StreamMetadata) metadata; streamMetadata = (Claim.StreamMetadata) metadata;
} }
String thumbnailUrl = item.getThumbnailUrl();
String thumbnailUrl = item.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000; long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000;
int bgColor = Helper.generateRandomColorForValue(item.getClaimId()); int bgColor = Helper.generateRandomColorForValue(item.getClaimId());
if (bgColor == 0) { if (bgColor == 0) {
@@ -404,7 +404,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE); vh.publishTimeView.setVisibility(!isPending ? View.VISIBLE : View.GONE);
vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE); vh.pendingTextView.setVisibility(isPending && !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
vh.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE); vh.repostInfoView.setVisibility(isRepost && type != VIEW_TYPE_FEATURED ? View.VISIBLE : View.GONE);
vh.repostChannelView.setText(isRepost ? original.getSigningChannel().getName() : null); vh.repostChannelView.setText(isRepost && original.getSigningChannel() != null ? original.getSigningChannel().getName() : null);
vh.repostChannelView.setOnClickListener(new View.OnClickListener() { vh.repostChannelView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@@ -430,7 +430,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
Helper.setViewVisibility(vh.loadingTextPlaceholder2, item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE); Helper.setViewVisibility(vh.loadingTextPlaceholder2, item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
Helper.setViewVisibility(vh.titleView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE); Helper.setViewVisibility(vh.titleView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
Helper.setViewVisibility(vh.publisherView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE); Helper.setViewVisibility(vh.publisherView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE);
Helper.setViewVisibility(vh.publishTimeView, !item.isLoadingPlaceholder() ? View.VISIBLE : View.GONE); Helper.setViewVisibility(vh.publishTimeView, !item.isLoadingPlaceholder() && !isPending ? View.VISIBLE : View.GONE);
if (type == VIEW_TYPE_FEATURED && item.isUnresolved()) { if (type == VIEW_TYPE_FEATURED && item.isUnresolved()) {
vh.durationView.setVisibility(View.GONE); vh.durationView.setVisibility(View.GONE);
@@ -27,9 +27,9 @@ import io.lbry.browser.utils.LbryUri;
import lombok.Setter; import lombok.Setter;
public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> { public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.ViewHolder> {
private List<Comment> items; private final List<Comment> items;
private Context context; private final Context context;
private boolean nested; private final boolean nested;
private float scale; private float scale;
@Setter @Setter
private ClaimListAdapter.ClaimListItemListener listener; private ClaimListAdapter.ClaimListItemListener listener;
@@ -102,14 +102,14 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected TextView channelName; protected final TextView channelName;
protected TextView commentText; protected final TextView commentText;
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected View noThumbnailView; protected final View noThumbnailView;
protected TextView alphaView; protected final TextView alphaView;
protected TextView commentTimeView; protected final TextView commentTimeView;
protected View replyLink; protected final View replyLink;
protected RecyclerView repliesList; protected final RecyclerView repliesList;
public ViewHolder (View v) { public ViewHolder (View v) {
super(v); super(v);
@@ -173,9 +173,9 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
public void onBindViewHolder(ViewHolder holder, int position) { public void onBindViewHolder(ViewHolder holder, int position) {
Comment comment = items.get(position); Comment comment = items.get(position);
holder.itemView.setPadding( holder.itemView.setPadding(
nested ? Helper.getScaledValue(56, scale) : holder.itemView.getPaddingLeft(), nested ? Helper.getScaledValue(56, scale) : holder.itemView.getPaddingStart(),
holder.itemView.getPaddingTop(), holder.itemView.getPaddingTop(),
nested ? 0 : holder.itemView.getPaddingRight(), nested ? 0 : holder.itemView.getPaddingEnd(),
holder.itemView.getPaddingBottom()); holder.itemView.getPaddingBottom());
holder.channelName.setText(comment.getChannelName()); holder.channelName.setText(comment.getChannelName());
@@ -190,7 +190,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId()); int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context); Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
if (hasThumbnail) { if (hasThumbnail) {
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl()). Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl(holder.thumbnailView.getLayoutParams().width, holder.thumbnailView.getLayoutParams().height, 85)).
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView); apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
} }
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null); holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
@@ -23,8 +23,8 @@ public class EditorsChoiceItemAdapter extends RecyclerView.Adapter<EditorsChoice
private static final int VIEW_TYPE_HEADER = 1; private static final int VIEW_TYPE_HEADER = 1;
private static final int VIEW_TYPE_CONTENT = 2; private static final int VIEW_TYPE_CONTENT = 2;
private Context context; private final Context context;
private List<EditorsChoiceItem> items; private final List<EditorsChoiceItem> items;
@Setter @Setter
private EditorsChoiceItemListener listener; private EditorsChoiceItemListener listener;
@@ -48,11 +48,11 @@ public class EditorsChoiceItemAdapter extends RecyclerView.Adapter<EditorsChoice
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected TextView descriptionView; protected final TextView descriptionView;
protected TextView headerView; protected final TextView headerView;
protected TextView titleView; protected final TextView titleView;
protected View cardView; protected final View cardView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
@@ -21,8 +21,8 @@ import io.lbry.browser.utils.Helper;
import lombok.Setter; import lombok.Setter;
public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.ViewHolder> { public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.ViewHolder> {
private Context context; private final Context context;
private List<GalleryItem> items; private final List<GalleryItem> items;
@Setter @Setter
private GalleryItemClickListener listener; private GalleryItemClickListener listener;
@@ -32,8 +32,8 @@ public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected TextView durationView; protected final TextView durationView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
thumbnailView = v.findViewById(R.id.gallery_item_thumbnail); thumbnailView = v.findViewById(R.id.gallery_item_thumbnail);
@@ -96,8 +96,8 @@ public class GalleryGridAdapter extends RecyclerView.Adapter<GalleryGridAdapter.
public static class GalleryGridItemDecoration extends RecyclerView.ItemDecoration { public static class GalleryGridItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount; private final int spanCount;
private int spacing; private final int spacing;
public GalleryGridItemDecoration(int spanCount, int spacing) { public GalleryGridItemDecoration(int spanCount, int spacing) {
this.spanCount = spanCount; this.spanCount = spanCount;
@@ -1,12 +1,10 @@
package io.lbry.browser.adapter; package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
@@ -18,9 +16,9 @@ import io.lbry.browser.model.Claim;
public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> { public class InlineChannelSpinnerAdapter extends ArrayAdapter<Claim> {
private List<Claim> channels; private final List<Claim> channels;
private int layoutResourceId; private final int layoutResourceId;
private LayoutInflater inflater; private final LayoutInflater inflater;
public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) { public InlineChannelSpinnerAdapter(Context context, int resource, List<Claim> channels) {
super(context, resource, 0, channels); super(context, resource, 0, channels);
@@ -1,9 +1,7 @@
package io.lbry.browser.adapter; package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -11,21 +9,16 @@ import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.lbryinc.Invitee; import io.lbry.browser.model.lbryinc.Invitee;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.ViewHolder> { public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.ViewHolder> {
private Context context; private final Context context;
private List<Invitee> items; private final List<Invitee> items;
public InviteeListAdapter(List<Invitee> invitees, Context context) { public InviteeListAdapter(List<Invitee> invitees, Context context) {
this.context = context; this.context = context;
@@ -80,8 +73,8 @@ public class InviteeListAdapter extends RecyclerView.Adapter<InviteeListAdapter.
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected TextView emailView; protected final TextView emailView;
protected TextView rewardView; protected final TextView rewardView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
@@ -10,13 +10,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.Language; import io.lbry.browser.model.Language;
import io.lbry.browser.utils.Predefined; import io.lbry.browser.utils.Predefined;
public class LanguageSpinnerAdapter extends ArrayAdapter<Language> { public class LanguageSpinnerAdapter extends ArrayAdapter<Language> {
private int layoutResourceId; private final int layoutResourceId;
private LayoutInflater inflater; private final LayoutInflater inflater;
public LanguageSpinnerAdapter(Context context, int resource) { public LanguageSpinnerAdapter(Context context, int resource) {
super(context, resource, 0, Predefined.PUBLISH_LANGUAGES); super(context, resource, 0, Predefined.PUBLISH_LANGUAGES);
@@ -10,13 +10,12 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.model.Language;
import io.lbry.browser.model.License; import io.lbry.browser.model.License;
import io.lbry.browser.utils.Predefined; import io.lbry.browser.utils.Predefined;
public class LicenseSpinnerAdapter extends ArrayAdapter<License> { public class LicenseSpinnerAdapter extends ArrayAdapter<License> {
private int layoutResourceId; private final int layoutResourceId;
private LayoutInflater inflater; private final LayoutInflater inflater;
public LicenseSpinnerAdapter(Context context, int resource) { public LicenseSpinnerAdapter(Context context, int resource) {
super(context, resource, 0, Predefined.LICENSES); super(context, resource, 0, Predefined.LICENSES);
@@ -2,10 +2,8 @@ package io.lbry.browser.adapter;
import android.content.Context; import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@@ -17,15 +15,14 @@ import io.lbry.browser.R;
import io.lbry.browser.model.NavMenuItem; import io.lbry.browser.model.NavMenuItem;
import io.lbry.browser.ui.controls.SolidIconView; import io.lbry.browser.ui.controls.SolidIconView;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Getter;
import lombok.Setter; import lombok.Setter;
public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAdapter.ViewHolder> { public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAdapter.ViewHolder> {
private static final int TYPE_GROUP = 1; private static final int TYPE_GROUP = 1;
private static final int TYPE_ITEM = 2; private static final int TYPE_ITEM = 2;
private Context context; private final Context context;
private List<NavMenuItem> menuItems; private final List<NavMenuItem> menuItems;
private NavMenuItem currentItem; private NavMenuItem currentItem;
@Setter @Setter
private NavigationMenuItemClickListener listener; private NavigationMenuItemClickListener listener;
@@ -65,8 +62,8 @@ public class NavigationMenuAdapter extends RecyclerView.Adapter<NavigationMenuAd
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected SolidIconView iconView; protected final SolidIconView iconView;
protected TextView titleView; protected final TextView titleView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
titleView = v.findViewById(R.id.nav_menu_title); titleView = v.findViewById(R.id.nav_menu_title);
@@ -18,12 +18,12 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import io.lbry.browser.R; import io.lbry.browser.R;
import io.lbry.browser.listener.SelectionModeListener;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.model.lbryinc.LbryNotification; import io.lbry.browser.model.lbryinc.LbryNotification;
import io.lbry.browser.ui.controls.SolidIconView; import io.lbry.browser.ui.controls.SolidIconView;
@@ -32,7 +32,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@@ -41,27 +40,32 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
private static final String RULE_CREATOR_SUBSCRIBER = "creator_subscriber"; private static final String RULE_CREATOR_SUBSCRIBER = "creator_subscriber";
private static final String RULE_COMMENT = "comment"; private static final String RULE_COMMENT = "comment";
private Context context; private final Context context;
private List<LbryNotification> items; private final List<LbryNotification> items;
private final List<LbryNotification> selectedItems;
@Setter @Setter
private NotificationClickListener clickListener; private NotificationClickListener clickListener;
@Getter @Getter
@Setter @Setter
private int customizeMode; private boolean inSelectionMode;
@Setter
private SelectionModeListener selectionModeListener;
public NotificationListAdapter(List<LbryNotification> notifications, Context context) { public NotificationListAdapter(List<LbryNotification> notifications, Context context) {
this.context = context; this.context = context;
this.items = new ArrayList<>(notifications); this.items = new ArrayList<>(notifications);
this.selectedItems = new ArrayList<>();
Collections.sort(items, Collections.reverseOrder(new LbryNotification())); Collections.sort(items, Collections.reverseOrder(new LbryNotification()));
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected View layoutView; protected final View layoutView;
protected TextView titleView; protected final TextView titleView;
protected TextView bodyView; protected final TextView bodyView;
protected TextView timeView; protected final TextView timeView;
protected SolidIconView iconView; protected final SolidIconView iconView;
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected final View selectedOverlayView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
layoutView = v.findViewById(R.id.notification_layout); layoutView = v.findViewById(R.id.notification_layout);
@@ -70,12 +74,25 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
timeView = v.findViewById(R.id.notification_time); timeView = v.findViewById(R.id.notification_time);
iconView = v.findViewById(R.id.notification_icon); iconView = v.findViewById(R.id.notification_icon);
thumbnailView = v.findViewById(R.id.notification_author_thumbnail); thumbnailView = v.findViewById(R.id.notification_author_thumbnail);
selectedOverlayView = v.findViewById(R.id.notification_selected_overlay);
} }
} }
public int getItemCount() { public int getItemCount() {
return items != null ? items.size() : 0; return items != null ? items.size() : 0;
} }
public List<LbryNotification> getSelectedItems() {
return this.selectedItems;
}
public int getSelectedCount() {
return selectedItems != null ? selectedItems.size() : 0;
}
public void clearSelectedItems() {
this.selectedItems.clear();
}
public boolean isNotificationSelected(LbryNotification notification) {
return selectedItems.contains(notification);
}
public void insertNotification(LbryNotification notification, int index) { public void insertNotification(LbryNotification notification, int index) {
if (!items.contains(notification)) { if (!items.contains(notification)) {
@@ -90,6 +107,12 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void removeNotifications(List<LbryNotification> notifications) {
for (LbryNotification notification : notifications) {
items.remove(notification);
}
notifyDataSetChanged();
}
public List<String> getAuthorUrls() { public List<String> getAuthorUrls() {
List<String> urls = new ArrayList<>(); List<String> urls = new ArrayList<>();
@@ -158,8 +181,8 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
@Override @Override
public void onBindViewHolder(NotificationListAdapter.ViewHolder vh, int position) { public void onBindViewHolder(NotificationListAdapter.ViewHolder vh, int position) {
LbryNotification notification = items.get(position); LbryNotification notification = items.get(position);
vh.layoutView.setBackgroundColor(ContextCompat.getColor(context, notification.isSeen() ? android.R.color.transparent : R.color.nextLbryGreenSemiTransparent));
vh.layoutView.setBackgroundColor(ContextCompat.getColor(context, notification.isSeen() ? R.color.white : R.color.nextLbryGreenSemiTransparent)); vh.selectedOverlayView.setVisibility(isNotificationSelected(notification) ? View.VISIBLE : View.GONE);
vh.titleView.setVisibility(!Helper.isNullOrEmpty(notification.getTitle()) ? View.VISIBLE : View.GONE); vh.titleView.setVisibility(!Helper.isNullOrEmpty(notification.getTitle()) ? View.VISIBLE : View.GONE);
vh.titleView.setText(notification.getTitle()); vh.titleView.setText(notification.getTitle());
@@ -170,7 +193,7 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE); vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE);
if (notification.getCommentAuthor() != null) { if (notification.getCommentAuthor() != null) {
Glide.with(context.getApplicationContext()).load( Glide.with(context.getApplicationContext()).load(
notification.getCommentAuthor().getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView); notification.getCommentAuthor().getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85)).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
} }
vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE); vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE);
@@ -180,11 +203,49 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
vh.itemView.setOnClickListener(new View.OnClickListener() { vh.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (clickListener != null) { if (inSelectionMode) {
clickListener.onNotificationClicked(notification); toggleSelectedNotification(notification);
} else {
if (clickListener != null) {
clickListener.onNotificationClicked(notification);
}
} }
} }
}); });
vh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
if (!inSelectionMode) {
inSelectionMode = true;
if (selectionModeListener != null) {
selectionModeListener.onEnterSelectionMode();
}
}
toggleSelectedNotification(notification);
return true;
}
});
}
private void toggleSelectedNotification(LbryNotification notification) {
if (selectedItems.contains(notification)) {
selectedItems.remove(notification);
} else {
selectedItems.add(notification);
}
if (selectionModeListener != null) {
selectionModeListener.onItemSelectionToggled();
}
if (selectedItems.size() == 0) {
inSelectionMode = false;
if (selectionModeListener != null) {
selectionModeListener.onExitSelectionMode();
}
}
notifyDataSetChanged();
} }
private long getLocalNotificationTime(LbryNotification notification) { private long getLocalNotificationTime(LbryNotification notification) {
@@ -32,7 +32,7 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
public static final int DISPLAY_MODE_ALL = 1; public static final int DISPLAY_MODE_ALL = 1;
public static final int DISPLAY_MODE_UNCLAIMED = 2; public static final int DISPLAY_MODE_UNCLAIMED = 2;
private Context context; private final Context context;
@Setter @Setter
private List<Reward> all; private List<Reward> all;
private List<Reward> items; private List<Reward> items;
@@ -85,16 +85,16 @@ public class RewardListAdapter extends RecyclerView.Adapter<RewardListAdapter.Vi
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected View iconClaimed; protected final View iconClaimed;
protected View loading; protected final View loading;
protected View upTo; protected final View upTo;
protected TextView textTitle; protected final TextView textTitle;
protected TextView textDescription; protected final TextView textDescription;
protected TextView textLbcValue; protected final TextView textLbcValue;
protected TextView textUsdValue; protected final TextView textUsdValue;
protected TextView textLinkTransaction; protected final TextView textLinkTransaction;
protected EditText inputCustomCode; protected final EditText inputCustomCode;
protected MaterialButton buttonClaimCustom; protected final MaterialButton buttonClaimCustom;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconClaimed = v.findViewById(R.id.reward_item_claimed_icon); iconClaimed = v.findViewById(R.id.reward_item_claimed_icon);
@@ -0,0 +1,70 @@
package io.lbry.browser.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import io.lbry.browser.R;
import io.lbry.browser.model.StartupStage;
public class StartupStageAdapter extends BaseAdapter {
private final List<StartupStage> list;
private final LayoutInflater inflater;
private final String[] stagesString;
public StartupStageAdapter(Context ctx, List<StartupStage> rows) {
this.list = rows;
this.inflater = LayoutInflater.from(ctx);
stagesString = new String[9];
stagesString[0] = ctx.getResources().getString(R.string.installation_id_loaded);
stagesString[1] = ctx.getResources().getString(R.string.known_tags_loaded);
stagesString[2] = ctx.getResources().getString(R.string.exchange_rate_loaded);
stagesString[3] = ctx.getResources().getString(R.string.user_authenticated);
stagesString[4] = ctx.getResources().getString(R.string.installation_registered);
stagesString[5] = ctx.getResources().getString(R.string.subscriptions_loaded);
stagesString[6] = ctx.getResources().getString(R.string.subscriptions_resolved);
stagesString[7] = ctx.getResources().getString(R.string.block_list_loaded);
stagesString[8] = ctx.getResources().getString(R.string.filter_list_loaded);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.list_item_startupstage, viewGroup, false);
ImageView iconView = view.findViewById(R.id.startup_stage_icon);
TextView textView = view.findViewById(R.id.startup_stage_text);
StartupStage item = (StartupStage) getItem(i);
iconView.setImageResource(item.stageDone ? R.drawable.ic_check : R.drawable.ic_close);
iconView.setColorFilter(item.stageDone ? Color.WHITE : Color.RED);
textView.setText(stagesString[item.stage - 1]);
}
return view;
}
}
@@ -22,9 +22,9 @@ import io.lbry.browser.utils.Helper;
import lombok.Setter; import lombok.Setter;
public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedChannelGridAdapter.ViewHolder> { public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedChannelGridAdapter.ViewHolder> {
private Context context; private final Context context;
private List<Claim> items; private final List<Claim> items;
private List<Claim> selectedItems; private final List<Claim> selectedItems;
@Setter @Setter
private ChannelItemSelectionListener listener; private ChannelItemSelectionListener listener;
@@ -35,11 +35,11 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected View noThumbnailView; protected final View noThumbnailView;
protected ImageView thumbnailView; protected final ImageView thumbnailView;
protected TextView alphaView; protected final TextView alphaView;
protected TextView titleView; protected final TextView titleView;
protected TextView tagView; protected final TextView tagView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
noThumbnailView = v.findViewById(R.id.suggested_channel_no_thumbnail); noThumbnailView = v.findViewById(R.id.suggested_channel_no_thumbnail);
@@ -89,7 +89,8 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
@Override @Override
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) { public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
Claim claim = items.get(position); Claim claim = items.get(position);
String thumbnailUrl = claim.getThumbnailUrl(); ViewGroup.LayoutParams lp = vh.thumbnailView.getLayoutParams();
String thumbnailUrl = claim.getThumbnailUrl(lp.width, lp.height, 85);
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId()); int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context); Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
@@ -23,12 +23,13 @@ public class TagListAdapter extends RecyclerView.Adapter<TagListAdapter.ViewHold
public static final int CUSTOMIZE_MODE_ADD = 1; public static final int CUSTOMIZE_MODE_ADD = 1;
public static final int CUSTOMIZE_MODE_REMOVE = 2; public static final int CUSTOMIZE_MODE_REMOVE = 2;
private Context context; private final Context context;
private List<Tag> items; private List<Tag> items;
@Setter @Setter
private TagClickListener clickListener; private TagClickListener clickListener;
@Getter
@Setter @Setter
@Getter
private int customizeMode; private int customizeMode;
public TagListAdapter(List<Tag> tags, Context context) { public TagListAdapter(List<Tag> tags, Context context) {
@@ -38,8 +39,8 @@ public class TagListAdapter extends RecyclerView.Adapter<TagListAdapter.ViewHold
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected ImageView iconView; protected final ImageView iconView;
protected TextView nameView; protected final TextView nameView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconView = v.findViewById(R.id.tag_action); iconView = v.findViewById(R.id.tag_action);
@@ -26,8 +26,8 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionList
private static final DecimalFormat TX_LIST_AMOUNT_FORMAT = new DecimalFormat("#,##0.0000"); private static final DecimalFormat TX_LIST_AMOUNT_FORMAT = new DecimalFormat("#,##0.0000");
private static final SimpleDateFormat TX_LIST_DATE_FORMAT = new SimpleDateFormat("MMM d"); private static final SimpleDateFormat TX_LIST_DATE_FORMAT = new SimpleDateFormat("MMM d");
private Context context; private final Context context;
private List<Transaction> items; private final List<Transaction> items;
@Setter @Setter
private TransactionClickListener listener; private TransactionClickListener listener;
@@ -107,14 +107,14 @@ public class TransactionListAdapter extends RecyclerView.Adapter<TransactionList
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected TextView descView; protected final TextView descView;
protected TextView amountView; protected final TextView amountView;
protected TextView claimView; protected final TextView claimView;
protected TextView feeView; protected final TextView feeView;
protected TextView txidLinkView; protected final TextView txidLinkView;
protected TextView dateView; protected final TextView dateView;
protected TextView pendingView; protected final TextView pendingView;
protected View infoFeeContainer; protected final View infoFeeContainer;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
@@ -21,8 +21,8 @@ import io.lbry.browser.utils.LbryUri;
import lombok.Setter; import lombok.Setter;
public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestionListAdapter.ViewHolder> { public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestionListAdapter.ViewHolder> {
private Context context; private final Context context;
private List<UrlSuggestion> items; private final List<UrlSuggestion> items;
@Setter @Setter
private UrlSuggestionClickListener listener; private UrlSuggestionClickListener listener;
@@ -130,9 +130,9 @@ public class UrlSuggestionListAdapter extends RecyclerView.Adapter<UrlSuggestion
} }
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
protected SolidIconView iconView; protected final SolidIconView iconView;
protected TextView titleView; protected final TextView titleView;
protected TextView descView; protected final TextView descView;
public ViewHolder(View v) { public ViewHolder(View v) {
super(v); super(v);
iconView = v.findViewById(R.id.url_suggestion_icon); iconView = v.findViewById(R.id.url_suggestion_icon);
@@ -25,7 +25,7 @@ public class VerificationPagerAdapter extends FragmentStateAdapter {
public static final int PAGE_VERIFICATION_WALLET = 2; public static final int PAGE_VERIFICATION_WALLET = 2;
public static final int PAGE_VERIFICATION_MANUAL = 3; public static final int PAGE_VERIFICATION_MANUAL = 3;
private FragmentActivity activity; private final FragmentActivity activity;
public VerificationPagerAdapter(FragmentActivity activity) { public VerificationPagerAdapter(FragmentActivity activity) {
super(activity); super(activity);
@@ -0,0 +1,100 @@
package io.lbry.browser.adapter;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import java.util.List;
import io.lbry.browser.MainActivity;
import io.lbry.browser.R;
import io.lbry.browser.model.WalletDetailItem;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.views.CreditsBalanceView;
public class WalletDetailAdapter extends BaseAdapter {
private final List<WalletDetailItem> list;
private final LayoutInflater inflater;
public WalletDetailAdapter(Context ctx, List<WalletDetailItem> rows) {
this.list = rows;
this.inflater = LayoutInflater.from(ctx);
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int i) {
return list.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
if (view == null) {
view = inflater.inflate(R.layout.list_item_boosting_balance, viewGroup, false);
CreditsBalanceView balanceView = view.findViewById(R.id.wallet_supporting_balance);
TextView detailTextView = view.findViewById(R.id.detail);
TextView detailExplanationTextView = view.findViewById(R.id.detail_explanation);
WalletDetailItem item = (WalletDetailItem) getItem(i);
detailTextView.setText(item.detail);
detailExplanationTextView.setText(item.detailDesc);
Helper.setViewText(balanceView, item.detailAmount);
ProgressBar progressUnlockTips = view.findViewById(R.id.wallet_unlock_tips_progress);
progressUnlockTips.setVisibility(item.isInProgress ? View.VISIBLE : View.GONE);
ImageButton buttonLock = view.findViewById(R.id.lock_button);
buttonLock.setVisibility((item.isUnlockable && !item.isInProgress) ? View.VISIBLE : View.GONE);
if (item.isUnlockable) {
buttonLock.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getContext() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()).
setTitle(R.string.unlock_tips).
setMessage(R.string.confirm_unlock_tips)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
unlockTips(view);
}
}).setNegativeButton(R.string.no, null);
builder.show();
}
}
});
}
}
return view;
}
private void unlockTips(View v) {
Context ctx = v.getContext();
if (ctx instanceof MainActivity) {
v.setVisibility(View.GONE);
View progress = v.getRootView().findViewById(R.id.wallet_unlock_tips_progress);
progress.setVisibility(View.VISIBLE);
((MainActivity) ctx).unlockTips();
}
}
}
@@ -21,13 +21,13 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
public class DatabaseHelper extends SQLiteOpenHelper { public class DatabaseHelper extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 6; public static final int DATABASE_VERSION = 8;
public static final String DATABASE_NAME = "LbryApp.db"; public static final String DATABASE_NAME = "LbryApp.db";
private static DatabaseHelper instance; private static DatabaseHelper instance;
private static final String[] SQL_CREATE_TABLES = { private static final String[] SQL_CREATE_TABLES = {
// local subscription store // local subscription store
"CREATE TABLE subscriptions (url TEXT PRIMARY KEY NOT NULL, channel_name TEXT NOT NULL)", "CREATE TABLE subscriptions (url TEXT PRIMARY KEY NOT NULL, channel_name TEXT NOT NULL, is_notifications_disabled INTEGER DEFAULT 0 NOT NULL)",
// url entry / suggestion history // url entry / suggestion history
"CREATE TABLE url_history (id INTEGER PRIMARY KEY NOT NULL, value TEXT NOT NULL, url TEXT, type INTEGER NOT NULL, timestamp TEXT NOT NULL)", "CREATE TABLE url_history (id INTEGER PRIMARY KEY NOT NULL, value TEXT NOT NULL, url TEXT, type INTEGER NOT NULL, timestamp TEXT NOT NULL)",
// tags (known and followed) // tags (known and followed)
@@ -60,6 +60,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
", is_read INTEGER DEFAULT 0 NOT NULL" + ", is_read INTEGER DEFAULT 0 NOT NULL" +
", is_seen INTEGER DEFAULT 0 NOT NULL " + ", is_seen INTEGER DEFAULT 0 NOT NULL " +
", timestamp TEXT NOT NULL)", ", timestamp TEXT NOT NULL)",
"CREATE TABLE shuffle_watched (id INTEGER PRIMARY KEY NOT NULL, claim_id TEXT NOT NULL)"
}; };
private static final String[] SQL_CREATE_INDEXES = { private static final String[] SQL_CREATE_INDEXES = {
"CREATE UNIQUE INDEX idx_subscription_url ON subscriptions (url)", "CREATE UNIQUE INDEX idx_subscription_url ON subscriptions (url)",
@@ -69,7 +70,8 @@ public class DatabaseHelper extends SQLiteOpenHelper {
"CREATE UNIQUE INDEX idx_view_history_url_device ON view_history (url, device)", "CREATE UNIQUE INDEX idx_view_history_url_device ON view_history (url, device)",
"CREATE INDEX idx_view_history_device ON view_history (device)", "CREATE INDEX idx_view_history_device ON view_history (device)",
"CREATE UNIQUE INDEX idx_notification_remote_id ON notifications (remote_id)", "CREATE UNIQUE INDEX idx_notification_remote_id ON notifications (remote_id)",
"CREATE INDEX idx_notification_timestamp ON notifications (timestamp)" "CREATE INDEX idx_notification_timestamp ON notifications (timestamp)",
"CREATE UNIQUE INDEX idx_shuffle_watched_claim ON shuffle_watched (claim_id)",
}; };
private static final String[] SQL_V1_V2_UPGRADE = { private static final String[] SQL_V1_V2_UPGRADE = {
@@ -99,11 +101,19 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String[] SQL_V5_V6_UPGRADE = { private static final String[] SQL_V5_V6_UPGRADE = {
"ALTER TABLE notifications ADD COLUMN author_url TEXT" "ALTER TABLE notifications ADD COLUMN author_url TEXT"
}; };
private static final String[] SQL_V6_V7_UPGRADE = {
"CREATE TABLE shuffle_watched (id INTEGER PRIMARY KEY NOT NULL, claim_id TEXT NOT NULL)",
"CREATE UNIQUE INDEX idx_shuffle_watched_claim ON shuffle_watched (claim_id)"
};
private static final String[] SQL_V7_V8_UPGRADE = {
"AlTER TABLE subscriptions ADD COLUMN is_notifications_disabled INTEGER DEFAULT 0 NOT NULL"
};
private static final String SQL_INSERT_SUBSCRIPTION = "REPLACE INTO subscriptions (channel_name, url) VALUES (?, ?)"; private static final String SQL_INSERT_SUBSCRIPTION = "REPLACE INTO subscriptions (channel_name, url, is_notifications_disabled) VALUES (?, ?, ?)";
private static final String SQL_UPDATE_SUBSCRIPTION_NOTIFICATION = "UPDATE subscriptions SET is_notification_disabled = ? WHERE url = ?";
private static final String SQL_CLEAR_SUBSCRIPTIONS = "DELETE FROM subscriptions"; private static final String SQL_CLEAR_SUBSCRIPTIONS = "DELETE FROM subscriptions";
private static final String SQL_DELETE_SUBSCRIPTION = "DELETE FROM subscriptions WHERE url = ?"; private static final String SQL_DELETE_SUBSCRIPTION = "DELETE FROM subscriptions WHERE url = ?";
private static final String SQL_GET_SUBSCRIPTIONS = "SELECT channel_name, url FROM subscriptions"; private static final String SQL_GET_SUBSCRIPTIONS = "SELECT channel_name, url, is_notifications_disabled FROM subscriptions";
private static final String SQL_INSERT_URL_HISTORY = "REPLACE INTO url_history (value, url, type, timestamp) VALUES (?, ?, ?, ?)"; private static final String SQL_INSERT_URL_HISTORY = "REPLACE INTO url_history (value, url, type, timestamp) VALUES (?, ?, ?, ?)";
private static final String SQL_CLEAR_URL_HISTORY = "DELETE FROM url_history"; private static final String SQL_CLEAR_URL_HISTORY = "DELETE FROM url_history";
@@ -113,9 +123,14 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String SQL_INSERT_NOTIFICATION = "REPLACE INTO notifications (remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String SQL_INSERT_NOTIFICATION = "REPLACE INTO notifications (remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
private static final String SQL_GET_NOTIFICATIONS = "SELECT id, remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp FROM notifications ORDER BY timestamp DESC LIMIT 500"; private static final String SQL_GET_NOTIFICATIONS = "SELECT id, remote_id, author_url, title, description, rule, target_url, is_read, is_seen, timestamp FROM notifications ORDER BY timestamp DESC LIMIT 500";
private static final String SQL_GET_UNREAD_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_read <> 1"; private static final String SQL_GET_UNREAD_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_read <> 1";
private static final String SQL_GET_UNSEEN_NOTIFICATIONS_COUNT = "SELECT COUNT(id) FROM notifications WHERE is_seen <> 1";
private static final String SQL_MARK_NOTIFICATIONS_READ = "UPDATE notifications SET is_read = 1 WHERE is_read = 0"; private static final String SQL_MARK_NOTIFICATIONS_READ = "UPDATE notifications SET is_read = 1 WHERE is_read = 0";
private static final String SQL_MARK_NOTIFICATIONS_SEEN = "UPDATE notifications SET is_seen = 1 WHERE is_seen = 0";
private static final String SQL_MARK_NOTIFICATION_READ_AND_SEEN = "UPDATE notifications SET is_read = 1, is_seen = 1 WHERE id = ?"; private static final String SQL_MARK_NOTIFICATION_READ_AND_SEEN = "UPDATE notifications SET is_read = 1, is_seen = 1 WHERE id = ?";
private static final String SQL_INSERT_SHUFFLE_WATCHED = "REPLACE INTO shuffle_watched (claim_id) VALUES (?)";
private static final String SQL_GET_SHUFFLE_WATCHED_CLAIMS = "SELECT claim_id FROM shuffle_watched";
private static final String SQL_INSERT_VIEW_HISTORY = private static final String SQL_INSERT_VIEW_HISTORY =
"REPLACE INTO view_history (url, claim_id, claim_name, cost, currency, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; "REPLACE INTO view_history (url, claim_id, claim_name, cost, currency, title, publisher_claim_id, publisher_name, publisher_title, thumbnail_url, device, release_time, timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
private static final String SQL_GET_VIEW_HISTORY = private static final String SQL_GET_VIEW_HISTORY =
@@ -174,6 +189,16 @@ public class DatabaseHelper extends SQLiteOpenHelper {
db.execSQL(sql); db.execSQL(sql);
} }
} }
if (oldVersion < 7) {
for (String sql : SQL_V6_V7_UPGRADE) {
db.execSQL(sql);
}
}
if (oldVersion < 8) {
for (String sql : SQL_V7_V8_UPGRADE) {
db.execSQL(sql);
}
}
} }
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
@@ -190,6 +215,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
public static void clearUrlHistoryBefore(Date date, SQLiteDatabase db) { public static void clearUrlHistoryBefore(Date date, SQLiteDatabase db) {
db.execSQL(SQL_CLEAR_URL_HISTORY_BEFORE_TIME, new Object[] { new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(new Date()) }); db.execSQL(SQL_CLEAR_URL_HISTORY_BEFORE_TIME, new Object[] { new SimpleDateFormat(Helper.ISO_DATE_FORMAT_PATTERN).format(new Date()) });
} }
// History items are essentially url suggestions // History items are essentially url suggestions
public static List<UrlSuggestion> getRecentHistory(SQLiteDatabase db) { public static List<UrlSuggestion> getRecentHistory(SQLiteDatabase db) {
List<UrlSuggestion> suggestions = new ArrayList<>(); List<UrlSuggestion> suggestions = new ArrayList<>();
@@ -289,7 +315,14 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} }
public static void createOrUpdateSubscription(Subscription subscription, SQLiteDatabase db) { public static void createOrUpdateSubscription(Subscription subscription, SQLiteDatabase db) {
db.execSQL(SQL_INSERT_SUBSCRIPTION, new Object[] { subscription.getChannelName(), subscription.getUrl() }); db.execSQL(SQL_INSERT_SUBSCRIPTION, new Object[] {
subscription.getChannelName(),
subscription.getUrl(),
subscription.isNotificationsDisabled() ? 1 : 0
});
}
public static void setSubscriptionNotificationDisabled(boolean flag, String url, SQLiteDatabase db) {
db.execSQL(SQL_UPDATE_SUBSCRIPTION_NOTIFICATION, new Object[] { flag ? 1 : 0, url });
} }
public static void deleteSubscription(Subscription subscription, SQLiteDatabase db) { public static void deleteSubscription(Subscription subscription, SQLiteDatabase db) {
db.execSQL(SQL_DELETE_SUBSCRIPTION, new Object[] { subscription.getUrl() }); db.execSQL(SQL_DELETE_SUBSCRIPTION, new Object[] { subscription.getUrl() });
@@ -306,6 +339,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
Subscription subscription = new Subscription(); Subscription subscription = new Subscription();
subscription.setChannelName(cursor.getString(0)); subscription.setChannelName(cursor.getString(0));
subscription.setUrl(cursor.getString(1)); subscription.setUrl(cursor.getString(1));
subscription.setNotificationsDisabled(cursor.getInt(2) == 1);
subscriptions.add(subscription); subscriptions.add(subscription);
} }
} finally { } finally {
@@ -357,6 +391,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} }
return notifications; return notifications;
} }
public static void deleteNotifications(List<LbryNotification> notifications, SQLiteDatabase db) {
StringBuilder sb = new StringBuilder("DELETE FROM notifications WHERE remote_id IN (");
List<Object> remoteIds = new ArrayList<>();
String delim = "";
for (int i = 0; i < notifications.size(); i++) {
remoteIds.add(String.valueOf(notifications.get(i).getRemoteId()));
sb.append(delim).append("?");
delim = ",";
}
sb.append(")");
String sql = sb.toString();
db.execSQL(sql, remoteIds.toArray());
}
public static int getUnreadNotificationsCount(SQLiteDatabase db) { public static int getUnreadNotificationsCount(SQLiteDatabase db) {
int count = 0; int count = 0;
Cursor cursor = null; Cursor cursor = null;
@@ -370,10 +418,42 @@ public class DatabaseHelper extends SQLiteOpenHelper {
} }
return count; return count;
} }
public static int getUnseenNotificationsCount(SQLiteDatabase db) {
int count = 0;
Cursor cursor = null;
try {
cursor = db.rawQuery(SQL_GET_UNSEEN_NOTIFICATIONS_COUNT, null);
if (cursor.moveToNext()) {
count = cursor.getInt(0);
}
} finally {
Helper.closeCursor(cursor);
}
return count;
}
public static void markNotificationsSeen(SQLiteDatabase db) {
db.execSQL(SQL_MARK_NOTIFICATIONS_SEEN);
}
public static void markNotificationsRead(SQLiteDatabase db) { public static void markNotificationsRead(SQLiteDatabase db) {
db.execSQL(SQL_MARK_NOTIFICATIONS_READ); db.execSQL(SQL_MARK_NOTIFICATIONS_READ);
} }
public static void markNotificationReadAndSeen(long notificationId, SQLiteDatabase db) { public static void markNotificationReadAndSeen(long notificationId, SQLiteDatabase db) {
db.execSQL(SQL_MARK_NOTIFICATION_READ_AND_SEEN, new Object[] { notificationId }); db.execSQL(SQL_MARK_NOTIFICATION_READ_AND_SEEN, new Object[] { notificationId });
} }
public static void createOrUpdateShuffleWatched(String claimId, SQLiteDatabase db) {
db.execSQL(SQL_INSERT_SHUFFLE_WATCHED, new Object[] { claimId });
}
public static List<String> getShuffleWatchedClaims(SQLiteDatabase db) {
List<String> claimIds = new ArrayList<>();
Cursor cursor = null;
try {
cursor = db.rawQuery(SQL_GET_SHUFFLE_WATCHED_CLAIMS, null);
while (cursor.moveToNext()) {
claimIds.add(cursor.getString(0));
}
} finally {
Helper.closeCursor(cursor);
}
return claimIds;
}
} }
@@ -67,8 +67,8 @@ public class ContentFromDialogFragment extends BottomSheetDialogFragment {
R.id.content_from_past_year_item, R.id.content_from_past_year_item,
R.id.content_from_all_time_item R.id.content_from_all_time_item
}; };
private BottomSheetDialogFragment dialog; private final BottomSheetDialogFragment dialog;
private ContentFromListener listener; private final ContentFromListener listener;
public ContentFromItemClickListener(BottomSheetDialogFragment dialog, ContentFromListener listener) { public ContentFromItemClickListener(BottomSheetDialogFragment dialog, ContentFromListener listener) {
this.dialog = dialog; this.dialog = dialog;
@@ -54,8 +54,8 @@ public class ContentScopeDialogFragment extends BottomSheetDialogFragment {
private final int[] checkViewIds = { private final int[] checkViewIds = {
R.id.content_scope_everyone_item_selected, R.id.content_scope_tags_item_selected R.id.content_scope_everyone_item_selected, R.id.content_scope_tags_item_selected
}; };
private BottomSheetDialogFragment dialog; private final BottomSheetDialogFragment dialog;
private ContentScopeListener listener; private final ContentScopeListener listener;
public ContentScopeItemClickListener(BottomSheetDialogFragment dialog, ContentScopeListener listener) { public ContentScopeItemClickListener(BottomSheetDialogFragment dialog, ContentScopeListener listener) {
this.dialog = dialog; this.dialog = dialog;
@@ -57,8 +57,8 @@ public class ContentSortDialogFragment extends BottomSheetDialogFragment {
private final int[] checkViewIds = { private final int[] checkViewIds = {
R.id.sort_by_trending_item_selected, R.id.sort_by_new_item_selected, R.id.sort_by_top_item_selected R.id.sort_by_trending_item_selected, R.id.sort_by_new_item_selected, R.id.sort_by_top_item_selected
}; };
private BottomSheetDialogFragment dialog; private final BottomSheetDialogFragment dialog;
private SortByListener listener; private final SortByListener listener;
public SortByItemClickListener(BottomSheetDialogFragment dialog, SortByListener listener) { public SortByItemClickListener(BottomSheetDialogFragment dialog, SortByListener listener) {
this.dialog = dialog; this.dialog = dialog;
@@ -13,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.widget.AppCompatSpinner; import androidx.appcompat.widget.AppCompatSpinner;
@@ -41,7 +40,6 @@ import io.lbry.browser.tasks.claim.ClaimListTask;
import io.lbry.browser.tasks.wallet.SupportCreateTask; import io.lbry.browser.tasks.wallet.SupportCreateTask;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
import lombok.Setter;
public class CreateSupportDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener { public class CreateSupportDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
public static final String TAG = "CreateSupportDialog"; public static final String TAG = "CreateSupportDialog";
@@ -61,13 +59,17 @@ public class CreateSupportDialogFragment extends BottomSheetDialogFragment imple
private ProgressBar progressLoadingChannels; private ProgressBar progressLoadingChannels;
@Setter private final CreateSupportListener listener;
private CreateSupportListener listener; private final Claim claim;
@Setter
private Claim claim;
public static CreateSupportDialogFragment newInstance() { private CreateSupportDialogFragment(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(); super();
this.claim = claim;
this.listener = listener;
}
public static CreateSupportDialogFragment newInstance(Claim claim, CreateSupportListener listener) {
return new CreateSupportDialogFragment(claim, listener);
} }
private void disableControls() { private void disableControls() {
@@ -225,9 +227,10 @@ public class CreateSupportDialogFragment extends BottomSheetDialogFragment imple
if (!isTip) { if (!isTip) {
sendButton.setText(R.string.send_revocable_support); sendButton.setText(R.string.send_revocable_support);
} else { } else {
String amountString = Helper.getValue(inputAmount.getText()); String amountString = Helper.getValue(inputAmount.getText(), "0");
double parsedAmount = Helper.parseDouble(amountString, 0); double parsedAmount = Helper.parseDouble(amountString, 0);
sendButton.setText(parsedAmount == 0 ? getString(R.string.send_a_tip) : getString(R.string.send_lbc_tip, amountString)); String text = getResources().getQuantityString(R.plurals.send_lbc_tip, parsedAmount == 1.0 ? 1 : 2, amountString);
sendButton.setText(text);
} }
} }
@@ -142,7 +142,7 @@ public class CustomizeTagsDialogFragment extends BottomSheetDialogFragment {
return view; return view;
} }
private TagListAdapter.TagClickListener customizeTagClickListener = new TagListAdapter.TagClickListener() { private final TagListAdapter.TagClickListener customizeTagClickListener = new TagListAdapter.TagClickListener() {
@Override @Override
public void onTagClicked(Tag tag, int customizeMode) { public void onTagClicked(Tag tag, int customizeMode) {
if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_ADD) { if (customizeMode == TagListAdapter.CUSTOMIZE_MODE_ADD) {
@@ -5,7 +5,6 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
@@ -37,7 +37,6 @@ import io.lbry.browser.tasks.claim.StreamRepostTask;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import lombok.Setter;
public class RepostClaimDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener { public class RepostClaimDialogFragment extends BottomSheetDialogFragment implements WalletBalanceListener {
public static final String TAG = "RepostClaimDialog"; public static final String TAG = "RepostClaimDialog";
@@ -57,13 +56,17 @@ public class RepostClaimDialogFragment extends BottomSheetDialogFragment impleme
private TextView linkToggleAdvanced; private TextView linkToggleAdvanced;
private View advancedContainer; private View advancedContainer;
@Setter private final RepostClaimListener listener;
private RepostClaimListener listener; private final Claim claim;
@Setter
private Claim claim;
public static RepostClaimDialogFragment newInstance() { private RepostClaimDialogFragment(Claim claim, RepostClaimListener listener) {
return new RepostClaimDialogFragment(); super();
this.listener = listener;
this.claim = claim;
}
public static RepostClaimDialogFragment newInstance(Claim claim, RepostClaimListener listener) {
return new RepostClaimDialogFragment(claim, listener);
} }
@Override @Override
@@ -1,5 +1,7 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import androidx.annotation.Nullable;
import com.google.gson.FieldNamingPolicy; import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
@@ -15,7 +17,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
@@ -138,6 +139,14 @@ public class Claim {
return null; return null;
} }
public boolean hasSource() {
if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value;
return metadata.getSource() != null;
}
return false;
}
public boolean isPlayable() { public boolean isPlayable() {
if (value instanceof StreamMetadata) { if (value instanceof StreamMetadata) {
StreamMetadata metadata = (StreamMetadata) value; StreamMetadata metadata = (StreamMetadata) value;
@@ -177,6 +186,21 @@ public class Claim {
return null; return null;
} }
/**
* Gets the URL from the CDN where getting the image file
* @param width Pass zero for width and height for the full size image file
* @param height Pass zero for width and height for the full size image file
* @param q Desired quality for the image to be retrieved
* @return URL from the CDN from where image can be retrieved
*/
public String getThumbnailUrl(int width, int height, int q) {
if (value != null && value.getThumbnail() != null) {
ImageCDNUrl imageCDNUrl = new ImageCDNUrl(Math.max(width, 0), Math.max(height, 0), q, null, value.getThumbnail().getUrl());
return imageCDNUrl.toString();
}
return null;
}
public String getCoverUrl() { public String getCoverUrl() {
if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) { if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) {
return ((ChannelMetadata) value).getCover().getUrl(); return ((ChannelMetadata) value).getCover().getUrl();
@@ -484,6 +508,30 @@ public class Claim {
private String url; private String url;
} }
/**
* Object to be instantiated. In order to get the URLto the CDN, call toString() on it
*/
static class ImageCDNUrl {
private String appendedPath = "";
public ImageCDNUrl(int width, int height, int quality, @Nullable String format, String thumbnailUrl) {
if (width != 0 && height != 0)
appendedPath = "s:".concat(String.valueOf(width)).concat(":").concat(String.valueOf(height)).concat("/");
appendedPath = appendedPath.concat("quality:").concat(String.valueOf(quality)).concat("/");
appendedPath = appendedPath.concat("plain/").concat(thumbnailUrl);
if (format != null)
appendedPath = appendedPath.concat("@").concat(format);
}
@Override
public String toString() {
String url = "https://image-processor.vanwanet.com/optimize/";
return url.concat(appendedPath);
}
}
@Data @Data
public static class StreamInfo { public static class StreamInfo {
private long duration; // video / audio private long duration; // video / audio
@@ -40,7 +40,7 @@ public class ClaimCacheKey {
@Override @Override
public boolean equals(@Nullable Object obj) { public boolean equals(@Nullable Object obj) {
if (obj == null || !(obj instanceof ClaimCacheKey)) { if (!(obj instanceof ClaimCacheKey)) {
return false; return false;
} }
ClaimCacheKey key = (ClaimCacheKey) obj; ClaimCacheKey key = (ClaimCacheKey) obj;
@@ -1,19 +1,15 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
public class ClaimSearchCacheValue { public class ClaimSearchCacheValue {
@Getter @Getter
@Setter private final List<Claim> claims;
private List<Claim> claims;
@Getter @Getter
@Setter private final long timestamp;
private long timestamp;
public ClaimSearchCacheValue(List<Claim> claims, long timestamp) { public ClaimSearchCacheValue(List<Claim> claims, long timestamp) {
this.claims = new ArrayList<>(claims); this.claims = new ArrayList<>(claims);
@@ -3,7 +3,6 @@ package io.lbry.browser.model;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -11,8 +10,7 @@ import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;
@Data @Data
public class Comment { public class Comment implements Comparable<Comment> {
public static final double LBC_COST = 1;
public static final int MAX_LENGTH = 2000; public static final int MAX_LENGTH = 2000;
private Claim poster; private Claim poster;
@@ -66,4 +64,9 @@ public class Comment {
return null; return null;
} }
} }
@Override
public int compareTo(Comment comment) {
return (int)(this.getTimestamp() - comment.getTimestamp());
}
} }
@@ -4,9 +4,9 @@ import lombok.Data;
@Data @Data
public class Language { public class Language {
private String code; private final String code;
private String name; private final String name;
private int stringResourceId; private final int stringResourceId;
public Language(String code, String name, int stringResourceId) { public Language(String code, String name, int stringResourceId) {
this.code = code; this.code = code;
@@ -4,9 +4,9 @@ import lombok.Data;
@Data @Data
public class License { public class License {
private String name; private final String name;
private String url; private String url;
private int stringResourceId; private final int stringResourceId;
public License(String name, int stringResourceId) { public License(String name, int stringResourceId) {
this.name = name; this.name = name;
@@ -2,8 +2,6 @@ package io.lbry.browser.model;
import android.content.Context; import android.content.Context;
import androidx.core.content.res.ResourcesCompat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -20,6 +18,7 @@ public class NavMenuItem {
public static final int ID_ITEM_FOLLOWING = 101; public static final int ID_ITEM_FOLLOWING = 101;
public static final int ID_ITEM_EDITORS_CHOICE = 102; public static final int ID_ITEM_EDITORS_CHOICE = 102;
public static final int ID_ITEM_ALL_CONTENT = 103; public static final int ID_ITEM_ALL_CONTENT = 103;
public static final int ID_ITEM_SHUFFLE = 104;
// Your Content // Your Content
public static final int ID_ITEM_CHANNELS = 201; public static final int ID_ITEM_CHANNELS = 201;
@@ -36,8 +35,8 @@ public class NavMenuItem {
public static final int ID_ITEM_SETTINGS = 401; public static final int ID_ITEM_SETTINGS = 401;
public static final int ID_ITEM_ABOUT = 402; public static final int ID_ITEM_ABOUT = 402;
private Context context; private final Context context;
private int id; private final int id;
private boolean group; private boolean group;
private int icon; private int icon;
private String title; private String title;
@@ -0,0 +1,11 @@
package io.lbry.browser.model;
public class StartupStage {
public final Integer stage;
public final Boolean stageDone;
public StartupStage(Integer stage, Boolean stageDone) {
this.stage = stage;
this.stageDone = stageDone;
}
}
@@ -3,9 +3,7 @@ package io.lbry.browser.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio;
import lombok.Data; import lombok.Data;
@Data @Data
@@ -6,14 +6,28 @@ import java.math.BigDecimal;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data @Data
public class WalletBalance { public class WalletBalance {
@Setter
@Getter
private BigDecimal available; private BigDecimal available;
@Setter
@Getter
private BigDecimal reserved; private BigDecimal reserved;
@Setter
@Getter
private BigDecimal claims; private BigDecimal claims;
@Setter
@Getter
private BigDecimal supports; private BigDecimal supports;
@Setter
@Getter
private BigDecimal tips; private BigDecimal tips;
@Setter
@Getter
private BigDecimal total; private BigDecimal total;
public WalletBalance() { public WalletBalance() {
@@ -0,0 +1,17 @@
package io.lbry.browser.model;
public class WalletDetailItem {
public String detail;
public String detailDesc;
public String detailAmount;
public boolean isUnlockable;
public boolean isInProgress;
public WalletDetailItem(String detail, String detailDesc, String detailAmount, boolean isUnlockable, boolean isInProgress) {
this.detail = detail;
this.detailDesc = detailDesc;
this.detailAmount = detailAmount;
this.isUnlockable = isUnlockable;
this.isInProgress = isInProgress;
}
}
@@ -1,11 +1,15 @@
package io.lbry.browser.model; package io.lbry.browser.model;
import lombok.Data; import lombok.Data;
import lombok.Getter;
@Data @Data
public class WalletSync { public class WalletSync {
private String hash; @Getter
private String data; private final String hash;
@Getter
private final String data;
@Getter
private boolean changed; private boolean changed;
public WalletSync(String hash, String data) { public WalletSync(String hash, String data) {
@@ -17,4 +21,5 @@ public class WalletSync {
this(hash, data); this(hash, data);
this.changed = changed; this.changed = changed;
} }
} }
@@ -9,7 +9,6 @@ import org.json.JSONObject;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import io.lbry.browser.model.Claim;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import lombok.Data; import lombok.Data;
@@ -11,17 +11,21 @@ public class Subscription {
@Getter @Getter
@Setter @Setter
private String url; private String url;
@Getter
@Setter
private boolean isNotificationsDisabled;
public Subscription() { public Subscription() {
} }
public Subscription(String channelName, String url) { public Subscription(String channelName, String url, boolean isNotificationsDisabled) {
this.channelName = channelName; this.channelName = channelName;
this.url = url; this.url = url;
this.isNotificationsDisabled = isNotificationsDisabled;
} }
public static Subscription fromClaim(Claim claim) { public static Subscription fromClaim(Claim claim) {
return new Subscription(claim.getName(), claim.getPermanentUrl()); return new Subscription(claim.getName(), claim.getPermanentUrl(), false);
} }
public String toString() { public String toString() {
return url; return url;
@@ -12,16 +12,17 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody;
public class BufferEventTask extends AsyncTask<Void, Void, Void> { public class BufferEventTask extends AsyncTask<Void, Void, Void> {
private static final String TAG = "LbryBufferEvent"; private static final String TAG = "LbryBufferEvent";
private static final String ENDPOINT = "https://collector-service.api.lbry.tv/api/v1/events/video"; private static final String ENDPOINT = "https://collector-service.api.lbry.tv/api/v1/events/video";
private String streamUrl; private final String streamUrl;
private String userIdHash; private final String userIdHash;
private long streamDuration; private final long streamDuration;
private long streamPosition; private final long streamPosition;
private long bufferDuration; private final long bufferDuration;
public BufferEventTask(String streamUrl, long streamDuration, long streamPosition, long bufferDuration, String userIdHash) { public BufferEventTask(String streamUrl, long streamDuration, long streamPosition, long bufferDuration, String userIdHash) {
this.streamUrl = streamUrl; this.streamUrl = streamUrl;
@@ -53,7 +54,11 @@ public class BufferEventTask extends AsyncTask<Void, Void, Void> {
build(); build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
String responseString = response.body().string(); ResponseBody resBody = response.body();
String responseString = "";
if (resBody != null) {
responseString = response.body().string();
}
Log.d(TAG, String.format("buffer event sent: %s", responseString)); Log.d(TAG, String.format("buffer event sent: %s", responseString));
} catch (Exception ex) { } catch (Exception ex) {
// we don't want to fail if a buffer event fails to register // we don't want to fail if a buffer event fails to register
@@ -0,0 +1,85 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import android.view.View;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Objects;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Comments;
import io.lbry.browser.utils.Helper;
import okhttp3.Response;
public class CommentCreateTask extends AsyncTask<Void, Void, Comment> {
private final Comment comment;
private final View progressView;
private final CommentCreateWithTipHandler handler;
private Exception error;
public CommentCreateTask(Comment comment, View progressView, CommentCreateWithTipHandler handler) {
this.comment = comment;
this.progressView = progressView;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressView, View.VISIBLE);
}
public Comment doInBackground(Void... params) {
Comment createdComment = null;
try {
// check comments status endpoint
Comments.checkCommentsEndpointStatus();
JSONObject comment_body = new JSONObject();
comment_body.put("comment", comment.getText());
comment_body.put("claim_id", comment.getClaimId());
if (!Helper.isNullOrEmpty(comment.getParentId())) {
comment_body.put("parent_id", comment.getParentId());
}
comment_body.put("channel_id", comment.getChannelId());
comment_body.put("channel_name", comment.getChannelName());
JSONObject jsonChannelSign = Comments.channelSign(comment_body, comment.getChannelId(), comment.getChannelName());
if (jsonChannelSign.has("signature") && jsonChannelSign.has("signing_ts")) {
comment_body.put("signature", jsonChannelSign.getString("signature"));
comment_body.put("signing_ts", jsonChannelSign.getString("signing_ts"));
}
Response resp = Comments.performRequest(comment_body, "comment.Create");
String responseString = Objects.requireNonNull(resp.body()).string();
resp.close();
JSONObject jsonResponse = new JSONObject(responseString);
if (jsonResponse.has("result"))
createdComment = Comment.fromJSONObject(jsonResponse.getJSONObject("result"));
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
error = ex;
}
return createdComment;
}
protected void onPostExecute(Comment createdComment) {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
if (createdComment != null) {
handler.onSuccess(createdComment);
} else {
handler.onError(error);
}
}
}
public interface CommentCreateWithTipHandler {
void onSuccess(Comment createdComment);
void onError(Exception error);
}
}
@@ -1,103 +0,0 @@
package io.lbry.browser.tasks;
import android.os.AsyncTask;
import android.view.View;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
import io.lbry.browser.utils.Lbryio;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class CommentCreateWithTipTask extends AsyncTask<Void, Void, Comment> {
private static final String STATUS_ENDPOINT = "https://comments.lbry.com";
private Comment comment;
private BigDecimal amount;
private View progressView;
private CommentCreateWithTipHandler handler;
private Exception error;
public CommentCreateWithTipTask(Comment comment, BigDecimal amount, View progressView, CommentCreateWithTipHandler handler) {
this.comment = comment;
this.amount = amount;
this.progressView = progressView;
this.handler = handler;
}
protected void onPreExecute() {
Helper.setViewVisibility(progressView, View.VISIBLE);
}
public Comment doInBackground(Void... params) {
Comment createdComment = null;
try {
// check comments status endpoint
Request request = new Request.Builder().url(STATUS_ENDPOINT).build();
OkHttpClient client = new OkHttpClient.Builder().
writeTimeout(30, TimeUnit.SECONDS).
readTimeout(30, TimeUnit.SECONDS).
build();
Response response = client.newCall(request).execute();
JSONObject status = new JSONObject(response.body().string());
String statusText = Helper.getJSONString("text", null, status);
boolean isRunning = Helper.getJSONBoolean("is_running", false, status);
if (!"ok".equalsIgnoreCase(statusText) || !isRunning) {
throw new ApiCallException("The comment server is not available at this time. Please try again later.");
}
Map<String, Object> options = new HashMap<>();
options.put("blocking", true);
options.put("claim_id", comment.getClaimId());
options.put("amount", new DecimalFormat(Helper.SDK_AMOUNT_FORMAT, new DecimalFormatSymbols(Locale.US)).format(amount.doubleValue()));
options.put("tip", true);
Lbry.genericApiCall(Lbry.METHOD_SUPPORT_CREATE, options);
options = new HashMap<>();
options.put("comment", comment.getText());
options.put("claim_id", comment.getClaimId());
options.put("channel_id", comment.getChannelId());
options.put("channel_name", comment.getChannelName());
if (!Helper.isNullOrEmpty(comment.getParentId())) {
options.put("parent_id", comment.getParentId());
}
JSONObject jsonObject = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_CREATE, options);
createdComment = Comment.fromJSONObject(jsonObject);
} catch (ApiCallException | ClassCastException | IOException | JSONException ex) {
error = ex;
}
return createdComment;
}
protected void onPostExecute(Comment createdComment) {
Helper.setViewVisibility(progressView, View.GONE);
if (handler != null) {
if (createdComment != null) {
handler.onSuccess(createdComment);
} else {
handler.onError(error);
}
}
}
public interface CommentCreateWithTipHandler {
void onSuccess(Comment createdComment);
void onError(Exception error);
}
}
@@ -8,11 +8,13 @@ import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.model.Comment; import io.lbry.browser.model.Comment;
import io.lbry.browser.utils.Comments;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
@@ -20,8 +22,8 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
private final int page; private final int page;
private final int pageSize; private final int pageSize;
private final String claim; private final String claim;
private ProgressBar progressBar; private final ProgressBar progressBar;
private CommentListHandler handler; private final CommentListHandler handler;
private Exception error; private Exception error;
public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) { public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) {
@@ -51,8 +53,7 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
options.put("skip_validation", true); options.put("skip_validation", true);
options.put("visible", true); options.put("visible", true);
JSONObject result = (JSONObject) Lbry.parseResponse(Comments.performRequest(Lbry.buildJsonParams(options), "comment.List"));
JSONObject result = (JSONObject) Lbry.genericApiCall(Lbry.METHOD_COMMENT_LIST, options);
JSONArray items = result.getJSONArray("items"); JSONArray items = result.getJSONArray("items");
List<Comment> children = new ArrayList<>(); List<Comment> children = new ArrayList<>();
@@ -68,6 +69,9 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
} }
} }
// Sort all replies from oldest to newest at once
Collections.sort(children);
for (Comment child : children) { for (Comment child : children) {
for (Comment parent : comments) { for (Comment parent : comments) {
if (parent.getId().equalsIgnoreCase(child.getParentId())) { if (parent.getId().equalsIgnoreCase(child.getParentId())) {
@@ -10,10 +10,10 @@ import io.lbry.browser.model.Tag;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class FollowUnfollowTagTask extends AsyncTask<Void, Void, Boolean> { public class FollowUnfollowTagTask extends AsyncTask<Void, Void, Boolean> {
private Tag tag; private final Tag tag;
private boolean unfollowing; private final boolean unfollowing;
private Context context; private final Context context;
private FollowUnfollowTagHandler handler; private final FollowUnfollowTagHandler handler;
private Exception error; private Exception error;
public FollowUnfollowTagTask(Tag tag, boolean unfollowing, Context context, FollowUnfollowTagHandler handler) { public FollowUnfollowTagTask(Tag tag, boolean unfollowing, Context context, FollowUnfollowTagHandler handler) {
@@ -12,9 +12,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lighthouse; import io.lbry.browser.utils.Lighthouse;
public class LighthouseAutoCompleteTask extends AsyncTask<Void, Void, List<UrlSuggestion>> { public class LighthouseAutoCompleteTask extends AsyncTask<Void, Void, List<UrlSuggestion>> {
private String text; private final String text;
private AutoCompleteResultHandler handler; private final AutoCompleteResultHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public LighthouseAutoCompleteTask(String text, View progressView, AutoCompleteResultHandler handler) { public LighthouseAutoCompleteTask(String text, View progressView, AutoCompleteResultHandler handler) {
@@ -14,13 +14,13 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lighthouse; import io.lbry.browser.utils.Lighthouse;
public class LighthouseSearchTask extends AsyncTask<Void, Void, List<Claim>> { public class LighthouseSearchTask extends AsyncTask<Void, Void, List<Claim>> {
private String rawQuery; private final String rawQuery;
private int size; private final int size;
private int from; private final int from;
private boolean nsfw; private final boolean nsfw;
private String relatedTo; private final String relatedTo;
private ClaimSearchResultHandler handler; private final ClaimSearchResultHandler handler;
private ProgressBar progressBar; private final ProgressBar progressBar;
private Exception error; private Exception error;
public LighthouseSearchTask(String rawQuery, int size, int from, boolean nsfw, String relatedTo, ProgressBar progressBar, ClaimSearchResultHandler handler) { public LighthouseSearchTask(String rawQuery, int size, int from, boolean nsfw, String relatedTo, ProgressBar progressBar, ClaimSearchResultHandler handler) {
@@ -4,22 +4,16 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.view.View;
import android.widget.ProgressBar;
import java.util.List; import java.util.List;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryRequestException;
import io.lbry.browser.exceptions.LbryResponseException;
import io.lbry.browser.model.Claim;
import io.lbry.browser.model.Tag; import io.lbry.browser.model.Tag;
import io.lbry.browser.utils.Helper;
public class LoadTagsTask extends AsyncTask<Void, Void, List<Tag>> { public class LoadTagsTask extends AsyncTask<Void, Void, List<Tag>> {
private Context context; private final Context context;
private LoadTagsHandler handler; private final LoadTagsHandler handler;
private Exception error; private Exception error;
public LoadTagsTask(Context context, LoadTagsHandler handler) { public LoadTagsTask(Context context, LoadTagsHandler handler) {
@@ -4,7 +4,6 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
@@ -17,24 +16,21 @@ import java.util.Map;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryUriException;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.LbryUri; import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
// background task to create a diff of local and remote subscriptions and try to merge // background task to create a diff of local and remote subscriptions and try to merge
public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> { public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
private static final String TAG = "MergeSubscriptionsTask"; private static final String TAG = "MergeSubscriptionsTask";
private Context context; private final Context context;
private List<Subscription> base; private final List<Subscription> base;
private List<Subscription> diff; private List<Subscription> diff;
private MergeSubscriptionsHandler handler; private final MergeSubscriptionsHandler handler;
private Exception error; private Exception error;
private boolean replaceLocal; private final boolean replaceLocal;
public MergeSubscriptionsTask(List<Subscription> base, boolean replaceLocal, Context context, MergeSubscriptionsHandler handler) { public MergeSubscriptionsTask(List<Subscription> base, boolean replaceLocal, Context context, MergeSubscriptionsHandler handler) {
this.base = base; this.base = base;
@@ -76,13 +72,15 @@ public class MergeSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
// check for any remote subs that may have been removed, and unsubscribe from them // check for any remote subs that may have been removed, and unsubscribe from them
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject item = array.getJSONObject(i); JSONObject item = array.getJSONObject(i);
// TODO: Refactor by creating static Subscription.fromJSON method
String claimId = item.getString("claim_id"); String claimId = item.getString("claim_id");
String channelName = item.getString("channel_name"); String channelName = item.getString("channel_name");
boolean isNotificationsDisabled = item.getBoolean("is_notifications_disabled");
LbryUri url = new LbryUri(); LbryUri url = new LbryUri();
url.setChannelName(channelName); url.setChannelName(channelName);
url.setClaimId(claimId); url.setClaimId(claimId);
Subscription subscription = new Subscription(channelName, url.toString()); Subscription subscription = new Subscription(channelName, url.toString(), isNotificationsDisabled);
remoteSubs.add(subscription); remoteSubs.add(subscription);
} }
} }
@@ -4,18 +4,15 @@ import android.os.AsyncTask;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.Buffer;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
public class ReadTextFileTask extends AsyncTask<Void, Void, String> { public class ReadTextFileTask extends AsyncTask<Void, Void, String> {
private String filePath; private final String filePath;
private Exception error; private Exception error;
private ReadTextFileHandler handler; private final ReadTextFileHandler handler;
public ReadTextFileTask(String filePath, ReadTextFileHandler handler) { public ReadTextFileTask(String filePath, ReadTextFileHandler handler) {
this.filePath = filePath; this.filePath = filePath;
this.handler = handler; this.handler = handler;
@@ -9,9 +9,9 @@ import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class SetSdkSettingTask extends AsyncTask<Void, Void, Boolean> { public class SetSdkSettingTask extends AsyncTask<Void, Void, Boolean> {
private String key; private final String key;
private String value; private final String value;
private GenericTaskHandler handler; private final GenericTaskHandler handler;
private Exception error; private Exception error;
public SetSdkSettingTask(String key, String value, GenericTaskHandler handler) { public SetSdkSettingTask(String key, String value, GenericTaskHandler handler) {
this.key = key; this.key = key;
@@ -13,13 +13,13 @@ import io.lbry.browser.utils.Lbry;
public class UpdateSuggestedTagsTask extends AsyncTask<Void, Void, List<Tag>> { public class UpdateSuggestedTagsTask extends AsyncTask<Void, Void, List<Tag>> {
private boolean clearPrevious; private final boolean clearPrevious;
private boolean excludeMature; private final boolean excludeMature;
private int limit; private final int limit;
private String filter; private final String filter;
private TagListAdapter addedTagsAdapter; private final TagListAdapter addedTagsAdapter;
private TagListAdapter suggestedTagsAdapter; private final TagListAdapter suggestedTagsAdapter;
private KnownTagsHandler handler; private final KnownTagsHandler handler;
public UpdateSuggestedTagsTask( public UpdateSuggestedTagsTask(
String filter, String filter,
@@ -21,9 +21,9 @@ import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
public class UploadImageTask extends AsyncTask<Void, Void, String> { public class UploadImageTask extends AsyncTask<Void, Void, String> {
private String filePath; private final String filePath;
private View progressView; private final View progressView;
private UploadThumbnailHandler handler; private final UploadThumbnailHandler handler;
private Exception error; private Exception error;
public UploadImageTask(String filePath, View progressView, UploadThumbnailHandler handler) { public UploadImageTask(String filePath, View progressView, UploadThumbnailHandler handler) {
@@ -11,17 +11,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class AbandonChannelTask extends AsyncTask<Void, Void, Boolean> { public class AbandonChannelTask extends AsyncTask<Void, Void, Boolean> {
private List<String> claimIds; private final List<String> claimIds;
private List<String> successfulClaimIds; private List<String> successfulClaimIds;
private List<String> failedClaimIds; private List<String> failedClaimIds;
private List<Exception> failedExceptions; private List<Exception> failedExceptions;
private View progressView; private final View progressView;
private AbandonHandler handler; private final AbandonHandler handler;
public AbandonChannelTask(List<String> claimIds, View progressView, AbandonHandler handler) { public AbandonChannelTask(List<String> claimIds, View progressView, AbandonHandler handler) {
this.claimIds = claimIds; this.claimIds = claimIds;
@@ -11,17 +11,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class AbandonStreamTask extends AsyncTask<Void, Void, Boolean> { public class AbandonStreamTask extends AsyncTask<Void, Void, Boolean> {
private List<String> claimIds; private final List<String> claimIds;
private List<String> successfulClaimIds; private List<String> successfulClaimIds;
private List<String> failedClaimIds; private List<String> failedClaimIds;
private List<Exception> failedExceptions; private List<Exception> failedExceptions;
private View progressView; private final View progressView;
private AbandonHandler handler; private final AbandonHandler handler;
public AbandonStreamTask(List<String> claimIds, View progressView, AbandonHandler handler) { public AbandonStreamTask(List<String> claimIds, View progressView, AbandonHandler handler) {
this.claimIds = claimIds; this.claimIds = claimIds;
@@ -21,12 +21,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ChannelCreateUpdateTask extends AsyncTask<Void, Void, Claim> { public class ChannelCreateUpdateTask extends AsyncTask<Void, Void, Claim> {
private Claim claim; private final Claim claim;
private BigDecimal deposit; private final BigDecimal deposit;
private boolean update; private final boolean update;
private Exception error; private Exception error;
private ClaimResultHandler handler; private final ClaimResultHandler handler;
private View progressView; private final View progressView;
public ChannelCreateUpdateTask(Claim claim, BigDecimal deposit, boolean update, View progressView, ClaimResultHandler handler) { public ChannelCreateUpdateTask(Claim claim, BigDecimal deposit, boolean update, View progressView, ClaimResultHandler handler) {
this.claim = claim; this.claim = claim;
@@ -19,9 +19,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ClaimListTask extends AsyncTask<Void, Void, List<Claim>> { public class ClaimListTask extends AsyncTask<Void, Void, List<Claim>> {
private List<String> types; private final List<String> types;
private View progressView; private final View progressView;
private ClaimListResultHandler handler; private final ClaimListResultHandler handler;
private Exception error; private Exception error;
public ClaimListTask(String type, View progressView, ClaimListResultHandler handler) { public ClaimListTask(String type, View progressView, ClaimListResultHandler handler) {
@@ -12,10 +12,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> { public class ClaimSearchTask extends AsyncTask<Void, Void, List<Claim>> {
private Map<String, Object> options; private final Map<String, Object> options;
private String connectionString; private final String connectionString;
private ClaimSearchResultHandler handler; private final ClaimSearchResultHandler handler;
private View progressView; private final View progressView;
private ApiCallException error; private ApiCallException error;
public ClaimSearchTask(Map<String, Object> options, String connectionString, View progressView, ClaimSearchResultHandler handler) { public ClaimSearchTask(Map<String, Object> options, String connectionString, View progressView, ClaimSearchResultHandler handler) {
@@ -21,10 +21,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class PublishClaimTask extends AsyncTask<Void, Void, Claim> { public class PublishClaimTask extends AsyncTask<Void, Void, Claim> {
private Claim claim; private final Claim claim;
private String filePath; private final String filePath;
private View progressView; private final View progressView;
private ClaimResultHandler handler; private final ClaimResultHandler handler;
private Exception error; private Exception error;
public PublishClaimTask(Claim claim, String filePath, View progressView, ClaimResultHandler handler) { public PublishClaimTask(Claim claim, String filePath, View progressView, ClaimResultHandler handler) {
this.claim = claim; this.claim = claim;
@@ -21,8 +21,8 @@ public class PurchaseListTask extends AsyncTask<Void, Void, List<Claim>> {
private String claimId; private String claimId;
private int page; private int page;
private int pageSize; private int pageSize;
private ClaimSearchResultHandler handler; private final ClaimSearchResultHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public PurchaseListTask(String claimId, View progressView, ClaimSearchResultHandler handler) { public PurchaseListTask(String claimId, View progressView, ClaimSearchResultHandler handler) {
@@ -13,10 +13,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class ResolveTask extends AsyncTask<Void, Void, List<Claim>> { public class ResolveTask extends AsyncTask<Void, Void, List<Claim>> {
private List<String> urls; private final List<String> urls;
private String connectionString; private final String connectionString;
private ClaimListResultHandler handler; private final ClaimListResultHandler handler;
private View progressView; private final View progressView;
private ApiCallException error; private ApiCallException error;
public ResolveTask(String url, String connectionString, View progressView, ClaimListResultHandler handler) { public ResolveTask(String url, String connectionString, View progressView, ClaimListResultHandler handler) {
@@ -20,12 +20,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class StreamRepostTask extends AsyncTask<Void, Void, Claim> { public class StreamRepostTask extends AsyncTask<Void, Void, Claim> {
private String name; private final String name;
private BigDecimal bid; private final BigDecimal bid;
private String claimId; private final String claimId;
private String channelId; private final String channelId;
private View progressView; private final View progressView;
private ClaimResultHandler handler; private final ClaimResultHandler handler;
private Exception error; private Exception error;
public StreamRepostTask(String name, BigDecimal bid, String claimId, String channelId, View progressView, ClaimResultHandler handler) { public StreamRepostTask(String name, BigDecimal bid, String claimId, String channelId, View progressView, ClaimResultHandler handler) {
@@ -7,12 +7,11 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import io.lbry.browser.exceptions.ApiCallException; import io.lbry.browser.exceptions.ApiCallException;
import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
// Just run delete on the specified claim IDs (no need for a handler) // Just run delete on the specified claim IDs (no need for a handler)
public class BulkDeleteFilesTask extends AsyncTask<Void, Void, Boolean> { public class BulkDeleteFilesTask extends AsyncTask<Void, Void, Boolean> {
private List<String> claimIds; private final List<String> claimIds;
public BulkDeleteFilesTask(List<String> claimIds) { public BulkDeleteFilesTask(List<String> claimIds) {
this.claimIds = claimIds; this.claimIds = claimIds;
} }
@@ -10,9 +10,9 @@ import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class DeleteFileTask extends AsyncTask<Void, Void, Boolean> { public class DeleteFileTask extends AsyncTask<Void, Void, Boolean> {
private String claimId; private final String claimId;
private Exception error; private Exception error;
private GenericTaskHandler handler; private final GenericTaskHandler handler;
public DeleteFileTask(String claimId, GenericTaskHandler handler) { public DeleteFileTask(String claimId, GenericTaskHandler handler) {
this.claimId = claimId; this.claimId = claimId;
@@ -11,12 +11,12 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> { public class FileListTask extends AsyncTask<Void, Void, List<LbryFile>> {
private String claimId; private final String claimId;
private boolean downloads; private boolean downloads;
private int page; private int page;
private int pageSize; private int pageSize;
private FileListResultHandler handler; private final FileListResultHandler handler;
private View progressView; private final View progressView;
private ApiCallException error; private ApiCallException error;
public FileListTask(int page, int pageSize, boolean downloads, View progressView, FileListResultHandler handler) { public FileListTask(int page, int pageSize, boolean downloads, View progressView, FileListResultHandler handler) {
@@ -14,10 +14,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry; import io.lbry.browser.utils.Lbry;
public class GetFileTask extends AsyncTask<Void, Void, LbryFile> { public class GetFileTask extends AsyncTask<Void, Void, LbryFile> {
private String uri; private final String uri;
private boolean saveFile; private final boolean saveFile;
private View progressView; private final View progressView;
private GetFileHandler handler; private final GetFileHandler handler;
private Exception error; private Exception error;
public GetFileTask(String uri, boolean saveFile, View progressView, GetFileHandler handler) { public GetFileTask(String uri, boolean saveFile, View progressView, GetFileHandler handler) {
@@ -15,18 +15,16 @@ import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.lbry.browser.MainActivity;
import io.lbry.browser.model.lbryinc.RewardVerified; import io.lbry.browser.model.lbryinc.RewardVerified;
import io.lbry.browser.tasks.RewardVerifiedHandler; import io.lbry.browser.tasks.RewardVerifiedHandler;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class AndroidPurchaseTask extends AsyncTask<Void, Void, RewardVerified> { public class AndroidPurchaseTask extends AsyncTask<Void, Void, RewardVerified> {
private Context context; private final Context context;
private View progressView; private final View progressView;
private String purchaseToken; private final String purchaseToken;
private RewardVerifiedHandler handler; private final RewardVerifiedHandler handler;
private Exception error; private Exception error;
public AndroidPurchaseTask(String purchaseToken, View progressView, Context context, RewardVerifiedHandler handler) { public AndroidPurchaseTask(String purchaseToken, View progressView, Context context, RewardVerifiedHandler handler) {
@@ -13,16 +13,15 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.lbryinc.Subscription; import io.lbry.browser.model.lbryinc.Subscription;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class ChannelSubscribeTask extends AsyncTask<Void, Void, Boolean> { public class ChannelSubscribeTask extends AsyncTask<Void, Void, Boolean> {
private Context context; private final Context context;
private String channelClaimId; private final String channelClaimId;
private Subscription subscription; private final Subscription subscription;
private ChannelSubscribeHandler handler; private final ChannelSubscribeHandler handler;
private Exception error; private Exception error;
private boolean isUnsubscribing; private final boolean isUnsubscribing;
public ChannelSubscribeTask(Context context, String channelClaimId, Subscription subscription, boolean isUnsubscribing, ChannelSubscribeHandler handler) { public ChannelSubscribeTask(Context context, String channelClaimId, Subscription subscription, boolean isUnsubscribing, ChannelSubscribeHandler handler) {
this.context = context; this.context = context;
@@ -51,11 +50,11 @@ public class ChannelSubscribeTask extends AsyncTask<Void, Void, Boolean> {
options.put("claim_id", channelClaimId); options.put("claim_id", channelClaimId);
if (!isUnsubscribing) { if (!isUnsubscribing) {
options.put("channel_name", subscription.getChannelName()); options.put("channel_name", subscription.getChannelName());
options.put("notifications_disabled", String.valueOf(subscription.isNotificationsDisabled()).toLowerCase());
} }
String action = isUnsubscribing ? "delete" : "new"; String action = isUnsubscribing ? "delete" : "new";
Lbryio.call("subscription", action, options, context); Object response = Lbryio.parseResponse(Lbryio.call("subscription", action, options, context));
if (!isUnsubscribing) { if (!isUnsubscribing) {
Lbryio.addSubscription(subscription); Lbryio.addSubscription(subscription);
} else { } else {
@@ -9,7 +9,6 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -25,12 +24,12 @@ import io.lbry.browser.utils.Lbryio;
public class ClaimRewardTask extends AsyncTask<Void, Void, String> { public class ClaimRewardTask extends AsyncTask<Void, Void, String> {
private Context context; private final Context context;
private String type; private final String type;
private String rewardCode; private final String rewardCode;
private View progressView; private final View progressView;
private double amountClaimed; private double amountClaimed;
private ClaimRewardHandler handler; private final ClaimRewardHandler handler;
private Exception error; private Exception error;
public ClaimRewardTask(String type, String rewardCode, View progressView, Context context, ClaimRewardHandler handler) { public ClaimRewardTask(String type, String rewardCode, View progressView, Context context, ClaimRewardHandler handler) {
@@ -7,9 +7,9 @@ import io.lbry.browser.model.lbryinc.User;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchCurrentUserTask extends AsyncTask<Void, Void, User> { public class FetchCurrentUserTask extends AsyncTask<Void, Void, User> {
private Context context; private final Context context;
private Exception error; private Exception error;
private FetchUserTaskHandler handler; private final FetchUserTaskHandler handler;
public FetchCurrentUserTask(Context context, FetchUserTaskHandler handler) { public FetchCurrentUserTask(Context context, FetchUserTaskHandler handler) {
this.context = context; this.context = context;
@@ -17,8 +17,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchInviteStatusTask extends AsyncTask<Void, Void, List<Invitee>> { public class FetchInviteStatusTask extends AsyncTask<Void, Void, List<Invitee>> {
private FetchInviteStatusHandler handler; private final FetchInviteStatusHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public FetchInviteStatusTask(View progressView, FetchInviteStatusHandler handler) { public FetchInviteStatusTask(View progressView, FetchInviteStatusHandler handler) {
@@ -12,8 +12,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchReferralCodeTask extends AsyncTask<Void, Void, String> { public class FetchReferralCodeTask extends AsyncTask<Void, Void, String> {
private FetchReferralCodeHandler handler; private final FetchReferralCodeHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public FetchReferralCodeTask(View progressView, FetchReferralCodeHandler handler) { public FetchReferralCodeTask(View progressView, FetchReferralCodeHandler handler) {
@@ -18,8 +18,8 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchRewardsTask extends AsyncTask<Void, Void, List<Reward>> { public class FetchRewardsTask extends AsyncTask<Void, Void, List<Reward>> {
private FetchRewardsHandler handler; private final FetchRewardsHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public FetchRewardsTask(View progressView, FetchRewardsHandler handler) { public FetchRewardsTask(View progressView, FetchRewardsHandler handler) {
@@ -15,10 +15,10 @@ public class FetchStatCountTask extends AsyncTask<Void, Void, Integer> {
public static final int STAT_VIEW_COUNT = 1; public static final int STAT_VIEW_COUNT = 1;
public static final int STAT_SUB_COUNT = 2; public static final int STAT_SUB_COUNT = 2;
private String claimId; private final String claimId;
private int stat; private final int stat;
private FetchStatCountHandler handler; private final FetchStatCountHandler handler;
private View progressView; private final View progressView;
private Exception error; private Exception error;
public FetchStatCountTask(int stat, String claimId, View progressView, FetchStatCountHandler handler) { public FetchStatCountTask(int stat, String claimId, View progressView, FetchStatCountHandler handler) {
@@ -23,9 +23,9 @@ import io.lbry.browser.utils.LbryUri;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class FetchSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> { public class FetchSubscriptionsTask extends AsyncTask<Void, Void, List<Subscription>> {
private Context context; private final Context context;
private FetchSubscriptionsHandler handler; private final FetchSubscriptionsHandler handler;
private ProgressBar progressBar; private final ProgressBar progressBar;
private Exception error; private Exception error;
public FetchSubscriptionsTask(Context context, ProgressBar progressBar, FetchSubscriptionsHandler handler) { public FetchSubscriptionsTask(Context context, ProgressBar progressBar, FetchSubscriptionsHandler handler) {
@@ -49,11 +49,12 @@ public class FetchSubscriptionsTask extends AsyncTask<Void, Void, List<Subscript
JSONObject item = array.getJSONObject(i); JSONObject item = array.getJSONObject(i);
String claimId = item.getString("claim_id"); String claimId = item.getString("claim_id");
String channelName = item.getString("channel_name"); String channelName = item.getString("channel_name");
boolean isNotificationsDisabled = item.getBoolean("is_notifications_disabled");
LbryUri url = new LbryUri(); LbryUri url = new LbryUri();
url.setChannelName(channelName); url.setChannelName(channelName);
url.setClaimId(claimId); url.setClaimId(claimId);
Subscription subscription = new Subscription(channelName, url.toString()); Subscription subscription = new Subscription(channelName, url.toString(), isNotificationsDisabled);
subscriptions.add(subscription); subscriptions.add(subscription);
// Persist the subscription locally if it doesn't exist // Persist the subscription locally if it doesn't exist
if (db != null) { if (db != null) {
@@ -14,9 +14,9 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class InviteByEmailTask extends AsyncTask<Void, Void, Boolean> { public class InviteByEmailTask extends AsyncTask<Void, Void, Boolean> {
private String email; private final String email;
private View progressView; private final View progressView;
private GenericTaskHandler handler; private final GenericTaskHandler handler;
private Exception error; private Exception error;
public InviteByEmailTask(String email, View progressView, GenericTaskHandler handler) { public InviteByEmailTask(String email, View progressView, GenericTaskHandler handler) {
@@ -2,24 +2,21 @@ package io.lbry.browser.tasks.lbryinc;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executor;
import io.lbry.browser.exceptions.LbryioRequestException; import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.tasks.GenericTaskHandler; import io.lbry.browser.tasks.GenericTaskHandler;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class LogFileViewTask extends AsyncTask<Void, Void, Boolean> { public class LogFileViewTask extends AsyncTask<Void, Void, Boolean> {
private String uri; private final String uri;
private Claim claim; private final Claim claim;
private Exception error; private Exception error;
private GenericTaskHandler handler; private final GenericTaskHandler handler;
private long timeToStart; private final long timeToStart;
public LogFileViewTask(String uri, Claim claim, long timeToStart, GenericTaskHandler handler) { public LogFileViewTask(String uri, Claim claim, long timeToStart, GenericTaskHandler handler) {
this.uri = uri; this.uri = uri;
@@ -2,7 +2,6 @@ package io.lbry.browser.tasks.lbryinc;
import android.os.AsyncTask; import android.os.AsyncTask;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -10,10 +9,9 @@ import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException; import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.model.Claim; import io.lbry.browser.model.Claim;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
import okhttp3.Response;
public class LogPublishTask extends AsyncTask<Void, Void, Void> { public class LogPublishTask extends AsyncTask<Void, Void, Void> {
private Claim claimResult; private final Claim claimResult;
public LogPublishTask(Claim claimResult) { public LogPublishTask(Claim claimResult) {
this.claimResult = claimResult; this.claimResult = claimResult;
} }
@@ -0,0 +1,33 @@
package io.lbry.browser.tasks.lbryinc;
import android.os.AsyncTask;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.lbry.browser.exceptions.LbryioRequestException;
import io.lbry.browser.exceptions.LbryioResponseException;
import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio;
public class NotificationDeleteTask extends AsyncTask<Void, Void, Boolean> {
private final List<Long> ids;
public NotificationDeleteTask(List<Long> ids) {
this.ids = ids;
}
protected Boolean doInBackground(Void... params) {
Map<String, String> options = new HashMap<>();
options.put("notification_ids", Helper.joinL(ids, ","));
try {
Object result = Lbryio.parseResponse(Lbryio.call("notification", "delete", options, null));
return "ok".equalsIgnoreCase(result.toString());
} catch (LbryioResponseException | LbryioRequestException ex) {
// pass
}
return false;
}
}
@@ -16,8 +16,10 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import io.lbry.browser.MainActivity; import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
@@ -30,9 +32,9 @@ import io.lbry.browser.utils.Lbryio;
public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotification>> { public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotification>> {
private static final String TAG = "Notifications"; private static final String TAG = "Notifications";
private Context context; private final Context context;
private ListNotificationsHandler handler; private final ListNotificationsHandler handler;
private ProgressBar progressBar; private final ProgressBar progressBar;
private Exception error; private Exception error;
public NotificationListTask(Context context, ProgressBar progressBar, ListNotificationsHandler handler) { public NotificationListTask(Context context, ProgressBar progressBar, ListNotificationsHandler handler) {
@@ -47,7 +49,9 @@ public class NotificationListTask extends AsyncTask<Void, Void, List<LbryNotific
List<LbryNotification> notifications = new ArrayList<>(); List<LbryNotification> notifications = new ArrayList<>();
SQLiteDatabase db = null; SQLiteDatabase db = null;
try { try {
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", context)); Map<String, String> parameters = new HashMap<>(1);
parameters.put("is_app_readable", "true");
JSONArray array = (JSONArray) Lbryio.parseResponse(Lbryio.call("notification", "list", parameters, context));
if (array != null) { if (array != null) {
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
JSONObject item = array.getJSONObject(i); JSONObject item = array.getJSONObject(i);
@@ -12,28 +12,28 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class NotificationUpdateTask extends AsyncTask<Void, Void, Boolean> { public class NotificationUpdateTask extends AsyncTask<Void, Void, Boolean> {
private List<Long> ids; private final List<Long> ids;
private boolean seen; private final boolean seen;
private boolean read; private final boolean read;
private boolean updateSeen; private final boolean updateRead;
public NotificationUpdateTask(List<Long> ids, boolean read) { public NotificationUpdateTask(List<Long> ids, boolean seen) {
this(ids, read, false, false); this(ids, false, true, false);
} }
public NotificationUpdateTask(List<Long> ids, boolean read, boolean seen, boolean updateSeen) { public NotificationUpdateTask(List<Long> ids, boolean read, boolean seen, boolean updateRead) {
this.ids = ids; this.ids = ids;
this.read = read; this.read = read;
this.seen = seen; this.seen = seen;
this.updateSeen = updateSeen; this.updateRead = updateRead;
} }
protected Boolean doInBackground(Void... params) { protected Boolean doInBackground(Void... params) {
Map<String, String> options = new HashMap<>(); Map<String, String> options = new HashMap<>();
options.put("notification_ids", Helper.joinL(ids, ",")); options.put("notification_ids", Helper.joinL(ids, ","));
options.put("is_read", String.valueOf(read)); options.put("is_seen", String.valueOf(seen));
if (updateSeen) { if (updateRead) {
options.put("is_seen", String.valueOf(seen)); options.put("is_read", String.valueOf(read));
} }
try { try {
@@ -22,10 +22,10 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class TwitterVerifyTask extends AsyncTask<Void, Void, RewardVerified> { public class TwitterVerifyTask extends AsyncTask<Void, Void, RewardVerified> {
private Context context; private final Context context;
private View progressView; private final View progressView;
private TwitterOauth twitterOauth; private final TwitterOauth twitterOauth;
private RewardVerifiedHandler handler; private final RewardVerifiedHandler handler;
private Exception error; private Exception error;
public TwitterVerifyTask(TwitterOauth twitterOauth, View progressView, Context context, RewardVerifiedHandler handler) { public TwitterVerifyTask(TwitterOauth twitterOauth, View progressView, Context context, RewardVerifiedHandler handler) {
@@ -11,8 +11,8 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion; import io.lbry.browser.model.UrlSuggestion;
public class FetchRecentUrlHistoryTask extends AsyncTask<Void, Void, List<UrlSuggestion>> { public class FetchRecentUrlHistoryTask extends AsyncTask<Void, Void, List<UrlSuggestion>> {
private DatabaseHelper dbHelper; private final DatabaseHelper dbHelper;
private FetchRecentUrlHistoryHandler handler; private final FetchRecentUrlHistoryHandler handler;
public FetchRecentUrlHistoryTask(DatabaseHelper dbHelper, FetchRecentUrlHistoryHandler handler) { public FetchRecentUrlHistoryTask(DatabaseHelper dbHelper, FetchRecentUrlHistoryHandler handler) {
this.dbHelper = dbHelper; this.dbHelper = dbHelper;
this.handler = handler; this.handler = handler;
@@ -10,15 +10,14 @@ import java.util.Date;
import java.util.List; import java.util.List;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.model.ViewHistory; import io.lbry.browser.model.ViewHistory;
import io.lbry.browser.utils.Helper; import io.lbry.browser.utils.Helper;
public class FetchViewHistoryTask extends AsyncTask<Void, Void, List<ViewHistory>> { public class FetchViewHistoryTask extends AsyncTask<Void, Void, List<ViewHistory>> {
private DatabaseHelper dbHelper; private final DatabaseHelper dbHelper;
private FetchViewHistoryHandler handler; private final FetchViewHistoryHandler handler;
private int pageSize; private final int pageSize;
private Date lastDate; private final Date lastDate;
public FetchViewHistoryTask(Date lastDate, int pageSize, DatabaseHelper dbHelper, FetchViewHistoryHandler handler) { public FetchViewHistoryTask(Date lastDate, int pageSize, DatabaseHelper dbHelper, FetchViewHistoryHandler handler) {
this.lastDate = lastDate; this.lastDate = lastDate;
this.pageSize = pageSize; this.pageSize = pageSize;
@@ -6,7 +6,6 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.util.Log; import android.util.Log;
@@ -23,9 +22,9 @@ import io.lbry.browser.utils.Helper;
public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<GalleryItem>> { public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<GalleryItem>> {
private static final String TAG = "LoadGalleryItemsTask"; private static final String TAG = "LoadGalleryItemsTask";
private LoadGalleryHandler handler; private final LoadGalleryHandler handler;
private View progressView; private final View progressView;
private Context context; private final Context context;
public LoadGalleryItemsTask(View progressView, Context context, LoadGalleryHandler handler) { public LoadGalleryItemsTask(View progressView, Context context, LoadGalleryHandler handler) {
this.progressView = progressView; this.progressView = progressView;
@@ -44,6 +43,7 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
if (context != null) { if (context != null) {
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
try { try {
// TODO: MediaStore.Video.Media.DURATION requires API level 29
String[] projection = { String[] projection = {
MediaStore.MediaColumns._ID, MediaStore.MediaColumns._ID,
MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.DATA,
@@ -61,6 +61,7 @@ public class LoadGalleryItemsTask extends AsyncTask<Void, GalleryItem, List<Gall
int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME); int nameColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE); int typeColumn = cursor.getColumnIndex(MediaStore.MediaColumns.MIME_TYPE);
int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); int pathColumn = cursor.getColumnIndex(MediaStore.MediaColumns.DATA);
// TODO: MediaStore.Video.Media.DURATION requires API level 29
int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION); int durationColumn = cursor.getColumnIndex(MediaStore.Video.Media.DURATION);
GalleryItem item = new GalleryItem(); GalleryItem item = new GalleryItem();
@@ -1,18 +1,15 @@
package io.lbry.browser.tasks.localdata; package io.lbry.browser.tasks.localdata;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask; import android.os.AsyncTask;
import io.lbry.browser.MainActivity;
import io.lbry.browser.data.DatabaseHelper; import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.UrlSuggestion; import io.lbry.browser.model.UrlSuggestion;
import io.lbry.browser.tasks.GenericTaskHandler;
public class SaveUrlHistoryTask extends AsyncTask<Void, Void, Boolean> { public class SaveUrlHistoryTask extends AsyncTask<Void, Void, Boolean> {
private DatabaseHelper dbHelper; private final DatabaseHelper dbHelper;
private UrlSuggestion suggestion; private final UrlSuggestion suggestion;
private SaveUrlHistoryHandler handler; private final SaveUrlHistoryHandler handler;
private Exception error; private Exception error;
public SaveUrlHistoryTask(UrlSuggestion suggestion, DatabaseHelper dbHelper, SaveUrlHistoryHandler handler) { public SaveUrlHistoryTask(UrlSuggestion suggestion, DatabaseHelper dbHelper, SaveUrlHistoryHandler handler) {
@@ -7,9 +7,9 @@ import io.lbry.browser.data.DatabaseHelper;
import io.lbry.browser.model.ViewHistory; import io.lbry.browser.model.ViewHistory;
public class SaveViewHistoryTask extends AsyncTask<Void, Void, Boolean> { public class SaveViewHistoryTask extends AsyncTask<Void, Void, Boolean> {
private DatabaseHelper dbHelper; private final DatabaseHelper dbHelper;
private ViewHistory history; private final ViewHistory history;
private SaveViewHistoryHandler handler; private final SaveViewHistoryHandler handler;
private Exception error; private Exception error;
public SaveViewHistoryTask(ViewHistory history, DatabaseHelper dbHelper, SaveViewHistoryHandler handler) { public SaveViewHistoryTask(ViewHistory history, DatabaseHelper dbHelper, SaveViewHistoryHandler handler) {
@@ -8,8 +8,8 @@ import io.lbry.browser.model.lbryinc.User;
import io.lbry.browser.utils.Lbryio; import io.lbry.browser.utils.Lbryio;
public class CheckUserEmailVerifiedTask extends AsyncTask<Void, Void, Boolean> { public class CheckUserEmailVerifiedTask extends AsyncTask<Void, Void, Boolean> {
private Context context; private final Context context;
private CheckUserEmailVerifiedHandler handler; private final CheckUserEmailVerifiedHandler handler;
public CheckUserEmailVerifiedTask(Context context, CheckUserEmailVerifiedHandler handler) { public CheckUserEmailVerifiedTask(Context context, CheckUserEmailVerifiedHandler handler) {
this.context = context; this.context = context;
Loaded 100 of 268 files, more files were not shown because too many files have changed in this diff. Show more