Compare commits
111 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a35d7dc5ae | ||
|
|
1e9e7e4cd7 | ||
|
|
cfd97ebd3d | ||
|
|
3ac8dc5558 | ||
|
|
6f93440b11 | ||
|
|
9283f419ba | ||
|
|
be67b36b6a | ||
|
|
6934daecff | ||
|
|
3d74d027c1 | ||
|
|
e048235dad | ||
|
|
d21dff08b8 | ||
|
|
5f06c4c3c0 | ||
|
|
b693b34fe7 | ||
|
|
b7f469957c | ||
|
|
4a7b415635 | ||
|
|
d9985d03ab | ||
|
|
6e324fd5ab | ||
|
|
167498dd2c | ||
|
|
688eaf6aab | ||
|
|
d7df105e04 | ||
|
|
ea5c4cd027 | ||
|
|
9589706df9 | ||
|
|
e6e37aec47 | ||
|
|
fc2d5fe00e | ||
|
|
a73d3d375a | ||
|
|
ce97c8f7d9 | ||
|
|
a48abc56dd | ||
|
|
1044d7a8d1 | ||
|
|
fb0a075c50 | ||
|
|
8a8c785a31 | ||
|
|
4e976fc4ec | ||
|
|
cdf06578c1 | ||
|
|
4a131d6215 | ||
|
|
45f71cdcc1 | ||
|
|
5192175ddc | ||
|
|
274a672637 | ||
|
|
c281ab5a39 | ||
|
|
0106afc93c | ||
|
|
d69b091858 | ||
|
|
f71274d90d | ||
|
|
a37b9a1036 | ||
|
|
a9b8174b10 | ||
|
|
20a0eda5db | ||
|
|
e231dba0b0 | ||
|
|
d9459dc8fa | ||
|
|
a55ff5ce5a | ||
|
|
f2ea1cde46 | ||
|
|
04dd8003f7 | ||
|
|
b82b46f7d7 | ||
|
|
33bccd10fe | ||
|
|
9956f1ae4f | ||
|
|
09a3c5da23 | ||
|
|
b1d51bbefb | ||
|
|
9e7aaa6c91 | ||
|
|
9686c97731 | ||
|
|
663718ece4 | ||
|
|
e3048d1eb2 | ||
|
|
c6785bfda0 | ||
|
|
781438d83a | ||
|
|
f5625cc6b9 | ||
|
|
132d375d81 | ||
|
|
54007ecd28 | ||
|
|
03c2b55776 | ||
|
|
c6e46384f8 | ||
|
|
ce1c607f05 | ||
|
|
19bbe51f01 | ||
|
|
ff4a4eaf78 | ||
|
|
2cf08f74db | ||
|
|
cc6bbc9869 | ||
|
|
8d962516f4 | ||
|
|
ced4ca01cb | ||
|
|
1195323acd | ||
|
|
87b62aef70 | ||
|
|
ec89ba0155 | ||
|
|
0695103589 | ||
|
|
8d47b09e80 | ||
|
|
3cd156ae42 | ||
|
|
4a22f62ec5 | ||
|
|
9ad37b4412 | ||
|
|
9fcabcb05e | ||
|
|
db1ae6020d | ||
|
|
7e039c9055 | ||
|
|
db7482ff12 | ||
|
|
d63ae7cadd | ||
|
|
c4fa0d405e | ||
|
|
63fef3ab7c | ||
|
|
7019c07a6d | ||
|
|
006ea9844a | ||
|
|
d2bbfe01f1 | ||
|
|
86d8ff3c68 | ||
|
|
00dacc32df | ||
|
|
1c1bd9265e | ||
|
|
0bb090eee6 | ||
|
|
d2f3bfb2e3 | ||
|
|
634ce0dddf | ||
|
|
c82bacb037 | ||
|
|
3edfd0892a | ||
|
|
30c0fd600f | ||
|
|
ccb31de1ba | ||
|
|
a74b623c10 | ||
|
|
5808e8f321 | ||
|
|
4f3fef3bfe | ||
|
|
0c07e649bf | ||
|
|
3be96cf035 | ||
|
|
82efa8298d | ||
|
|
c2ba716916 | ||
|
|
f61497ffd9 | ||
|
|
7f3c46942d | ||
|
|
9d1c4bd660 | ||
|
|
3b357eb509 | ||
|
|
786914b1a6 |
29
.github/ISSUE_TEMPLATE.md
vendored
Normal file
29
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
**PLEASE READ THIS**
|
||||||
|
|
||||||
|
I acknowledge that:
|
||||||
|
|
||||||
|
- I have updated to the latest version of the app (https://github.com/KotatsuApp/Kotatsu/releases/latest)
|
||||||
|
- If this is an issue with a parser, that I should be opening an issue in https://github.com/KotatsuApp/kotatsu-parsers
|
||||||
|
- I have searched the existing issues and this is new ticket **NOT** a duplicate or related to another open or closed issue
|
||||||
|
- I will fill out the title and the information in this template
|
||||||
|
|
||||||
|
Note that the issue will be automatically closed if you do not fill out the title or requested information.
|
||||||
|
|
||||||
|
**DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Device information
|
||||||
|
* Kotatsu version: ?
|
||||||
|
* Android version: ?
|
||||||
|
* Device: ?
|
||||||
|
|
||||||
|
## Steps to reproduce
|
||||||
|
1. First step
|
||||||
|
2. Second step
|
||||||
|
|
||||||
|
## Issue/Request
|
||||||
|
?
|
||||||
|
|
||||||
|
## Other details
|
||||||
|
Additional details and attachments.
|
||||||
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: ⚠️ Source issue
|
- name: ⚠️ Source issue
|
||||||
url: https://github.com/nv95/kotatsu-parsers/issues/new
|
url: https://github.com/KotatsuApp/kotatsu-parsers/issues/new
|
||||||
about: Issues and requests for sources should be opened in the kotatsu-parsers repository instead
|
about: Issues and requests for sources should be opened in the kotatsu-parsers repository instead
|
||||||
6
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
6
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
@@ -44,7 +44,7 @@ body:
|
|||||||
label: Kotatsu version
|
label: Kotatsu version
|
||||||
description: You can find your Kotatsu version in **Settings → About**.
|
description: You can find your Kotatsu version in **Settings → About**.
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Example: "3.2.3"
|
Example: "3.3"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
@@ -85,9 +85,7 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have written a short but informative title.
|
- label: I have written a short but informative title.
|
||||||
required: true
|
required: true
|
||||||
- label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/nv95/kotatsu-parsers/issues/new).
|
- label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/KotatsuApp/kotatsu-parsers/issues/new).
|
||||||
required: true
|
|
||||||
- label: I have updated the app to version **[3.2.3](https://github.com/nv95/Kotatsu/releases/latest)**.
|
|
||||||
required: true
|
required: true
|
||||||
- label: I will fill out all of the requested information in this form.
|
- label: I will fill out all of the requested information in this form.
|
||||||
required: true
|
required: true
|
||||||
14
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
14
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
@@ -21,6 +21,16 @@ body:
|
|||||||
placeholder: |
|
placeholder: |
|
||||||
Additional details and attachments.
|
Additional details and attachments.
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: kotatsu-version
|
||||||
|
attributes:
|
||||||
|
label: Kotatsu version
|
||||||
|
description: You can find your Kotatsu version in **Settings → About**.
|
||||||
|
placeholder: |
|
||||||
|
Example: "3.3"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
- type: checkboxes
|
- type: checkboxes
|
||||||
id: acknowledgements
|
id: acknowledgements
|
||||||
attributes:
|
attributes:
|
||||||
@@ -31,9 +41,7 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have written a short but informative title.
|
- label: I have written a short but informative title.
|
||||||
required: true
|
required: true
|
||||||
- label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/nv95/kotatsu-parsers/issues/new).
|
- label: If this is an issue with a source, I should be opening an issue in the [parsers repository](https://github.com/KotatsuApp/kotatsu-parsers/issues/new).
|
||||||
required: true
|
|
||||||
- label: I have updated the app to version **[3.2.3](https://github.com/nv95/Kotatsu/releases/latest)**.
|
|
||||||
required: true
|
required: true
|
||||||
- label: I will fill out all of the requested information in this form.
|
- label: I will fill out all of the requested information in this form.
|
||||||
required: true
|
required: true
|
||||||
29
.github/workflows/issue_moderator.yml
vendored
Normal file
29
.github/workflows/issue_moderator.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Issue moderator
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened, edited, reopened]
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
moderate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Moderate issues
|
||||||
|
uses: tachiyomiorg/issue-moderator-action@v1
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
auto-close-rules: |
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"type": "body",
|
||||||
|
"regex": ".*DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT.*",
|
||||||
|
"message": "The acknowledgment section was not removed."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "body",
|
||||||
|
"regex": ".*\\* (Kotatsu version|Android version|Device): \\?.*",
|
||||||
|
"message": "Requested information in the template was not filled out."
|
||||||
|
}
|
||||||
|
]
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -12,6 +12,8 @@
|
|||||||
/.idea/assetWizardSettings.xml
|
/.idea/assetWizardSettings.xml
|
||||||
/.idea/kotlinScripting.xml
|
/.idea/kotlinScripting.xml
|
||||||
/.idea/deploymentTargetDropDown.xml
|
/.idea/deploymentTargetDropDown.xml
|
||||||
|
/.idea/androidTestResultsUserPreferences.xml
|
||||||
|
/.idea/render.experimental.xml
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|||||||
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -7,7 +7,7 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="Android Studio default JDK" />
|
<option name="gradleJvm" value="Embedded JDK" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
287
.idea/icon.svg
generated
Normal file
287
.idea/icon.svg
generated
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
inkscape:export-ydpi="39.689999"
|
||||||
|
inkscape:export-xdpi="39.689999"
|
||||||
|
inkscape:export-filename="/home/admin/Documents/projects/graphics/k/icon4.png"
|
||||||
|
width="512mm"
|
||||||
|
height="512mm"
|
||||||
|
viewBox="0 0 512 512.00002"
|
||||||
|
version="1.1"
|
||||||
|
id="svg8"
|
||||||
|
inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
|
||||||
|
sodipodi:docname="icon4.svg">
|
||||||
|
<defs
|
||||||
|
id="defs2">
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1266">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1256" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1258" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1260" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1262" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1264" />
|
||||||
|
</filter>
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1059">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1049" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1051" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1053" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1055" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1057" />
|
||||||
|
</filter>
|
||||||
|
<filter
|
||||||
|
style="color-interpolation-filters:sRGB;"
|
||||||
|
inkscape:label="Drop Shadow"
|
||||||
|
id="filter1071">
|
||||||
|
<feFlood
|
||||||
|
flood-opacity="0.498039"
|
||||||
|
flood-color="rgb(0,0,0)"
|
||||||
|
result="flood"
|
||||||
|
id="feFlood1061" />
|
||||||
|
<feComposite
|
||||||
|
in="flood"
|
||||||
|
in2="SourceGraphic"
|
||||||
|
operator="in"
|
||||||
|
result="composite1"
|
||||||
|
id="feComposite1063" />
|
||||||
|
<feGaussianBlur
|
||||||
|
in="composite1"
|
||||||
|
stdDeviation="3"
|
||||||
|
result="blur"
|
||||||
|
id="feGaussianBlur1065" />
|
||||||
|
<feOffset
|
||||||
|
dx="6"
|
||||||
|
dy="6"
|
||||||
|
result="offset"
|
||||||
|
id="feOffset1067" />
|
||||||
|
<feComposite
|
||||||
|
in="SourceGraphic"
|
||||||
|
in2="offset"
|
||||||
|
operator="over"
|
||||||
|
result="composite2"
|
||||||
|
id="feComposite1069" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#0d47a1"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="0.175"
|
||||||
|
inkscape:cx="-361.03654"
|
||||||
|
inkscape:cy="630.78782"
|
||||||
|
inkscape:document-units="mm"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:window-width="1600"
|
||||||
|
inkscape:window-height="838"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="20"
|
||||||
|
fit-margin-left="20"
|
||||||
|
fit-margin-right="20"
|
||||||
|
fit-margin-bottom="20" />
|
||||||
|
<metadata
|
||||||
|
id="metadata5">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Слой 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-51.12025,-104.74797)">
|
||||||
|
<g
|
||||||
|
id="g1028"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1030"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1032"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1034"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1036"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1038"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1040"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1042"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1044"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1046"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1048"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1050"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1052"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1054"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<g
|
||||||
|
id="g1056"
|
||||||
|
transform="matrix(6.9754464,0,0,6.9754464,32.42507,404.31391)" />
|
||||||
|
<path
|
||||||
|
id="path1128"
|
||||||
|
d="m 307.12025,310.74755 c -50.53732,0 -91.66608,44.85688 -91.66608,99.99965 0,55.14277 41.12954,99.99964 91.66608,99.99964 50.53653,0 91.66607,-44.85687 91.66607,-99.99964 0,-55.14277 -41.12875,-99.99965 -91.66607,-99.99965 z m -34.21238,78.72707 c -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52265,-0.27656 -3.72733,-0.8789 l -12.9398,-6.4781 -12.9398,6.4781 c -4.13436,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05077,-4.11796 -0.39062,-9.11481 3.72733,-11.18199 l 16.66635,-8.33357 c 2.34374,-1.17187 5.11092,-1.17187 7.45466,0 l 16.66635,8.33357 c 4.11951,2.06718 5.77966,7.06403 3.72889,11.18199 z m 58.33338,-24.99991 c -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52264,-0.27656 -3.72733,-0.8789 l -12.93901,-6.47811 -12.9398,6.47811 c -4.13436,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05078,-4.11796 -0.39063,-9.11482 3.72733,-11.182 l 16.66634,-8.33356 c 2.34375,-1.17187 5.11092,-1.17187 7.45466,0 l 16.66635,8.33356 c 4.11874,2.06718 5.77889,7.06404 3.72811,11.182 z m 54.60606,13.81792 c 4.11795,2.06718 5.7781,7.06403 3.72733,11.18199 -1.46484,2.91327 -4.41092,4.60623 -7.45466,4.60623 -1.25312,0 -2.52265,-0.27656 -3.72733,-0.8789 l -12.9398,-6.4781 -12.9398,6.4781 c -4.11795,2.06718 -9.11481,0.37421 -11.18199,-3.72733 -2.05077,-4.11796 -0.39062,-9.11481 3.72733,-11.18199 l 16.66635,-8.33357 c 2.34374,-1.17187 5.11092,-1.17187 7.45466,0 z"
|
||||||
|
style="fill:#ffffff;stroke-width:0.781247" />
|
||||||
|
<path
|
||||||
|
id="path1130"
|
||||||
|
d="m 415.36283,274.00237 c -3.48202,-6.90544 -6.92029,-13.41714 -10.20934,-19.37102 l -8.26716,-14.47964 c -6.79607,-11.51871 -12.25699,-19.90305 -14.78354,-23.66554 -0.7164,-43.32797 -19.12415,-53.79356 -21.25617,-54.86777 -3.20624,-1.5789 -7.09607,-0.97656 -9.6195,1.56249 -12.25621,12.25621 -20.23118,24.4632 -24.00695,30.89286 h -40.20141 c -3.77577,-6.42888 -11.75153,-18.63665 -24.00695,-30.89286 -2.52265,-2.53905 -6.39685,-3.14139 -9.6195,-1.56249 -2.13202,1.07421 -20.54055,11.5398 -21.25617,54.86777 -2.52655,3.76327 -7.98669,12.14605 -14.78276,23.66476 l -8.27341,14.49214 c -3.28983,5.95701 -6.73044,12.47105 -10.21403,19.3804 l -7.4445,15.32572 c -17.72572,38.05377 -34.30066,85.4286 -34.30066,129.72766 0,69.32085 58.26776,128.42064 60.75838,130.89485 0.91171,0.91172 2.03437,1.61171 3.25546,2.01796 1.07421,0.35859 26.78974,8.757 69.31928,8.757 2.21327,0 4.32967,-0.8789 5.89217,-2.4414 l 5.89216,-5.89216 h 9.76559 l 5.89217,5.89216 c 1.56249,1.5625 3.67811,2.4414 5.89216,2.4414 42.52954,0 68.24507,-8.39841 69.31929,-8.757 1.22109,-0.40703 2.34374,-1.10703 3.25546,-2.01796 2.48905,-2.47421 60.75681,-61.57322 60.75681,-130.89485 0,-44.29906 -16.57494,-91.67389 -34.30066,-129.72766 z M 348.7865,227.41426 c 4.60624,0 4.41171,7.35466 4.41171,11.96089 4.60623,0 12.25464,0.1 12.25464,4.70624 0,9.19606 -7.47107,16.66634 -16.66635,16.66634 -9.19528,0 -16.66634,-7.47028 -16.66634,-16.66634 0,-9.19606 7.47106,-16.66713 16.66634,-16.66713 z m -57.69823,30.14364 c 1.28593,-3.10858 4.32967,-5.14295 7.69841,-5.14295 h 16.66635 c 3.36952,0 6.41248,2.03437 7.69841,5.14295 1.28593,3.10858 0.56953,6.70545 -1.80703,9.082 l -8.33356,8.33356 c -1.62734,1.62734 -3.76014,2.4414 -5.89217,2.4414 -2.13202,0 -4.26404,-0.81406 -5.89216,-2.4414 l -8.33357,-8.33356 c -2.37421,-2.37655 -3.09061,-5.97342 -1.80468,-9.082 z m -25.63428,-30.14364 c 4.60623,0 4.4117,7.35466 4.4117,11.96089 4.60623,0 12.25465,0.1 12.25465,4.70624 0,9.19606 -7.47107,16.66634 -16.66635,16.66634 -9.19606,0 -16.66635,-7.47106 -16.66635,-16.66634 -7.8e-4,-9.19606 7.47029,-16.66713 16.66635,-16.66713 z m 41.66626,299.99893 c -59.7326,0 -108.33321,-52.34357 -108.33321,-116.66599 0,-64.32243 48.60061,-116.66599 108.33321,-116.66599 59.73259,0 108.3332,52.34356 108.3332,116.66599 0,64.32242 -48.60061,116.66599 -108.3332,116.66599 z"
|
||||||
|
style="fill:#ffffff;stroke-width:0.781247;filter:url(#filter1059)"
|
||||||
|
sodipodi:nodetypes="cccccccccccccccsccssccssccsccscsssssssssssccsscsscssssss" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1138"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)"
|
||||||
|
inkscape:groupmode="layer" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1140"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1142"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1144"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1146"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1148"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1150"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1152"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1154"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1156"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1158"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1160"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1162"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1164"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<g
|
||||||
|
style="fill:#ffffff"
|
||||||
|
id="g1166"
|
||||||
|
transform="matrix(0.78124721,0,0,0.78124721,107.12096,160.74809)" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 344.3189,392.83707 c -4.60362,-2.75958 -5.36974,-9.69605 -1.45595,-13.18226 0.54459,-0.48508 5.34567,-3.07035 10.66909,-5.74503 7.5498,-3.79328 10.16725,-4.86303 11.89884,-4.86303 1.73503,0 4.42542,1.10391 12.3172,5.05396 11.72559,5.86898 12.60994,6.68326 12.60994,11.61118 0,3.40408 -0.99553,5.20819 -4.00363,7.25549 -3.08358,2.09867 -5.44113,1.68547 -13.60905,-2.38528 l -7.19926,-3.58796 -7.37198,3.59617 c -8.3911,4.09331 -10.26721,4.39753 -13.8552,2.24676 z"
|
||||||
|
id="path944" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 285.98437,367.98056 c -3.86343,-2.35557 -5.1524,-8.06518 -2.66781,-11.81734 1.64304,-2.48125 20.719,-12.23981 23.92632,-12.23981 1.56364,0 4.61398,1.26582 12.2153,5.06905 8.53551,4.27064 10.3157,5.36752 11.30239,6.96403 1.75651,2.84207 1.95178,5.62136 0.58856,8.37633 -1.52635,3.08463 -3.36973,4.32306 -6.86644,4.61304 -2.68142,0.22236 -3.36743,-0.003 -10.22731,-3.35873 l -7.35311,-3.59707 -7.04119,3.52834 c -7.90523,3.96133 -10.62609,4.44409 -13.87671,2.46216 z"
|
||||||
|
id="path946" />
|
||||||
|
<path
|
||||||
|
style="fill:#ef5350;fill-opacity:1;stroke:none;stroke-width:5.18208;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 228.11707,393.18031 c -1.0244,-0.54435 -2.42484,-1.80721 -3.11209,-2.80633 -1.05812,-1.53828 -1.2181,-2.32693 -1.04433,-5.14815 0.29039,-4.71472 1.41139,-5.70783 12.90113,-11.42937 7.71258,-3.84061 9.99443,-4.74971 11.92193,-4.74971 1.94819,0 4.22735,0.92952 12.47354,5.08716 8.66324,4.3679 10.26522,5.3693 11.33052,7.08263 3.53608,5.68714 -0.55313,12.95355 -7.28968,12.95355 -1.25225,0 -4.29453,-1.20187 -9.08226,-3.58799 l -7.19927,-3.58796 -7.37197,3.59617 c -8.07507,3.93914 -10.21699,4.34922 -13.52752,2.59 z"
|
||||||
|
id="path948" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 13 KiB |
6
.idea/render.experimental.xml
generated
6
.idea/render.experimental.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="RenderSettings">
|
|
||||||
<option name="quality" value="0.25" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
31
README.md
31
README.md
@@ -1,8 +1,8 @@
|
|||||||
# Kotatsu
|
# Kotatsu
|
||||||
|
|
||||||
Kotatsu is a free and open source manga reader for Android.
|
Kotatsu is a free and open source manga reader for Android.
|
||||||
|
|
||||||
   [](https://hosted.weblate.org/engage/kotatsu/) [](http://4pda.ru/forum/index.php?showtopic=697669) [](https://discord.gg/NNJ5RgVBC5)
|
   [](https://hosted.weblate.org/engage/kotatsu/) [](http://4pda.ru/forum/index.php?showtopic=697669) [](https://discord.gg/NNJ5RgVBC5)
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
@@ -10,16 +10,15 @@ Kotatsu is a free and open source manga reader for Android.
|
|||||||
alt="Get it on F-Droid"
|
alt="Get it on F-Droid"
|
||||||
height="80">](https://f-droid.org/packages/org.koitharu.kotatsu)
|
height="80">](https://f-droid.org/packages/org.koitharu.kotatsu)
|
||||||
|
|
||||||
Download APK from Github Releases:
|
Download APK from GitHub Releases:
|
||||||
|
|
||||||
- [Latest release](https://github.com/nv95/Kotatsu/releases/latest)
|
- [Latest release](https://github.com/KotatsuApp/Kotatsu/releases/latest)
|
||||||
- [Legacy build](https://github.com/nv95/Kotatsu/releases/tag/v0.4-legacy) (with Android 4.1+ support)
|
|
||||||
|
|
||||||
### Main Features
|
### Main Features
|
||||||
|
|
||||||
* Online manga catalogues
|
* Online manga catalogues
|
||||||
* Search manga by name and genre
|
* Search manga by name and genres
|
||||||
* Reading history
|
* Reading history and bookmarks
|
||||||
* Favourites organized by user-defined categories
|
* Favourites organized by user-defined categories
|
||||||
* Downloading manga and reading it offline. Third-party CBZ archives also supported
|
* Downloading manga and reading it offline. Third-party CBZ archives also supported
|
||||||
* Tablet-optimized material design UI
|
* Tablet-optimized material design UI
|
||||||
@@ -30,12 +29,12 @@ Download APK from Github Releases:
|
|||||||
|
|
||||||
### Screenshots
|
### Screenshots
|
||||||
|
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
|
|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
|  |  |
|
|  |  |
|
||||||
|-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
|
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
|
||||||
|
|
||||||
### Localization
|
### Localization
|
||||||
|
|
||||||
@@ -43,16 +42,18 @@ Download APK from Github Releases:
|
|||||||
<img src="https://hosted.weblate.org/widgets/kotatsu/-/287x66-white.png" alt="Translation status" />
|
<img src="https://hosted.weblate.org/widgets/kotatsu/-/287x66-white.png" alt="Translation status" />
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
Kotatsu is localized in a number of different languages, if you would like to help improve these or add new languages, please head over to the Weblate <a href="https://hosted.weblate.org/engage/kotatsu/">project page</a>
|
Kotatsu is localized in a number of different languages, if you would like to help improve these or add new languages,
|
||||||
|
please head over to the Weblate <a href="https://hosted.weblate.org/engage/kotatsu/">project page</a>
|
||||||
|
|
||||||
### License
|
### License
|
||||||
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
|
||||||
|
[](http://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||||
|
|
||||||
Kotatsu is Free Software: You can use, study share and improve it at your
|
Kotatsu is Free Software: You can use, study share and improve it at your
|
||||||
will. Specifically you can redistribute and/or modify it under the terms of the
|
will. Specifically you can redistribute and/or modify it under the terms of the
|
||||||
[GNU General Public License](https://www.gnu.org/licenses/gpl.html) as
|
[GNU General Public License](https://www.gnu.org/licenses/gpl.html) as
|
||||||
published by the Free Software Foundation, either version 3 of the License, or
|
published by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
### Disclaimer
|
### Disclaimer
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ android {
|
|||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 32
|
targetSdkVersion 32
|
||||||
versionCode 409
|
versionCode 412
|
||||||
versionName '3.3'
|
versionName '3.4'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@@ -24,6 +24,10 @@ android {
|
|||||||
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
arg 'room.schemaLocation', "$projectDir/schemas".toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// define this values in your local.properties file
|
||||||
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_ID', "\"${localProperty('shikimori.clientId')}\""
|
||||||
|
buildConfigField 'String', 'SHIKIMORI_CLIENT_SECRET', "\"${localProperty('shikimori.clientSecret')}\""
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
@@ -64,40 +68,46 @@ android {
|
|||||||
unitTests.returnDefaultValues = false
|
unitTests.returnDefaultValues = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
afterEvaluate {
|
||||||
|
compileDebugKotlin {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += ['-opt-in=org.koitharu.kotatsu.parsers.InternalParsersApi']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||||
implementation('com.github.nv95:kotatsu-parsers:f46c5add46') {
|
implementation('com.github.nv95:kotatsu-parsers:da3b0ae0cf') {
|
||||||
exclude group: 'org.json', module: 'json'
|
exclude group: 'org.json', module: 'json'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1'
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.3'
|
||||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
|
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.7.0'
|
implementation 'androidx.core:core-ktx:1.8.0'
|
||||||
implementation 'androidx.activity:activity-ktx:1.4.0'
|
implementation 'androidx.activity:activity-ktx:1.5.0'
|
||||||
implementation 'androidx.fragment:fragment-ktx:1.4.1'
|
implementation 'androidx.fragment:fragment-ktx:1.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-service:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-service:2.4.1'
|
implementation 'androidx.lifecycle:lifecycle-process:2.5.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-process:2.4.1'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
|
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
|
||||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||||
implementation 'androidx.work:work-runtime-ktx:2.7.1'
|
implementation 'androidx.work:work-runtime-ktx:2.7.1'
|
||||||
implementation 'com.google.android.material:material:1.7.0-alpha01'
|
implementation 'androidx.biometric:biometric-ktx:1.2.0-alpha04'
|
||||||
|
implementation 'com.google.android.material:material:1.7.0-alpha02'
|
||||||
//noinspection LifecycleAnnotationProcessorWithJava8
|
//noinspection LifecycleAnnotationProcessorWithJava8
|
||||||
kapt 'androidx.lifecycle:lifecycle-compiler:2.4.1'
|
kapt 'androidx.lifecycle:lifecycle-compiler:2.5.0'
|
||||||
|
|
||||||
implementation 'androidx.room:room-runtime:2.4.2'
|
implementation 'androidx.room:room-runtime:2.4.2'
|
||||||
implementation 'androidx.room:room-ktx:2.4.2'
|
implementation 'androidx.room:room-ktx:2.4.2'
|
||||||
kapt 'androidx.room:room-compiler:2.4.2'
|
kapt 'androidx.room:room-compiler:2.4.2'
|
||||||
|
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
|
||||||
implementation 'com.squareup.okio:okio:3.1.0'
|
implementation 'com.squareup.okio:okio:3.2.0'
|
||||||
|
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl:4.3.2'
|
||||||
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'
|
implementation 'com.hannesdorfmann:adapterdelegates4-kotlin-dsl-viewbinding:4.3.2'
|
||||||
@@ -107,15 +117,24 @@ dependencies {
|
|||||||
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
|
||||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||||
|
|
||||||
|
implementation 'ch.acra:acra-mail:5.9.3'
|
||||||
|
implementation 'ch.acra:acra-dialog:5.9.3'
|
||||||
|
|
||||||
|
debugImplementation 'org.jsoup:jsoup:1.15.1'
|
||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.3'
|
||||||
testImplementation 'io.insert-koin:koin-test-junit4:3.2.0'
|
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||||
androidTestImplementation 'androidx.test:rules:1.4.0'
|
androidTestImplementation 'androidx.test:rules:1.4.0'
|
||||||
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
|
androidTestImplementation 'androidx.test:core-ktx:1.4.0'
|
||||||
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
|
||||||
|
|
||||||
|
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.3'
|
||||||
|
androidTestImplementation 'io.insert-koin:koin-test:3.2.0'
|
||||||
|
androidTestImplementation 'io.insert-koin:koin-test-junit4:3.2.0'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.room:room-testing:2.4.2'
|
androidTestImplementation 'androidx.room:room-testing:2.4.2'
|
||||||
|
androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.13.0'
|
||||||
}
|
}
|
||||||
163
app/src/androidTest/assets/manga/bad_ids.json
Normal file
163
app/src/androidTest/assets/manga/bad_ids.json
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 1552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
36
app/src/androidTest/assets/manga/empty.json
Normal file
36
app/src/androidTest/assets/manga/empty.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
136
app/src/androidTest/assets/manga/first_chapters.json
Normal file
136
app/src/androidTest/assets/manga/first_chapters.json
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
163
app/src/androidTest/assets/manga/full.json
Normal file
163
app/src/androidTest/assets/manga/full.json
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541665,
|
||||||
|
"name": "2 - 1",
|
||||||
|
"number": 6,
|
||||||
|
"url": "/stranstviia_emanon/vol2/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1415570400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
154
app/src/androidTest/assets/manga/without_middle_chapter.json
Normal file
154
app/src/androidTest/assets/manga/without_middle_chapter.json
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
{
|
||||||
|
"id": -2096681732556647985,
|
||||||
|
"title": "Странствия Эманон",
|
||||||
|
"url": "/stranstviia_emanon",
|
||||||
|
"publicUrl": "https://readmanga.io/stranstviia_emanon",
|
||||||
|
"rating": 0.9400894,
|
||||||
|
"isNsfw": true,
|
||||||
|
"coverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_p.jpg",
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"title": "Сверхъестественное",
|
||||||
|
"key": "supernatural",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Сэйнэн",
|
||||||
|
"key": "seinen",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Повседневность",
|
||||||
|
"key": "slice_of_life",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Приключения",
|
||||||
|
"key": "adventure",
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"state": "FINISHED",
|
||||||
|
"largeCoverUrl": "https://staticrm.rmr.rocks/uploads/pics/01/12/559_o.jpg",
|
||||||
|
"description": "Продолжение истории о загадочной девушке по имени Эманон, которая помнит всё, что происходило на Земле за последние три миллиарда лет. \n<br>Начало истории читайте в \"Воспоминаниях Эманон\". \n<div class=\"clearfix\"></div>",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"id": 3552943969433540704,
|
||||||
|
"name": "1 - 1",
|
||||||
|
"number": 1,
|
||||||
|
"url": "/stranstviia_emanon/vol1/1",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540705,
|
||||||
|
"name": "1 - 2",
|
||||||
|
"number": 2,
|
||||||
|
"url": "/stranstviia_emanon/vol1/2",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540706,
|
||||||
|
"name": "1 - 3",
|
||||||
|
"number": 3,
|
||||||
|
"url": "/stranstviia_emanon/vol1/3",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540707,
|
||||||
|
"name": "1 - 4",
|
||||||
|
"number": 4,
|
||||||
|
"url": "/stranstviia_emanon/vol1/4",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433540708,
|
||||||
|
"name": "1 - 5",
|
||||||
|
"number": 5,
|
||||||
|
"url": "/stranstviia_emanon/vol1/5",
|
||||||
|
"scanlator": "Sad-Robot",
|
||||||
|
"uploadDate": 1342731600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541666,
|
||||||
|
"name": "2 - 2",
|
||||||
|
"number": 7,
|
||||||
|
"url": "/stranstviia_emanon/vol2/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1419976800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541667,
|
||||||
|
"name": "2 - 3",
|
||||||
|
"number": 8,
|
||||||
|
"url": "/stranstviia_emanon/vol2/3",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1427922000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541668,
|
||||||
|
"name": "2 - 4",
|
||||||
|
"number": 9,
|
||||||
|
"url": "/stranstviia_emanon/vol2/4",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1436907600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541669,
|
||||||
|
"name": "2 - 5",
|
||||||
|
"number": 10,
|
||||||
|
"url": "/stranstviia_emanon/vol2/5",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1446674400000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433541670,
|
||||||
|
"name": "2 - 6",
|
||||||
|
"number": 11,
|
||||||
|
"url": "/stranstviia_emanon/vol2/6",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1451512800000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542626,
|
||||||
|
"name": "3 - 1",
|
||||||
|
"number": 12,
|
||||||
|
"url": "/stranstviia_emanon/vol3/1",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542627,
|
||||||
|
"name": "3 - 2",
|
||||||
|
"number": 13,
|
||||||
|
"url": "/stranstviia_emanon/vol3/2",
|
||||||
|
"scanlator": "Sup!",
|
||||||
|
"uploadDate": 1461618000000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3552943969433542628,
|
||||||
|
"name": "3 - 3",
|
||||||
|
"number": 14,
|
||||||
|
"url": "/stranstviia_emanon/vol3/3",
|
||||||
|
"scanlator": "",
|
||||||
|
"uploadDate": 1465851600000,
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": "READMANGA_RU"
|
||||||
|
}
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
package org.koitharu.kotatsu.core.db
|
package org.koitharu.kotatsu.core.db
|
||||||
|
|
||||||
import androidx.room.testing.MigrationTestHelper
|
import androidx.room.testing.MigrationTestHelper
|
||||||
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import java.io.IOException
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.koitharu.kotatsu.core.db.migrations.*
|
import org.koitharu.kotatsu.core.db.migrations.*
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class MangaDatabaseTest {
|
class MangaDatabaseTest {
|
||||||
@@ -16,8 +15,7 @@ class MangaDatabaseTest {
|
|||||||
@get:Rule
|
@get:Rule
|
||||||
val helper: MigrationTestHelper = MigrationTestHelper(
|
val helper: MigrationTestHelper = MigrationTestHelper(
|
||||||
InstrumentationRegistry.getInstrumentation(),
|
InstrumentationRegistry.getInstrumentation(),
|
||||||
MangaDatabase::class.java.canonicalName,
|
MangaDatabase::class.java,
|
||||||
FrameworkSQLiteOpenHelperFactory()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -37,7 +35,6 @@ class MangaDatabaseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
|
||||||
const val TEST_DB = "test-db"
|
const val TEST_DB = "test-db"
|
||||||
@@ -50,6 +47,9 @@ class MangaDatabaseTest {
|
|||||||
Migration5To6(),
|
Migration5To6(),
|
||||||
Migration6To7(),
|
Migration6To7(),
|
||||||
Migration7To8(),
|
Migration7To8(),
|
||||||
|
Migration8To9(),
|
||||||
|
Migration9To10(),
|
||||||
|
Migration10To11(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package org.koitharu.kotatsu.tracker.domain
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import com.squareup.moshi.Moshi
|
||||||
|
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import okio.buffer
|
||||||
|
import okio.source
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.koin.test.KoinTest
|
||||||
|
import org.koin.test.inject
|
||||||
|
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||||
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class TrackerTest : KoinTest {
|
||||||
|
|
||||||
|
private val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||||
|
private val mangaAdapter = moshi.adapter(Manga::class.java)
|
||||||
|
private val historyRegistry by inject<HistoryRepository>()
|
||||||
|
private val repository by inject<TrackingRepository>()
|
||||||
|
private val dataRepository by inject<MangaDataRepository>()
|
||||||
|
private val tracker by inject<Tracker>()
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun noUpdates() = runTest {
|
||||||
|
val manga = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(manga.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(manga, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(manga.id))
|
||||||
|
tracker.checkUpdates(manga, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(manga.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun hasUpdates() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun badIds() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaBad = loadManga("bad_ids.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaBad, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun badIds2() = runTest {
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaBad = loadManga("bad_ids.json")
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
tracker.deleteTrack(mangaFirst.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaBad, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun fullReset() = runTest {
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
val mangaEmpty = loadManga("empty.json")
|
||||||
|
tracker.deleteTrack(mangaFull.id)
|
||||||
|
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaEmpty, commit = true).apply {
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
tracker.checkUpdates(mangaEmpty, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFull.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun syncWithHistory() = runTest {
|
||||||
|
val mangaFull = loadManga("full.json")
|
||||||
|
val mangaFirst = loadManga("first_chapters.json")
|
||||||
|
tracker.deleteTrack(mangaFull.id)
|
||||||
|
|
||||||
|
tracker.checkUpdates(mangaFirst, commit = true).apply {
|
||||||
|
assertFalse(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(0, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assertEquals(3, newChapters.size)
|
||||||
|
}
|
||||||
|
assertEquals(3, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
|
||||||
|
val chapter = requireNotNull(mangaFull.chapters).run { get(lastIndex - 1) }
|
||||||
|
repository.syncWithHistory(mangaFull, chapter.id)
|
||||||
|
|
||||||
|
assertEquals(1, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
tracker.checkUpdates(mangaFull, commit = true).apply {
|
||||||
|
assertTrue(isValid)
|
||||||
|
assert(newChapters.isEmpty())
|
||||||
|
}
|
||||||
|
assertEquals(1, repository.getNewChaptersCount(mangaFirst.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun loadManga(name: String): Manga {
|
||||||
|
val assets = InstrumentationRegistry.getInstrumentation().context.assets
|
||||||
|
val manga = assets.open("manga/$name").use {
|
||||||
|
mangaAdapter.fromJson(it.source().buffer())
|
||||||
|
} ?: throw RuntimeException("Cannot read manga from json \"$name\"")
|
||||||
|
dataRepository.storeManga(manga)
|
||||||
|
return manga
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@ class DummyParser(override val context: MangaLoaderContext) : MangaParser(MangaS
|
|||||||
offset: Int,
|
offset: Int,
|
||||||
query: String?,
|
query: String?,
|
||||||
tags: Set<MangaTag>?,
|
tags: Set<MangaTag>?,
|
||||||
sortOrder: SortOrder?
|
sortOrder: SortOrder,
|
||||||
): List<Manga> {
|
): List<Manga> {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="org.koitharu.kotatsu.KotatsuApp"
|
android:name="org.koitharu.kotatsu.KotatsuApp"
|
||||||
@@ -58,7 +59,15 @@
|
|||||||
android:label="@string/search_manga" />
|
android:label="@string/search_manga" />
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
android:name="org.koitharu.kotatsu.settings.SettingsActivity"
|
||||||
android:label="@string/settings" />
|
android:exported="true"
|
||||||
|
android:label="@string/settings">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="kotatsu" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.browser.BrowserActivity"
|
android:name="org.koitharu.kotatsu.browser.BrowserActivity"
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
@@ -67,11 +76,6 @@
|
|||||||
android:name="org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity"
|
android:name="org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity"
|
||||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize" />
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.core.ui.CrashActivity"
|
|
||||||
android:label="@string/error_occurred"
|
|
||||||
android:theme="@android:style/Theme.DeviceDefault"
|
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity"
|
android:name="org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity"
|
||||||
android:label="@string/favourites_categories"
|
android:label="@string/favourites_categories"
|
||||||
@@ -85,9 +89,6 @@
|
|||||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name="org.koitharu.kotatsu.search.ui.global.GlobalSearchActivity"
|
|
||||||
android:label="@string/search" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity"
|
android:name="org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity"
|
||||||
android:label="@string/search" />
|
android:label="@string/search" />
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
package org.koitharu.kotatsu
|
package org.koitharu.kotatsu
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.Context
|
||||||
import android.os.StrictMode
|
import android.os.StrictMode
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.fragment.app.strictmode.FragmentStrictMode
|
import androidx.fragment.app.strictmode.FragmentStrictMode
|
||||||
|
import org.acra.ReportField
|
||||||
|
import org.acra.config.dialog
|
||||||
|
import org.acra.config.mailSender
|
||||||
|
import org.acra.data.StringFormat
|
||||||
|
import org.acra.ktx.initAcra
|
||||||
import org.koin.android.ext.android.get
|
import org.koin.android.ext.android.get
|
||||||
import org.koin.android.ext.koin.androidContext
|
import org.koin.android.ext.koin.androidContext
|
||||||
import org.koin.core.context.startKoin
|
import org.koin.core.context.startKoin
|
||||||
@@ -13,7 +19,6 @@ import org.koitharu.kotatsu.core.db.databaseModule
|
|||||||
import org.koitharu.kotatsu.core.github.githubModule
|
import org.koitharu.kotatsu.core.github.githubModule
|
||||||
import org.koitharu.kotatsu.core.network.networkModule
|
import org.koitharu.kotatsu.core.network.networkModule
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.core.ui.AppCrashHandler
|
|
||||||
import org.koitharu.kotatsu.core.ui.uiModule
|
import org.koitharu.kotatsu.core.ui.uiModule
|
||||||
import org.koitharu.kotatsu.details.detailsModule
|
import org.koitharu.kotatsu.details.detailsModule
|
||||||
import org.koitharu.kotatsu.favourites.favouritesModule
|
import org.koitharu.kotatsu.favourites.favouritesModule
|
||||||
@@ -26,6 +31,7 @@ import org.koitharu.kotatsu.main.ui.protect.AppProtectHelper
|
|||||||
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
import org.koitharu.kotatsu.parsers.MangaLoaderContext
|
||||||
import org.koitharu.kotatsu.reader.readerModule
|
import org.koitharu.kotatsu.reader.readerModule
|
||||||
import org.koitharu.kotatsu.remotelist.remoteListModule
|
import org.koitharu.kotatsu.remotelist.remoteListModule
|
||||||
|
import org.koitharu.kotatsu.scrobbling.shikimori.shikimoriModule
|
||||||
import org.koitharu.kotatsu.search.searchModule
|
import org.koitharu.kotatsu.search.searchModule
|
||||||
import org.koitharu.kotatsu.settings.settingsModule
|
import org.koitharu.kotatsu.settings.settingsModule
|
||||||
import org.koitharu.kotatsu.suggestions.suggestionsModule
|
import org.koitharu.kotatsu.suggestions.suggestionsModule
|
||||||
@@ -41,7 +47,6 @@ class KotatsuApp : Application() {
|
|||||||
enableStrictMode()
|
enableStrictMode()
|
||||||
}
|
}
|
||||||
initKoin()
|
initKoin()
|
||||||
Thread.setDefaultUncaughtExceptionHandler(AppCrashHandler(applicationContext))
|
|
||||||
AppCompatDelegate.setDefaultNightMode(get<AppSettings>().theme)
|
AppCompatDelegate.setDefaultNightMode(get<AppSettings>().theme)
|
||||||
registerActivityLifecycleCallbacks(get<AppProtectHelper>())
|
registerActivityLifecycleCallbacks(get<AppProtectHelper>())
|
||||||
registerActivityLifecycleCallbacks(get<ActivityRecreationHandle>())
|
registerActivityLifecycleCallbacks(get<ActivityRecreationHandle>())
|
||||||
@@ -70,11 +75,43 @@ class KotatsuApp : Application() {
|
|||||||
readerModule,
|
readerModule,
|
||||||
appWidgetModule,
|
appWidgetModule,
|
||||||
suggestionsModule,
|
suggestionsModule,
|
||||||
|
shikimoriModule,
|
||||||
bookmarksModule,
|
bookmarksModule,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(base: Context?) {
|
||||||
|
super.attachBaseContext(base)
|
||||||
|
initAcra {
|
||||||
|
buildConfigClass = BuildConfig::class.java
|
||||||
|
reportFormat = StringFormat.KEY_VALUE_LIST
|
||||||
|
reportContent = listOf(
|
||||||
|
ReportField.PACKAGE_NAME,
|
||||||
|
ReportField.APP_VERSION_CODE,
|
||||||
|
ReportField.APP_VERSION_NAME,
|
||||||
|
ReportField.ANDROID_VERSION,
|
||||||
|
ReportField.PHONE_MODEL,
|
||||||
|
ReportField.CRASH_CONFIGURATION,
|
||||||
|
ReportField.STACK_TRACE,
|
||||||
|
ReportField.CUSTOM_DATA,
|
||||||
|
ReportField.SHARED_PREFERENCES,
|
||||||
|
)
|
||||||
|
dialog {
|
||||||
|
text = getString(R.string.crash_text)
|
||||||
|
title = getString(R.string.error_occurred)
|
||||||
|
positiveButtonText = getString(R.string.send)
|
||||||
|
resIcon = R.drawable.ic_alert_outline
|
||||||
|
resTheme = android.R.style.Theme_Material_Light_Dialog_Alert
|
||||||
|
}
|
||||||
|
mailSender {
|
||||||
|
mailTo = getString(R.string.email_error_report)
|
||||||
|
reportAsFile = true
|
||||||
|
reportFileName = "stacktrace.txt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun enableStrictMode() {
|
private fun enableStrictMode() {
|
||||||
StrictMode.setThreadPolicy(
|
StrictMode.setThreadPolicy(
|
||||||
StrictMode.ThreadPolicy.Builder()
|
StrictMode.ThreadPolicy.Builder()
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract class BaseBottomSheet<B : ViewBinding> : BottomSheetDialogFragment() {
|
|||||||
requireContext().displayCompat?.let {
|
requireContext().displayCompat?.let {
|
||||||
val metrics = DisplayMetrics()
|
val metrics = DisplayMetrics()
|
||||||
it.getRealMetrics(metrics)
|
it.getRealMetrics(metrics)
|
||||||
behavior?.peekHeight = metrics.heightPixels / 2
|
behavior?.peekHeight = (metrics.heightPixels * 0.4).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
@@ -60,6 +60,15 @@ abstract class BaseBottomSheet<B : ViewBinding> : BottomSheetDialogFragment() {
|
|||||||
return AppBottomSheetDialog(requireContext(), theme)
|
return AppBottomSheetDialog(requireContext(), theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun addBottomSheetCallback(callback: BottomSheetBehavior.BottomSheetCallback) {
|
||||||
|
val b = behavior ?: return
|
||||||
|
b.addBottomSheetCallback(callback)
|
||||||
|
val rootView = dialog?.findViewById<View>(materialR.id.design_bottom_sheet)
|
||||||
|
if (rootView != null) {
|
||||||
|
callback.onStateChanged(rootView, b.state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
protected abstract fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): B
|
||||||
|
|
||||||
protected fun setExpanded(isExpanded: Boolean, isLocked: Boolean) {
|
protected fun setExpanded(isExpanded: Boolean, isLocked: Boolean) {
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import androidx.annotation.CallSuper
|
|||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import org.koitharu.kotatsu.base.ui.util.RecyclerViewOwner
|
import org.koitharu.kotatsu.base.ui.util.RecyclerViewOwner
|
||||||
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
import org.koitharu.kotatsu.base.ui.util.WindowInsetsDelegate
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.settings.SettingsActivity
|
|
||||||
import org.koitharu.kotatsu.settings.SettingsHeadersFragment
|
import org.koitharu.kotatsu.settings.SettingsHeadersFragment
|
||||||
|
|
||||||
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
abstract class BasePreferenceFragment(@StringRes private val titleId: Int) :
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.dialog
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.text.InputFilter
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import org.koitharu.kotatsu.databinding.DialogInputBinding
|
|
||||||
|
|
||||||
class TextInputDialog private constructor(
|
|
||||||
private val delegate: AlertDialog,
|
|
||||||
) : DialogInterface by delegate {
|
|
||||||
|
|
||||||
fun show() = delegate.show()
|
|
||||||
|
|
||||||
class Builder(context: Context) {
|
|
||||||
|
|
||||||
private val binding = DialogInputBinding.inflate(LayoutInflater.from(context))
|
|
||||||
|
|
||||||
private val delegate = MaterialAlertDialogBuilder(context)
|
|
||||||
.setView(binding.root)
|
|
||||||
|
|
||||||
fun setTitle(@StringRes titleResId: Int): Builder {
|
|
||||||
delegate.setTitle(titleResId)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setTitle(title: CharSequence): Builder {
|
|
||||||
delegate.setTitle(title)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setHint(@StringRes hintResId: Int): Builder {
|
|
||||||
binding.inputEdit.hint = binding.root.context.getString(hintResId)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setMaxLength(maxLength: Int, strict: Boolean): Builder {
|
|
||||||
with(binding.inputLayout) {
|
|
||||||
counterMaxLength = maxLength
|
|
||||||
isCounterEnabled = maxLength > 0
|
|
||||||
}
|
|
||||||
if (strict && maxLength > 0) {
|
|
||||||
binding.inputEdit.filters += InputFilter.LengthFilter(maxLength)
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setInputType(inputType: Int): Builder {
|
|
||||||
binding.inputEdit.inputType = inputType
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setText(text: String): Builder {
|
|
||||||
binding.inputEdit.setText(text)
|
|
||||||
binding.inputEdit.setSelection(text.length)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setPositiveButton(
|
|
||||||
@StringRes textId: Int,
|
|
||||||
listener: (DialogInterface, String) -> Unit
|
|
||||||
): Builder {
|
|
||||||
delegate.setPositiveButton(textId) { dialog, _ ->
|
|
||||||
listener(dialog, binding.inputEdit.text?.toString().orEmpty())
|
|
||||||
}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNegativeButton(
|
|
||||||
@StringRes textId: Int,
|
|
||||||
listener: DialogInterface.OnClickListener? = null
|
|
||||||
): Builder {
|
|
||||||
delegate.setNegativeButton(textId, listener)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnCancelListener(listener: DialogInterface.OnCancelListener): Builder {
|
|
||||||
delegate.setOnCancelListener(listener)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun create() =
|
|
||||||
TextInputDialog(delegate.create())
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.list
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.view.ActionMode
|
||||||
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.LifecycleEventObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import androidx.savedstate.SavedStateRegistry
|
||||||
|
import androidx.savedstate.SavedStateRegistryOwner
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.decor.AbstractSelectionItemDecoration
|
||||||
|
import kotlin.coroutines.EmptyCoroutineContext
|
||||||
|
|
||||||
|
private const val KEY_SELECTION = "selection"
|
||||||
|
private const val PROVIDER_NAME = "selection_decoration"
|
||||||
|
|
||||||
|
class ListSelectionController(
|
||||||
|
private val activity: Activity,
|
||||||
|
private val decoration: AbstractSelectionItemDecoration,
|
||||||
|
private val registryOwner: SavedStateRegistryOwner,
|
||||||
|
private val callback: Callback,
|
||||||
|
) : ActionMode.Callback, SavedStateRegistry.SavedStateProvider {
|
||||||
|
|
||||||
|
private var actionMode: ActionMode? = null
|
||||||
|
private val stateEventObserver = StateEventObserver()
|
||||||
|
|
||||||
|
val count: Int
|
||||||
|
get() = decoration.checkedItemsCount
|
||||||
|
|
||||||
|
fun snapshot(): Set<Long> {
|
||||||
|
return peekCheckedIds().toSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun peekCheckedIds(): Set<Long> {
|
||||||
|
return decoration.checkedItemsIds
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear() {
|
||||||
|
decoration.clearSelection()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addAll(ids: Collection<Long>) {
|
||||||
|
if (ids.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoration.checkAll(ids)
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun attachToRecyclerView(recyclerView: RecyclerView) {
|
||||||
|
recyclerView.addItemDecoration(decoration)
|
||||||
|
registryOwner.lifecycle.addObserver(stateEventObserver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun saveState(): Bundle {
|
||||||
|
val bundle = Bundle(1)
|
||||||
|
bundle.putLongArray(KEY_SELECTION, peekCheckedIds().toLongArray())
|
||||||
|
return bundle
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemClick(id: Long): Boolean {
|
||||||
|
if (decoration.checkedItemsCount != 0) {
|
||||||
|
decoration.toggleItemChecked(id)
|
||||||
|
if (decoration.checkedItemsCount == 0) {
|
||||||
|
actionMode?.finish()
|
||||||
|
} else {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
}
|
||||||
|
notifySelectionChanged()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onItemLongClick(id: Long): Boolean {
|
||||||
|
startActionMode()
|
||||||
|
return actionMode?.also {
|
||||||
|
decoration.setItemIsChecked(id, true)
|
||||||
|
notifySelectionChanged()
|
||||||
|
} != null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onCreateActionMode(mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
|
return callback.onPrepareActionMode(mode, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
|
return callback.onActionItemClicked(mode, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode) {
|
||||||
|
callback.onDestroyActionMode(mode)
|
||||||
|
clear()
|
||||||
|
actionMode = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startActionMode() {
|
||||||
|
if (actionMode == null) {
|
||||||
|
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun notifySelectionChanged() {
|
||||||
|
val count = decoration.checkedItemsCount
|
||||||
|
callback.onSelectionChanged(count)
|
||||||
|
if (count == 0) {
|
||||||
|
actionMode?.finish()
|
||||||
|
} else {
|
||||||
|
actionMode?.invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreState(ids: Collection<Long>) {
|
||||||
|
if (ids.isEmpty() || decoration.checkedItemsCount != 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
decoration.checkAll(ids)
|
||||||
|
startActionMode()
|
||||||
|
notifySelectionChanged()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Callback : ActionMode.Callback {
|
||||||
|
|
||||||
|
fun onSelectionChanged(count: Int)
|
||||||
|
|
||||||
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean
|
||||||
|
|
||||||
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean
|
||||||
|
|
||||||
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean
|
||||||
|
|
||||||
|
override fun onDestroyActionMode(mode: ActionMode) = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class StateEventObserver : LifecycleEventObserver {
|
||||||
|
|
||||||
|
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||||
|
if (event == Lifecycle.Event.ON_CREATE) {
|
||||||
|
val registry = registryOwner.savedStateRegistry
|
||||||
|
registry.registerSavedStateProvider(PROVIDER_NAME, this@ListSelectionController)
|
||||||
|
val state = registry.consumeRestoredStateForKey(PROVIDER_NAME)
|
||||||
|
if (state != null) {
|
||||||
|
Dispatchers.Main.dispatch(EmptyCoroutineContext) { // == Handler.post
|
||||||
|
if (source.lifecycle.currentState.isAtLeast(Lifecycle.State.CREATED)) {
|
||||||
|
restoreState(state.getLongArray(KEY_SELECTION)?.toList().orEmpty())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ abstract class AbstractSelectionItemDecoration : RecyclerView.ItemDecoration() {
|
|||||||
|
|
||||||
private val bounds = Rect()
|
private val bounds = Rect()
|
||||||
private val boundsF = RectF()
|
private val boundsF = RectF()
|
||||||
private val selection = HashSet<Long>()
|
protected val selection = HashSet<Long>()
|
||||||
|
|
||||||
protected var hasBackground: Boolean = true
|
protected var hasBackground: Boolean = true
|
||||||
protected var hasForeground: Boolean = false
|
protected var hasForeground: Boolean = false
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ class WindowInsetsDelegate(
|
|||||||
|
|
||||||
private var lastInsets: Insets? = null
|
private var lastInsets: Insets? = null
|
||||||
|
|
||||||
override fun onApplyWindowInsets(v: View?, insets: WindowInsetsCompat?): WindowInsetsCompat? {
|
override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat {
|
||||||
if (insets == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
val handledInsets = interceptingWindowInsetsListener?.onApplyWindowInsets(v, insets) ?: insets
|
val handledInsets = interceptingWindowInsetsListener?.onApplyWindowInsets(v, insets) ?: insets
|
||||||
val newInsets = if (handleImeInsets) {
|
val newInsets = if (handleImeInsets) {
|
||||||
Insets.max(
|
Insets.max(
|
||||||
@@ -49,7 +46,7 @@ class WindowInsetsDelegate(
|
|||||||
) {
|
) {
|
||||||
view.removeOnLayoutChangeListener(this)
|
view.removeOnLayoutChangeListener(this)
|
||||||
if (lastInsets == null) { // Listener may not be called
|
if (lastInsets == null) { // Listener may not be called
|
||||||
onApplyWindowInsets(view, ViewCompat.getRootWindowInsets(view))
|
onApplyWindowInsets(view, ViewCompat.getRootWindowInsets(view) ?: return)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,19 +17,28 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import android.widget.TextView
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
import androidx.core.view.postDelayed
|
import androidx.core.view.postDelayed
|
||||||
import org.koitharu.kotatsu.R
|
import com.google.android.material.color.MaterialColors
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
|
import com.google.android.material.shape.ShapeAppearanceModel
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import org.koitharu.kotatsu.databinding.FadingSnackbarLayoutBinding
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getThemeColorStateList
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
private const val ENTER_DURATION = 300L
|
private const val ENTER_DURATION = 300L
|
||||||
private const val EXIT_DURATION = 200L
|
private const val EXIT_DURATION = 200L
|
||||||
private const val SHORT_DURATION = 1_500L
|
private const val SHORT_DURATION_MS = 1_500L
|
||||||
private const val LONG_DURATION = 2_750L
|
private const val LONG_DURATION_MS = 2_750L
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom snackbar implementation allowing more control over placement and entry/exit animations.
|
* A custom snackbar implementation allowing more control over placement and entry/exit animations.
|
||||||
*
|
*
|
||||||
@@ -40,16 +49,13 @@ private const val LONG_DURATION = 2_750L
|
|||||||
class FadingSnackbar @JvmOverloads constructor(
|
class FadingSnackbar @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0
|
defStyleAttr: Int = 0,
|
||||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
) : FrameLayout(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
private val message: TextView
|
private val binding = FadingSnackbarLayoutBinding.inflate(LayoutInflater.from(context), this)
|
||||||
private val action: Button
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val view = LayoutInflater.from(context).inflate(R.layout.fading_snackbar_layout, this, true)
|
binding.snackbarLayout.background = createThemedBackground()
|
||||||
message = view.findViewById(R.id.snackbar_text)
|
|
||||||
action = view.findViewById(R.id.snackbar_action)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismiss() {
|
fun dismiss() {
|
||||||
@@ -62,33 +68,66 @@ class FadingSnackbar @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun show(
|
fun show(
|
||||||
messageText: CharSequence? = null,
|
messageText: CharSequence?,
|
||||||
@StringRes actionId: Int? = null,
|
@StringRes actionId: Int = 0,
|
||||||
longDuration: Boolean = true,
|
duration: Int = Snackbar.LENGTH_SHORT,
|
||||||
actionClick: () -> Unit = { dismiss() },
|
onActionClick: (FadingSnackbar.() -> Unit)? = null,
|
||||||
dismissListener: () -> Unit = { }
|
onDismiss: (() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
message.text = messageText
|
binding.snackbarText.text = messageText
|
||||||
if (actionId != null) {
|
if (actionId != 0) {
|
||||||
action.run {
|
with(binding.snackbarAction) {
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
text = context.getString(actionId)
|
text = context.getString(actionId)
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
actionClick()
|
onActionClick?.invoke(this@FadingSnackbar) ?: dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
action.visibility = GONE
|
binding.snackbarAction.visibility = GONE
|
||||||
}
|
}
|
||||||
alpha = 0f
|
alpha = 0f
|
||||||
visibility = VISIBLE
|
visibility = VISIBLE
|
||||||
animate()
|
animate()
|
||||||
.alpha(1f)
|
.alpha(1f)
|
||||||
.duration = ENTER_DURATION
|
.duration = ENTER_DURATION
|
||||||
val showDuration = ENTER_DURATION + if (longDuration) LONG_DURATION else SHORT_DURATION
|
if (duration == Snackbar.LENGTH_INDEFINITE) {
|
||||||
postDelayed(showDuration) {
|
return
|
||||||
|
}
|
||||||
|
val durationMs = ENTER_DURATION + if (duration == Snackbar.LENGTH_LONG) LONG_DURATION_MS else SHORT_DURATION_MS
|
||||||
|
postDelayed(durationMs) {
|
||||||
dismiss()
|
dismiss()
|
||||||
dismissListener()
|
onDismiss?.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createThemedBackground(): Drawable {
|
||||||
|
val backgroundColor = MaterialColors.layer(this, materialR.attr.colorSurface, materialR.attr.colorOnSurface, 1f)
|
||||||
|
val shapeAppearanceModel = ShapeAppearanceModel.builder(
|
||||||
|
context,
|
||||||
|
materialR.style.ShapeAppearance_Material3_Corner_ExtraSmall,
|
||||||
|
0
|
||||||
|
).build()
|
||||||
|
val background = createMaterialShapeDrawableBackground(
|
||||||
|
backgroundColor,
|
||||||
|
shapeAppearanceModel,
|
||||||
|
)
|
||||||
|
val backgroundTint = context.getThemeColorStateList(materialR.attr.colorSurfaceInverse)
|
||||||
|
return if (backgroundTint != null) {
|
||||||
|
val wrappedDrawable = DrawableCompat.wrap(background)
|
||||||
|
DrawableCompat.setTintList(wrappedDrawable, backgroundTint)
|
||||||
|
wrappedDrawable
|
||||||
|
} else {
|
||||||
|
DrawableCompat.wrap(background)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createMaterialShapeDrawableBackground(
|
||||||
|
@ColorInt backgroundColor: Int,
|
||||||
|
shapeAppearanceModel: ShapeAppearanceModel,
|
||||||
|
): MaterialShapeDrawable {
|
||||||
|
val background = MaterialShapeDrawable(shapeAppearanceModel)
|
||||||
|
background.fillColor = ColorStateList.valueOf(backgroundColor)
|
||||||
|
return background
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,4 +25,5 @@ class BookmarkEntity(
|
|||||||
@ColumnInfo(name = "scroll") val scroll: Int,
|
@ColumnInfo(name = "scroll") val scroll: Int,
|
||||||
@ColumnInfo(name = "image") val imageUrl: String,
|
@ColumnInfo(name = "image") val imageUrl: String,
|
||||||
@ColumnInfo(name = "created_at") val createdAt: Long,
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
|
@ColumnInfo(name = "percent") val percent: Float,
|
||||||
)
|
)
|
||||||
@@ -18,6 +18,7 @@ fun BookmarkEntity.toBookmark(manga: Manga) = Bookmark(
|
|||||||
scroll = scroll,
|
scroll = scroll,
|
||||||
imageUrl = imageUrl,
|
imageUrl = imageUrl,
|
||||||
createdAt = Date(createdAt),
|
createdAt = Date(createdAt),
|
||||||
|
percent = percent,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Bookmark.toEntity() = BookmarkEntity(
|
fun Bookmark.toEntity() = BookmarkEntity(
|
||||||
@@ -28,4 +29,5 @@ fun Bookmark.toEntity() = BookmarkEntity(
|
|||||||
scroll = scroll,
|
scroll = scroll,
|
||||||
imageUrl = imageUrl,
|
imageUrl = imageUrl,
|
||||||
createdAt = createdAt.time,
|
createdAt = createdAt.time,
|
||||||
|
percent = percent,
|
||||||
)
|
)
|
||||||
@@ -11,6 +11,7 @@ class Bookmark(
|
|||||||
val scroll: Int,
|
val scroll: Int,
|
||||||
val imageUrl: String,
|
val imageUrl: String,
|
||||||
val createdAt: Date,
|
val createdAt: Date,
|
||||||
|
val percent: Float,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
@@ -26,6 +27,7 @@ class Bookmark(
|
|||||||
if (scroll != other.scroll) return false
|
if (scroll != other.scroll) return false
|
||||||
if (imageUrl != other.imageUrl) return false
|
if (imageUrl != other.imageUrl) return false
|
||||||
if (createdAt != other.createdAt) return false
|
if (createdAt != other.createdAt) return false
|
||||||
|
if (percent != other.percent) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -38,6 +40,7 @@ class Bookmark(
|
|||||||
result = 31 * result + scroll
|
result = 31 * result + scroll
|
||||||
result = 31 * result + imageUrl.hashCode()
|
result = 31 * result + imageUrl.hashCode()
|
||||||
result = 31 * result + createdAt.hashCode()
|
result = 31 * result + createdAt.hashCode()
|
||||||
|
result = 31 * result + percent.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,6 +111,7 @@ class BackupRepository(private val db: MangaDatabase) {
|
|||||||
jo.put("chapter_id", chapterId)
|
jo.put("chapter_id", chapterId)
|
||||||
jo.put("page", page)
|
jo.put("page", page)
|
||||||
jo.put("scroll", scroll)
|
jo.put("scroll", scroll)
|
||||||
|
jo.put("percent", percent)
|
||||||
return jo
|
return jo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ class BackupZipOutput(val file: File) : Closeable {
|
|||||||
|
|
||||||
private val output = ZipOutput(file, Deflater.BEST_COMPRESSION)
|
private val output = ZipOutput(file, Deflater.BEST_COMPRESSION)
|
||||||
|
|
||||||
suspend fun put(entry: BackupEntry) {
|
suspend fun put(entry: BackupEntry) = runInterruptible(Dispatchers.IO) {
|
||||||
output.put(entry.name, entry.data.toString(2))
|
output.put(entry.name, entry.data.toString(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun finish() {
|
suspend fun finish() = runInterruptible(Dispatchers.IO) {
|
||||||
output.finish()
|
output.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ import org.koitharu.kotatsu.favourites.data.FavouriteCategoryEntity
|
|||||||
import org.koitharu.kotatsu.favourites.data.FavouriteEntity
|
import org.koitharu.kotatsu.favourites.data.FavouriteEntity
|
||||||
import org.koitharu.kotatsu.history.data.HistoryEntity
|
import org.koitharu.kotatsu.history.data.HistoryEntity
|
||||||
import org.koitharu.kotatsu.parsers.model.SortOrder
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
||||||
import org.koitharu.kotatsu.parsers.util.json.JSONIterator
|
import org.koitharu.kotatsu.parsers.util.json.*
|
||||||
import org.koitharu.kotatsu.parsers.util.json.getBooleanOrDefault
|
|
||||||
import org.koitharu.kotatsu.parsers.util.json.getStringOrNull
|
|
||||||
import org.koitharu.kotatsu.parsers.util.json.mapJSON
|
|
||||||
|
|
||||||
class RestoreRepository(private val db: MangaDatabase) {
|
class RestoreRepository(private val db: MangaDatabase) {
|
||||||
|
|
||||||
@@ -95,7 +92,8 @@ class RestoreRepository(private val db: MangaDatabase) {
|
|||||||
updatedAt = json.getLong("updated_at"),
|
updatedAt = json.getLong("updated_at"),
|
||||||
chapterId = json.getLong("chapter_id"),
|
chapterId = json.getLong("chapter_id"),
|
||||||
page = json.getInt("page"),
|
page = json.getInt("page"),
|
||||||
scroll = json.getDouble("scroll").toFloat()
|
scroll = json.getDouble("scroll").toFloat(),
|
||||||
|
percent = json.getFloatOrDefault("percent", -1f),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun parseCategory(json: JSONObject) = FavouriteCategoryEntity(
|
private fun parseCategory(json: JSONObject) = FavouriteCategoryEntity(
|
||||||
|
|||||||
@@ -6,8 +6,14 @@ import androidx.room.Room
|
|||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import org.koitharu.kotatsu.bookmarks.data.BookmarkEntity
|
import org.koitharu.kotatsu.bookmarks.data.BookmarkEntity
|
||||||
import org.koitharu.kotatsu.bookmarks.data.BookmarksDao
|
import org.koitharu.kotatsu.bookmarks.data.BookmarksDao
|
||||||
import org.koitharu.kotatsu.core.db.dao.*
|
import org.koitharu.kotatsu.core.db.dao.MangaDao
|
||||||
import org.koitharu.kotatsu.core.db.entity.*
|
import org.koitharu.kotatsu.core.db.dao.PreferencesDao
|
||||||
|
import org.koitharu.kotatsu.core.db.dao.TagsDao
|
||||||
|
import org.koitharu.kotatsu.core.db.dao.TrackLogsDao
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaPrefsEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.MangaTagsEntity
|
||||||
|
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
||||||
import org.koitharu.kotatsu.core.db.migrations.*
|
import org.koitharu.kotatsu.core.db.migrations.*
|
||||||
import org.koitharu.kotatsu.favourites.data.FavouriteCategoriesDao
|
import org.koitharu.kotatsu.favourites.data.FavouriteCategoriesDao
|
||||||
import org.koitharu.kotatsu.favourites.data.FavouriteCategoryEntity
|
import org.koitharu.kotatsu.favourites.data.FavouriteCategoryEntity
|
||||||
@@ -15,16 +21,22 @@ import org.koitharu.kotatsu.favourites.data.FavouriteEntity
|
|||||||
import org.koitharu.kotatsu.favourites.data.FavouritesDao
|
import org.koitharu.kotatsu.favourites.data.FavouritesDao
|
||||||
import org.koitharu.kotatsu.history.data.HistoryDao
|
import org.koitharu.kotatsu.history.data.HistoryDao
|
||||||
import org.koitharu.kotatsu.history.data.HistoryEntity
|
import org.koitharu.kotatsu.history.data.HistoryEntity
|
||||||
|
import org.koitharu.kotatsu.scrobbling.data.ScrobblingDao
|
||||||
|
import org.koitharu.kotatsu.scrobbling.data.ScrobblingEntity
|
||||||
import org.koitharu.kotatsu.suggestions.data.SuggestionDao
|
import org.koitharu.kotatsu.suggestions.data.SuggestionDao
|
||||||
import org.koitharu.kotatsu.suggestions.data.SuggestionEntity
|
import org.koitharu.kotatsu.suggestions.data.SuggestionEntity
|
||||||
|
import org.koitharu.kotatsu.tracker.data.TrackEntity
|
||||||
|
import org.koitharu.kotatsu.tracker.data.TrackLogEntity
|
||||||
|
import org.koitharu.kotatsu.tracker.data.TracksDao
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [
|
entities = [
|
||||||
MangaEntity::class, TagEntity::class, HistoryEntity::class, MangaTagsEntity::class,
|
MangaEntity::class, TagEntity::class, HistoryEntity::class, MangaTagsEntity::class,
|
||||||
FavouriteCategoryEntity::class, FavouriteEntity::class, MangaPrefsEntity::class,
|
FavouriteCategoryEntity::class, FavouriteEntity::class, MangaPrefsEntity::class,
|
||||||
TrackEntity::class, TrackLogEntity::class, SuggestionEntity::class, BookmarkEntity::class,
|
TrackEntity::class, TrackLogEntity::class, SuggestionEntity::class, BookmarkEntity::class,
|
||||||
|
ScrobblingEntity::class,
|
||||||
],
|
],
|
||||||
version = 11,
|
version = 12,
|
||||||
)
|
)
|
||||||
abstract class MangaDatabase : RoomDatabase() {
|
abstract class MangaDatabase : RoomDatabase() {
|
||||||
|
|
||||||
@@ -47,6 +59,8 @@ abstract class MangaDatabase : RoomDatabase() {
|
|||||||
abstract val suggestionDao: SuggestionDao
|
abstract val suggestionDao: SuggestionDao
|
||||||
|
|
||||||
abstract val bookmarksDao: BookmarksDao
|
abstract val bookmarksDao: BookmarksDao
|
||||||
|
|
||||||
|
abstract val scrobblingDao: ScrobblingDao
|
||||||
}
|
}
|
||||||
|
|
||||||
fun MangaDatabase(context: Context): MangaDatabase = Room.databaseBuilder(
|
fun MangaDatabase(context: Context): MangaDatabase = Room.databaseBuilder(
|
||||||
@@ -64,6 +78,7 @@ fun MangaDatabase(context: Context): MangaDatabase = Room.databaseBuilder(
|
|||||||
Migration8To9(),
|
Migration8To9(),
|
||||||
Migration9To10(),
|
Migration9To10(),
|
||||||
Migration10To11(),
|
Migration10To11(),
|
||||||
|
Migration11To12(),
|
||||||
).addCallback(
|
).addCallback(
|
||||||
DatabasePrePopulateCallback(context.resources)
|
DatabasePrePopulateCallback(context.resources)
|
||||||
).build()
|
).build()
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package org.koitharu.kotatsu.core.db.dao
|
package org.koitharu.kotatsu.core.db.dao
|
||||||
|
|
||||||
import androidx.room.*
|
import androidx.room.*
|
||||||
import org.koitharu.kotatsu.core.db.entity.TrackLogEntity
|
import org.koitharu.kotatsu.tracker.data.TrackLogEntity
|
||||||
import org.koitharu.kotatsu.core.db.entity.TrackLogWithManga
|
import org.koitharu.kotatsu.tracker.data.TrackLogWithManga
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface TrackLogsDao {
|
interface TrackLogsDao {
|
||||||
@@ -21,7 +21,7 @@ interface TrackLogsDao {
|
|||||||
suspend fun removeAll(mangaId: Long)
|
suspend fun removeAll(mangaId: Long)
|
||||||
|
|
||||||
@Query("DELETE FROM track_logs WHERE manga_id NOT IN (SELECT manga_id FROM tracks)")
|
@Query("DELETE FROM track_logs WHERE manga_id NOT IN (SELECT manga_id FROM tracks)")
|
||||||
suspend fun cleanup()
|
suspend fun gc()
|
||||||
|
|
||||||
@Query("SELECT COUNT(*) FROM track_logs")
|
@Query("SELECT COUNT(*) FROM track_logs")
|
||||||
suspend fun count(): Int
|
suspend fun count(): Int
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.koitharu.kotatsu.core.db.entity
|
package org.koitharu.kotatsu.core.db.entity
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
import org.koitharu.kotatsu.core.model.TrackingLogItem
|
|
||||||
import org.koitharu.kotatsu.parsers.model.*
|
import org.koitharu.kotatsu.parsers.model.*
|
||||||
import org.koitharu.kotatsu.parsers.util.mapToSet
|
import org.koitharu.kotatsu.parsers.util.mapToSet
|
||||||
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
||||||
@@ -35,13 +33,6 @@ fun MangaEntity.toManga(tags: Set<MangaTag>) = Manga(
|
|||||||
|
|
||||||
fun MangaWithTags.toManga() = manga.toManga(tags.toMangaTags())
|
fun MangaWithTags.toManga() = manga.toManga(tags.toMangaTags())
|
||||||
|
|
||||||
fun TrackLogWithManga.toTrackingLogItem() = TrackingLogItem(
|
|
||||||
id = trackLog.id,
|
|
||||||
chapters = trackLog.chapters.split('\n').filterNot { x -> x.isEmpty() },
|
|
||||||
manga = manga.toManga(tags.toMangaTags()),
|
|
||||||
createdAt = Date(trackLog.createdAt)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Model to entity
|
// Model to entity
|
||||||
|
|
||||||
fun Manga.toEntity() = MangaEntity(
|
fun Manga.toEntity() = MangaEntity(
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.koitharu.kotatsu.core.db.migrations
|
||||||
|
|
||||||
|
import androidx.room.migration.Migration
|
||||||
|
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||||
|
|
||||||
|
class Migration11To12 : Migration(11, 12) {
|
||||||
|
|
||||||
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
|
database.execSQL(
|
||||||
|
"""
|
||||||
|
CREATE TABLE IF NOT EXISTS `scrobblings` (
|
||||||
|
`scrobbler` INTEGER NOT NULL,
|
||||||
|
`id` INTEGER NOT NULL,
|
||||||
|
`manga_id` INTEGER NOT NULL,
|
||||||
|
`target_id` INTEGER NOT NULL,
|
||||||
|
`status` TEXT,
|
||||||
|
`chapter` INTEGER NOT NULL,
|
||||||
|
`comment` TEXT,
|
||||||
|
`rating` REAL NOT NULL,
|
||||||
|
PRIMARY KEY(`scrobbler`, `id`, `manga_id`)
|
||||||
|
)
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
database.execSQL("ALTER TABLE history ADD COLUMN `percent` REAL NOT NULL DEFAULT -1")
|
||||||
|
database.execSQL("ALTER TABLE bookmarks ADD COLUMN `percent` REAL NOT NULL DEFAULT -1")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.core.exceptions
|
package org.koitharu.kotatsu.core.exceptions
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import okio.IOException
|
import okio.IOException
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
|
|
||||||
class CloudFlareProtectedException(
|
class CloudFlareProtectedException(
|
||||||
val url: String
|
val url: String
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.koitharu.kotatsu.core.exceptions
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.parsers.util.mapNotNullToSet
|
||||||
|
|
||||||
|
class CompositeException(val errors: Collection<Throwable>) : Exception() {
|
||||||
|
|
||||||
|
override val message: String = errors.mapNotNullToSet { it.message }.joinToString()
|
||||||
|
}
|
||||||
@@ -11,4 +11,5 @@ data class MangaHistory(
|
|||||||
val chapterId: Long,
|
val chapterId: Long,
|
||||||
val page: Int,
|
val page: Int,
|
||||||
val scroll: Int,
|
val scroll: Int,
|
||||||
|
val percent: Float,
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.koitharu.kotatsu.core.model
|
||||||
|
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun MangaSource.getLocaleTitle(): String? {
|
||||||
|
val lc = Locale(locale ?: return null)
|
||||||
|
return lc.getDisplayLanguage(lc).toTitleCase(lc)
|
||||||
|
}
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.model
|
|
||||||
|
|
||||||
import android.os.Parcelable
|
|
||||||
import kotlinx.parcelize.Parcelize
|
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
data class MangaTracking(
|
|
||||||
val manga: Manga,
|
|
||||||
val knownChaptersCount: Int,
|
|
||||||
val lastChapterId: Long,
|
|
||||||
val lastNotifiedChapterId: Long,
|
|
||||||
val lastCheck: Date?
|
|
||||||
)
|
|
||||||
@@ -3,14 +3,13 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.utils.ext.createList
|
|
||||||
|
|
||||||
class ParcelableMangaChapters(
|
class ParcelableMangaChapters(
|
||||||
val chapters: List<MangaChapter>,
|
val chapters: List<MangaChapter>,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this(
|
constructor(parcel: Parcel) : this(
|
||||||
createList(parcel.readInt()) { parcel.readMangaChapter() }
|
List(parcel.readInt()) { parcel.readMangaChapter() }
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.utils.ext.createList
|
|
||||||
|
|
||||||
class ParcelableMangaPages(
|
class ParcelableMangaPages(
|
||||||
val pages: List<MangaPage>,
|
val pages: List<MangaPage>,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this(
|
constructor(parcel: Parcel) : this(
|
||||||
createList(parcel.readInt()) { parcel.readMangaPage() }
|
List(parcel.readInt()) { parcel.readMangaPage() }
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
import org.koitharu.kotatsu.utils.ext.createSet
|
import org.koitharu.kotatsu.utils.ext.Set
|
||||||
|
|
||||||
class ParcelableMangaTags(
|
class ParcelableMangaTags(
|
||||||
val tags: Set<MangaTag>,
|
val tags: Set<MangaTag>,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this(
|
constructor(parcel: Parcel) : this(
|
||||||
createSet(parcel.readInt()) { parcel.readMangaTag() }
|
Set(parcel.readInt()) { parcel.readMangaTag() }
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ object CommonHeaders {
|
|||||||
const val ACCEPT = "Accept"
|
const val ACCEPT = "Accept"
|
||||||
const val CONTENT_DISPOSITION = "Content-Disposition"
|
const val CONTENT_DISPOSITION = "Content-Disposition"
|
||||||
const val COOKIE = "Cookie"
|
const val COOKIE = "Cookie"
|
||||||
|
const val AUTHORIZATION = "Authorization"
|
||||||
|
|
||||||
val CACHE_CONTROL_DISABLED: CacheControl
|
val CACHE_CONTROL_DISABLED: CacheControl
|
||||||
get() = CacheControl.Builder().noStore().build()
|
get() = CacheControl.Builder().noStore().build()
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ interface MangaRepository {
|
|||||||
|
|
||||||
val sortOrders: Set<SortOrder>
|
val sortOrders: Set<SortOrder>
|
||||||
|
|
||||||
suspend fun getList(
|
suspend fun getList(offset: Int, query: String): List<Manga>
|
||||||
offset: Int,
|
|
||||||
query: String? = null,
|
suspend fun getList(offset: Int, tags: Set<MangaTag>?, sortOrder: SortOrder?): List<Manga>
|
||||||
tags: Set<MangaTag>? = null,
|
|
||||||
sortOrder: SortOrder? = null,
|
|
||||||
): List<Manga>
|
|
||||||
|
|
||||||
suspend fun getDetails(manga: Manga): Manga
|
suspend fun getDetails(manga: Manga): Manga
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ class RemoteMangaRepository(private val parser: MangaParser) : MangaRepository {
|
|||||||
getConfig().defaultSortOrder = value
|
getConfig().defaultSortOrder = value
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getList(
|
override suspend fun getList(offset: Int, query: String): List<Manga> {
|
||||||
offset: Int,
|
return parser.getList(offset, query)
|
||||||
query: String?,
|
}
|
||||||
tags: Set<MangaTag>?,
|
|
||||||
sortOrder: SortOrder?,
|
override suspend fun getList(offset: Int, tags: Set<MangaTag>?, sortOrder: SortOrder?): List<Manga> {
|
||||||
): List<Manga> = parser.getList(offset, query, tags, sortOrder)
|
return parser.getList(offset, tags, sortOrder)
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun getDetails(manga: Manga): Manga = parser.getDetails(manga)
|
override suspend fun getDetails(manga: Manga): Manga = parser.getDetails(manga)
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import androidx.collection.arraySetOf
|
|||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.google.android.material.color.DynamicColors
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import java.io.File
|
||||||
|
import java.text.DateFormat
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.*
|
||||||
import kotlinx.coroutines.channels.awaitClose
|
import kotlinx.coroutines.channels.awaitClose
|
||||||
import kotlinx.coroutines.channels.trySendBlocking
|
import kotlinx.coroutines.channels.trySendBlocking
|
||||||
import kotlinx.coroutines.flow.callbackFlow
|
import kotlinx.coroutines.flow.callbackFlow
|
||||||
@@ -18,12 +22,9 @@ import org.koitharu.kotatsu.core.model.ZoomMode
|
|||||||
import org.koitharu.kotatsu.core.network.DoHProvider
|
import org.koitharu.kotatsu.core.network.DoHProvider
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.utils.ext.getEnumValue
|
import org.koitharu.kotatsu.utils.ext.getEnumValue
|
||||||
|
import org.koitharu.kotatsu.utils.ext.observe
|
||||||
import org.koitharu.kotatsu.utils.ext.putEnumValue
|
import org.koitharu.kotatsu.utils.ext.putEnumValue
|
||||||
import org.koitharu.kotatsu.utils.ext.toUriOrNull
|
import org.koitharu.kotatsu.utils.ext.toUriOrNull
|
||||||
import java.io.File
|
|
||||||
import java.text.DateFormat
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class AppSettings(context: Context) {
|
class AppSettings(context: Context) {
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class AppSettings(context: Context) {
|
|||||||
get() = Collections.unmodifiableSet(remoteSources)
|
get() = Collections.unmodifiableSet(remoteSources)
|
||||||
|
|
||||||
var listMode: ListMode
|
var listMode: ListMode
|
||||||
get() = prefs.getEnumValue(KEY_LIST_MODE, ListMode.DETAILED_LIST)
|
get() = prefs.getEnumValue(KEY_LIST_MODE, ListMode.GRID)
|
||||||
set(value) = prefs.edit { putEnumValue(KEY_LIST_MODE, value) }
|
set(value) = prefs.edit { putEnumValue(KEY_LIST_MODE, value) }
|
||||||
|
|
||||||
var defaultSection: AppSection
|
var defaultSection: AppSection
|
||||||
@@ -104,10 +105,13 @@ class AppSettings(context: Context) {
|
|||||||
val isReaderModeDetectionEnabled: Boolean
|
val isReaderModeDetectionEnabled: Boolean
|
||||||
get() = prefs.getBoolean(KEY_READER_MODE_DETECT, true)
|
get() = prefs.getBoolean(KEY_READER_MODE_DETECT, true)
|
||||||
|
|
||||||
var historyGrouping: Boolean
|
var isHistoryGroupingEnabled: Boolean
|
||||||
get() = prefs.getBoolean(KEY_HISTORY_GROUPING, true)
|
get() = prefs.getBoolean(KEY_HISTORY_GROUPING, true)
|
||||||
set(value) = prefs.edit { putBoolean(KEY_HISTORY_GROUPING, value) }
|
set(value) = prefs.edit { putBoolean(KEY_HISTORY_GROUPING, value) }
|
||||||
|
|
||||||
|
val isReadingIndicatorsEnabled: Boolean
|
||||||
|
get() = prefs.getBoolean(KEY_READING_INDICATORS, true)
|
||||||
|
|
||||||
val isHistoryExcludeNsfw: Boolean
|
val isHistoryExcludeNsfw: Boolean
|
||||||
get() = prefs.getBoolean(KEY_HISTORY_EXCLUDE_NSFW, false)
|
get() = prefs.getBoolean(KEY_HISTORY_EXCLUDE_NSFW, false)
|
||||||
|
|
||||||
@@ -125,6 +129,10 @@ class AppSettings(context: Context) {
|
|||||||
get() = prefs.getString(KEY_APP_PASSWORD, null)
|
get() = prefs.getString(KEY_APP_PASSWORD, null)
|
||||||
set(value) = prefs.edit { if (value != null) putString(KEY_APP_PASSWORD, value) else remove(KEY_APP_PASSWORD) }
|
set(value) = prefs.edit { if (value != null) putString(KEY_APP_PASSWORD, value) else remove(KEY_APP_PASSWORD) }
|
||||||
|
|
||||||
|
var isBiometricProtectionEnabled: Boolean
|
||||||
|
get() = prefs.getBoolean(KEY_PROTECT_APP_BIOMETRIC, true)
|
||||||
|
set(value) = prefs.edit { putBoolean(KEY_PROTECT_APP_BIOMETRIC, value) }
|
||||||
|
|
||||||
var sourcesOrder: List<String>
|
var sourcesOrder: List<String>
|
||||||
get() = prefs.getString(KEY_SOURCES_ORDER, null)
|
get() = prefs.getString(KEY_SOURCES_ORDER, null)
|
||||||
?.split('|')
|
?.split('|')
|
||||||
@@ -242,15 +250,7 @@ class AppSettings(context: Context) {
|
|||||||
prefs.unregisterOnSharedPreferenceChangeListener(listener)
|
prefs.unregisterOnSharedPreferenceChangeListener(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun observe() = callbackFlow<String> {
|
fun observe() = prefs.observe()
|
||||||
val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
|
||||||
trySendBlocking(key)
|
|
||||||
}
|
|
||||||
prefs.registerOnSharedPreferenceChangeListener(listener)
|
|
||||||
awaitClose {
|
|
||||||
prefs.unregisterOnSharedPreferenceChangeListener(listener)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -293,11 +293,13 @@ class AppSettings(context: Context) {
|
|||||||
const val KEY_READER_MODE_DETECT = "reader_mode_detect"
|
const val KEY_READER_MODE_DETECT = "reader_mode_detect"
|
||||||
const val KEY_APP_PASSWORD = "app_password"
|
const val KEY_APP_PASSWORD = "app_password"
|
||||||
const val KEY_PROTECT_APP = "protect_app"
|
const val KEY_PROTECT_APP = "protect_app"
|
||||||
|
const val KEY_PROTECT_APP_BIOMETRIC = "protect_app_bio"
|
||||||
const val KEY_APP_VERSION = "app_version"
|
const val KEY_APP_VERSION = "app_version"
|
||||||
const val KEY_ZOOM_MODE = "zoom_mode"
|
const val KEY_ZOOM_MODE = "zoom_mode"
|
||||||
const val KEY_BACKUP = "backup"
|
const val KEY_BACKUP = "backup"
|
||||||
const val KEY_RESTORE = "restore"
|
const val KEY_RESTORE = "restore"
|
||||||
const val KEY_HISTORY_GROUPING = "history_grouping"
|
const val KEY_HISTORY_GROUPING = "history_grouping"
|
||||||
|
const val KEY_READING_INDICATORS = "reading_indicators"
|
||||||
const val KEY_REVERSE_CHAPTERS = "reverse_chapters"
|
const val KEY_REVERSE_CHAPTERS = "reverse_chapters"
|
||||||
const val KEY_HISTORY_EXCLUDE_NSFW = "history_exclude_nsfw"
|
const val KEY_HISTORY_EXCLUDE_NSFW = "history_exclude_nsfw"
|
||||||
const val KEY_PAGES_NUMBERS = "pages_numbers"
|
const val KEY_PAGES_NUMBERS = "pages_numbers"
|
||||||
@@ -307,6 +309,7 @@ class AppSettings(context: Context) {
|
|||||||
const val KEY_SUGGESTIONS_EXCLUDE_NSFW = "suggestions_exclude_nsfw"
|
const val KEY_SUGGESTIONS_EXCLUDE_NSFW = "suggestions_exclude_nsfw"
|
||||||
const val KEY_SUGGESTIONS_EXCLUDE_TAGS = "suggestions_exclude_tags"
|
const val KEY_SUGGESTIONS_EXCLUDE_TAGS = "suggestions_exclude_tags"
|
||||||
const val KEY_SEARCH_SINGLE_SOURCE = "search_single_source"
|
const val KEY_SEARCH_SINGLE_SOURCE = "search_single_source"
|
||||||
|
const val KEY_SHIKIMORI = "shikimori"
|
||||||
const val KEY_DOWNLOADS_PARALLELISM = "downloads_parallelism"
|
const val KEY_DOWNLOADS_PARALLELISM = "downloads_parallelism"
|
||||||
const val KEY_DOWNLOADS_SLOWDOWN = "downloads_slowdown"
|
const val KEY_DOWNLOADS_SLOWDOWN = "downloads_slowdown"
|
||||||
const val KEY_ALL_FAVOURITES_VISIBLE = "all_favourites_visible"
|
const val KEY_ALL_FAVOURITES_VISIBLE = "all_favourites_visible"
|
||||||
@@ -316,9 +319,6 @@ class AppSettings(context: Context) {
|
|||||||
const val KEY_APP_UPDATE = "app_update"
|
const val KEY_APP_UPDATE = "app_update"
|
||||||
const val KEY_APP_UPDATE_AUTO = "app_update_auto"
|
const val KEY_APP_UPDATE_AUTO = "app_update_auto"
|
||||||
const val KEY_APP_TRANSLATION = "about_app_translation"
|
const val KEY_APP_TRANSLATION = "about_app_translation"
|
||||||
const val KEY_FEEDBACK_4PDA = "about_feedback_4pda"
|
|
||||||
const val KEY_FEEDBACK_DISCORD = "about_feedback_discord"
|
|
||||||
const val KEY_FEEDBACK_GITHUB = "about_feedback_github"
|
|
||||||
|
|
||||||
private const val NETWORK_NEVER = 0
|
private const val NETWORK_NEVER = 0
|
||||||
private const val NETWORK_ALWAYS = 1
|
private const val NETWORK_ALWAYS = 1
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.util.Log
|
|
||||||
import kotlin.system.exitProcess
|
|
||||||
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
|
||||||
|
|
||||||
class AppCrashHandler(private val applicationContext: Context) : Thread.UncaughtExceptionHandler {
|
|
||||||
|
|
||||||
override fun uncaughtException(t: Thread, e: Throwable) {
|
|
||||||
val intent = CrashActivity.newIntent(applicationContext, e)
|
|
||||||
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
try {
|
|
||||||
applicationContext.startActivity(intent)
|
|
||||||
} catch (t: Throwable) {
|
|
||||||
t.printStackTraceDebug()
|
|
||||||
}
|
|
||||||
Log.e("CRASH", e.message, e)
|
|
||||||
exitProcess(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ActivityNotFoundException
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
|
||||||
import org.koitharu.kotatsu.R
|
|
||||||
import org.koitharu.kotatsu.databinding.ActivityCrashBinding
|
|
||||||
import org.koitharu.kotatsu.main.ui.MainActivity
|
|
||||||
import org.koitharu.kotatsu.parsers.util.ellipsize
|
|
||||||
import org.koitharu.kotatsu.utils.ShareHelper
|
|
||||||
|
|
||||||
class CrashActivity : Activity(), View.OnClickListener {
|
|
||||||
|
|
||||||
private lateinit var binding: ActivityCrashBinding
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = ActivityCrashBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
|
||||||
binding.textView.text = intent.getStringExtra(Intent.EXTRA_TEXT)
|
|
||||||
binding.buttonClose.setOnClickListener(this)
|
|
||||||
binding.buttonRestart.setOnClickListener(this)
|
|
||||||
binding.buttonReport.setOnClickListener(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
|
||||||
menuInflater.inflate(R.menu.opt_crash, menu)
|
|
||||||
return super.onCreateOptionsMenu(menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
when (item.itemId) {
|
|
||||||
R.id.action_share -> {
|
|
||||||
ShareHelper(this).shareText(binding.textView.text.toString())
|
|
||||||
}
|
|
||||||
else -> return super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
|
||||||
when (v.id) {
|
|
||||||
R.id.button_close -> {
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
R.id.button_restart -> {
|
|
||||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
|
||||||
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
startActivity(intent)
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
R.id.button_report -> {
|
|
||||||
val intent = Intent(Intent.ACTION_VIEW)
|
|
||||||
intent.data = Uri.parse("https://github.com/nv95/Kotatsu/issues")
|
|
||||||
try {
|
|
||||||
startActivity(Intent.createChooser(intent, getString(R.string.report_github)))
|
|
||||||
} catch (_: ActivityNotFoundException) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
private const val MAX_TRACE_SIZE = 131071
|
|
||||||
|
|
||||||
fun newIntent(context: Context, error: Throwable): Intent {
|
|
||||||
val crashInfo = error
|
|
||||||
.stackTraceToString()
|
|
||||||
.trimIndent()
|
|
||||||
.ellipsize(MAX_TRACE_SIZE)
|
|
||||||
val intent = Intent(context, CrashActivity::class.java)
|
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, crashInfo)
|
|
||||||
return intent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.core.ui
|
package org.koitharu.kotatsu.core.ui
|
||||||
|
|
||||||
|
import android.text.Html
|
||||||
import coil.ComponentRegistry
|
import coil.ComponentRegistry
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.disk.DiskCache
|
import coil.disk.DiskCache
|
||||||
@@ -10,6 +11,7 @@ import org.koin.dsl.module
|
|||||||
import org.koitharu.kotatsu.core.parser.FaviconMapper
|
import org.koitharu.kotatsu.core.parser.FaviconMapper
|
||||||
import org.koitharu.kotatsu.local.data.CacheDir
|
import org.koitharu.kotatsu.local.data.CacheDir
|
||||||
import org.koitharu.kotatsu.local.data.CbzFetcher
|
import org.koitharu.kotatsu.local.data.CbzFetcher
|
||||||
|
import org.koitharu.kotatsu.utils.image.CoilImageGetter
|
||||||
|
|
||||||
val uiModule
|
val uiModule
|
||||||
get() = module {
|
get() = module {
|
||||||
@@ -29,6 +31,9 @@ val uiModule
|
|||||||
ImageLoader.Builder(androidContext())
|
ImageLoader.Builder(androidContext())
|
||||||
.okHttpClient(httpClientFactory)
|
.okHttpClient(httpClientFactory)
|
||||||
.interceptorDispatcher(Dispatchers.Default)
|
.interceptorDispatcher(Dispatchers.Default)
|
||||||
|
.fetcherDispatcher(Dispatchers.IO)
|
||||||
|
.decoderDispatcher(Dispatchers.Default)
|
||||||
|
.transformationDispatcher(Dispatchers.Default)
|
||||||
.diskCache(diskCacheFactory)
|
.diskCache(diskCacheFactory)
|
||||||
.components(
|
.components(
|
||||||
ComponentRegistry.Builder()
|
ComponentRegistry.Builder()
|
||||||
@@ -37,4 +42,5 @@ val uiModule
|
|||||||
.build()
|
.build()
|
||||||
).build()
|
).build()
|
||||||
}
|
}
|
||||||
|
factory<Html.ImageGetter> { CoilImageGetter(androidContext(), get()) }
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,6 @@ val detailsModule
|
|||||||
get() = module {
|
get() = module {
|
||||||
|
|
||||||
viewModel { intent ->
|
viewModel { intent ->
|
||||||
DetailsViewModel(intent.get(), get(), get(), get(), get(), get(), get(), get())
|
DetailsViewModel(intent.get(), get(), get(), get(), get(), get(), get(), get(), get(), get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,17 @@ import android.os.Bundle
|
|||||||
import android.view.*
|
import android.view.*
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.ui.BaseFragment
|
import org.koitharu.kotatsu.base.ui.BaseFragment
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.ListSelectionController
|
||||||
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
||||||
import org.koitharu.kotatsu.databinding.FragmentChaptersBinding
|
import org.koitharu.kotatsu.databinding.FragmentChaptersBinding
|
||||||
import org.koitharu.kotatsu.details.ui.adapter.BranchesAdapter
|
import org.koitharu.kotatsu.details.ui.adapter.BranchesAdapter
|
||||||
@@ -27,26 +28,21 @@ import org.koitharu.kotatsu.parsers.model.MangaSource
|
|||||||
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderState
|
import org.koitharu.kotatsu.reader.ui.ReaderState
|
||||||
import org.koitharu.kotatsu.utils.RecyclerViewScrollCallback
|
import org.koitharu.kotatsu.utils.RecyclerViewScrollCallback
|
||||||
|
import org.koitharu.kotatsu.utils.ext.addMenuProvider
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class ChaptersFragment :
|
class ChaptersFragment :
|
||||||
BaseFragment<FragmentChaptersBinding>(),
|
BaseFragment<FragmentChaptersBinding>(),
|
||||||
OnListItemClickListener<ChapterListItem>,
|
OnListItemClickListener<ChapterListItem>,
|
||||||
ActionMode.Callback,
|
|
||||||
AdapterView.OnItemSelectedListener,
|
AdapterView.OnItemSelectedListener,
|
||||||
MenuItem.OnActionExpandListener,
|
MenuItem.OnActionExpandListener,
|
||||||
SearchView.OnQueryTextListener {
|
SearchView.OnQueryTextListener,
|
||||||
|
ListSelectionController.Callback {
|
||||||
|
|
||||||
private val viewModel by sharedViewModel<DetailsViewModel>()
|
private val viewModel by sharedViewModel<DetailsViewModel>()
|
||||||
|
|
||||||
private var chaptersAdapter: ChaptersAdapter? = null
|
private var chaptersAdapter: ChaptersAdapter? = null
|
||||||
private var actionMode: ActionMode? = null
|
private var selectionController: ListSelectionController? = null
|
||||||
private var selectionDecoration: ChaptersSelectionDecoration? = null
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onInflateView(
|
override fun onInflateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
@@ -56,9 +52,14 @@ class ChaptersFragment :
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
chaptersAdapter = ChaptersAdapter(this)
|
chaptersAdapter = ChaptersAdapter(this)
|
||||||
selectionDecoration = ChaptersSelectionDecoration(view.context)
|
selectionController = ListSelectionController(
|
||||||
|
activity = requireActivity(),
|
||||||
|
decoration = ChaptersSelectionDecoration(view.context),
|
||||||
|
registryOwner = this,
|
||||||
|
callback = this,
|
||||||
|
)
|
||||||
with(binding.recyclerViewChapters) {
|
with(binding.recyclerViewChapters) {
|
||||||
addItemDecoration(selectionDecoration!!)
|
checkNotNull(selectionController).attachToRecyclerView(this)
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
adapter = chaptersAdapter
|
adapter = chaptersAdapter
|
||||||
}
|
}
|
||||||
@@ -72,49 +73,18 @@ class ChaptersFragment :
|
|||||||
binding.textViewHolder.isVisible = it
|
binding.textViewHolder.isVisible = it
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
addMenuProvider(ChaptersMenuProvider())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
chaptersAdapter = null
|
chaptersAdapter = null
|
||||||
selectionDecoration = null
|
selectionController = null
|
||||||
binding.spinnerBranches?.adapter = null
|
binding.spinnerBranches?.adapter = null
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
inflater.inflate(R.menu.opt_chapters, menu)
|
|
||||||
val searchMenuItem = menu.findItem(R.id.action_search)
|
|
||||||
searchMenuItem.setOnActionExpandListener(this)
|
|
||||||
val searchView = searchMenuItem.actionView as SearchView
|
|
||||||
searchView.setOnQueryTextListener(this)
|
|
||||||
searchView.setIconifiedByDefault(false)
|
|
||||||
searchView.queryHint = searchMenuItem.title
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
||||||
super.onPrepareOptionsMenu(menu)
|
|
||||||
menu.findItem(R.id.action_reversed).isChecked = viewModel.isChaptersReversed.value == true
|
|
||||||
menu.findItem(R.id.action_search).isVisible = viewModel.isChaptersEmpty.value == false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
|
||||||
R.id.action_reversed -> {
|
|
||||||
viewModel.setChaptersReversed(!item.isChecked)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemClick(item: ChapterListItem, view: View) {
|
override fun onItemClick(item: ChapterListItem, view: View) {
|
||||||
if (selectionDecoration?.checkedItemsCount != 0) {
|
if (selectionController?.onItemClick(item.chapter.id) == true) {
|
||||||
selectionDecoration?.toggleItemChecked(item.chapter.id)
|
|
||||||
if (selectionDecoration?.checkedItemsCount == 0) {
|
|
||||||
actionMode?.finish()
|
|
||||||
} else {
|
|
||||||
actionMode?.invalidate()
|
|
||||||
binding.recyclerViewChapters.invalidateItemDecorations()
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (item.hasFlag(ChapterListItem.FLAG_MISSING)) {
|
if (item.hasFlag(ChapterListItem.FLAG_MISSING)) {
|
||||||
@@ -133,14 +103,7 @@ class ChaptersFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(item: ChapterListItem, view: View): Boolean {
|
override fun onItemLongClick(item: ChapterListItem, view: View): Boolean {
|
||||||
if (actionMode == null) {
|
return selectionController?.onItemLongClick(item.chapter.id) ?: false
|
||||||
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
|
||||||
}
|
|
||||||
return actionMode?.also {
|
|
||||||
selectionDecoration?.setItemIsChecked(item.chapter.id, true)
|
|
||||||
binding.recyclerViewChapters.invalidateItemDecorations()
|
|
||||||
it.invalidate()
|
|
||||||
} != null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
||||||
@@ -149,13 +112,13 @@ class ChaptersFragment :
|
|||||||
DownloadService.start(
|
DownloadService.start(
|
||||||
context ?: return false,
|
context ?: return false,
|
||||||
viewModel.getRemoteManga() ?: viewModel.manga.value ?: return false,
|
viewModel.getRemoteManga() ?: viewModel.manga.value ?: return false,
|
||||||
selectionDecoration?.checkedItemsIds?.toSet()
|
selectionController?.snapshot(),
|
||||||
)
|
)
|
||||||
mode.finish()
|
mode.finish()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_delete -> {
|
R.id.action_delete -> {
|
||||||
val ids = selectionDecoration?.checkedItemsIds
|
val ids = selectionController?.peekCheckedIds()
|
||||||
val manga = viewModel.manga.value
|
val manga = viewModel.manga.value
|
||||||
when {
|
when {
|
||||||
ids.isNullOrEmpty() || manga == null -> Unit
|
ids.isNullOrEmpty() || manga == null -> Unit
|
||||||
@@ -174,9 +137,7 @@ class ChaptersFragment :
|
|||||||
}
|
}
|
||||||
R.id.action_select_all -> {
|
R.id.action_select_all -> {
|
||||||
val ids = chaptersAdapter?.items?.map { it.chapter.id } ?: return false
|
val ids = chaptersAdapter?.items?.map { it.chapter.id } ?: return false
|
||||||
selectionDecoration?.checkAll(ids)
|
selectionController?.addAll(ids)
|
||||||
binding.recyclerViewChapters.invalidateItemDecorations()
|
|
||||||
mode.invalidate()
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
@@ -196,7 +157,7 @@ class ChaptersFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
val selectedIds = selectionDecoration?.checkedItemsIds ?: return false
|
val selectedIds = selectionController?.peekCheckedIds() ?: return false
|
||||||
val items = chaptersAdapter?.items?.filter { x -> x.chapter.id in selectedIds }.orEmpty()
|
val items = chaptersAdapter?.items?.filter { x -> x.chapter.id in selectedIds }.orEmpty()
|
||||||
menu.findItem(R.id.action_save).isVisible = items.none { x ->
|
menu.findItem(R.id.action_save).isVisible = items.none { x ->
|
||||||
x.chapter.source == MangaSource.LOCAL
|
x.chapter.source == MangaSource.LOCAL
|
||||||
@@ -208,10 +169,8 @@ class ChaptersFragment :
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyActionMode(mode: ActionMode?) {
|
override fun onSelectionChanged(count: Int) {
|
||||||
selectionDecoration?.clearSelection()
|
|
||||||
binding.recyclerViewChapters.invalidateItemDecorations()
|
binding.recyclerViewChapters.invalidateItemDecorations()
|
||||||
actionMode = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemActionExpand(item: MenuItem?): Boolean = true
|
override fun onMenuItemActionExpand(item: MenuItem?): Boolean = true
|
||||||
@@ -268,4 +227,30 @@ class ChaptersFragment :
|
|||||||
private fun onLoadingStateChanged(isLoading: Boolean) {
|
private fun onLoadingStateChanged(isLoading: Boolean) {
|
||||||
binding.progressBar.isVisible = isLoading
|
binding.progressBar.isVisible = isLoading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inner class ChaptersMenuProvider : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_chapters, menu)
|
||||||
|
val searchMenuItem = menu.findItem(R.id.action_search)
|
||||||
|
searchMenuItem.setOnActionExpandListener(this@ChaptersFragment)
|
||||||
|
val searchView = searchMenuItem.actionView as SearchView
|
||||||
|
searchView.setOnQueryTextListener(this@ChaptersFragment)
|
||||||
|
searchView.setIconifiedByDefault(false)
|
||||||
|
searchView.queryHint = searchMenuItem.title
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareMenu(menu: Menu) {
|
||||||
|
menu.findItem(R.id.action_reversed).isChecked = viewModel.isChaptersReversed.value == true
|
||||||
|
menu.findItem(R.id.action_search).isVisible = viewModel.isChaptersEmpty.value == false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
|
||||||
|
R.id.action_reversed -> {
|
||||||
|
viewModel.setChaptersReversed(!menuItem.isChecked)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,17 +15,17 @@ import android.widget.Toast
|
|||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.core.content.pm.ShortcutManagerCompat
|
import androidx.core.content.pm.ShortcutManagerCompat
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
import androidx.core.net.toFile
|
|
||||||
import androidx.core.net.toUri
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updateLayoutParams
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.commit
|
import androidx.fragment.app.commit
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.google.android.material.tabs.TabLayoutMediator
|
import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.acra.ktx.sendWithAcra
|
||||||
import org.koin.android.ext.android.get
|
import org.koin.android.ext.android.get
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
import org.koin.core.parameter.parametersOf
|
import org.koin.core.parameter.parametersOf
|
||||||
@@ -39,13 +39,14 @@ import org.koitharu.kotatsu.core.os.ShortcutsRepository
|
|||||||
import org.koitharu.kotatsu.databinding.ActivityDetailsBinding
|
import org.koitharu.kotatsu.databinding.ActivityDetailsBinding
|
||||||
import org.koitharu.kotatsu.details.ui.adapter.BranchesAdapter
|
import org.koitharu.kotatsu.details.ui.adapter.BranchesAdapter
|
||||||
import org.koitharu.kotatsu.download.ui.service.DownloadService
|
import org.koitharu.kotatsu.download.ui.service.DownloadService
|
||||||
|
import org.koitharu.kotatsu.parsers.exception.ParseException
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.util.mapNotNullToSet
|
import org.koitharu.kotatsu.parsers.util.mapNotNullToSet
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderState
|
import org.koitharu.kotatsu.reader.ui.ReaderState
|
||||||
|
import org.koitharu.kotatsu.scrobbling.ui.selector.ScrobblingSelectorBottomSheet
|
||||||
import org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity
|
import org.koitharu.kotatsu.search.ui.multi.MultiSearchActivity
|
||||||
import org.koitharu.kotatsu.utils.ShareHelper
|
|
||||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
|
|
||||||
class DetailsActivity :
|
class DetailsActivity :
|
||||||
@@ -84,7 +85,7 @@ class DetailsActivity :
|
|||||||
viewModel.onMangaRemoved.observe(this, ::onMangaRemoved)
|
viewModel.onMangaRemoved.observe(this, ::onMangaRemoved)
|
||||||
viewModel.onError.observe(this, ::onError)
|
viewModel.onError.observe(this, ::onError)
|
||||||
viewModel.onShowToast.observe(this) {
|
viewModel.onShowToast.observe(this) {
|
||||||
binding.snackbar.show(messageText = getString(it), longDuration = false)
|
binding.snackbar.show(messageText = getString(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
registerReceiver(downloadReceiver, IntentFilter(DownloadService.ACTION_DOWNLOAD_COMPLETE))
|
registerReceiver(downloadReceiver, IntentFilter(DownloadService.ACTION_DOWNLOAD_COMPLETE))
|
||||||
@@ -117,6 +118,21 @@ class DetailsActivity :
|
|||||||
Toast.makeText(this, e.getDisplayMessage(resources), Toast.LENGTH_LONG).show()
|
Toast.makeText(this, e.getDisplayMessage(resources), Toast.LENGTH_LONG).show()
|
||||||
finishAfterTransition()
|
finishAfterTransition()
|
||||||
}
|
}
|
||||||
|
e is ParseException || e is IllegalArgumentException || e is IllegalStateException -> {
|
||||||
|
binding.snackbar.show(
|
||||||
|
messageText = e.getDisplayMessage(resources),
|
||||||
|
actionId = R.string.report,
|
||||||
|
duration = if (viewModel.manga.value?.chapters == null) {
|
||||||
|
Snackbar.LENGTH_INDEFINITE
|
||||||
|
} else {
|
||||||
|
Snackbar.LENGTH_LONG
|
||||||
|
},
|
||||||
|
onActionClick = {
|
||||||
|
e.sendWithAcra()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
binding.snackbar.show(e.getDisplayMessage(resources))
|
binding.snackbar.show(e.getDisplayMessage(resources))
|
||||||
}
|
}
|
||||||
@@ -154,28 +170,15 @@ class DetailsActivity :
|
|||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
val manga = viewModel.manga.value
|
val manga = viewModel.manga.value
|
||||||
menu.findItem(R.id.action_save).isVisible =
|
menu.findItem(R.id.action_save).isVisible = manga?.source != null && manga.source != MangaSource.LOCAL
|
||||||
manga?.source != null && manga.source != MangaSource.LOCAL
|
menu.findItem(R.id.action_delete).isVisible = manga?.source == MangaSource.LOCAL
|
||||||
menu.findItem(R.id.action_delete).isVisible =
|
menu.findItem(R.id.action_browser).isVisible = manga?.source != MangaSource.LOCAL
|
||||||
manga?.source == MangaSource.LOCAL
|
menu.findItem(R.id.action_shortcut).isVisible = ShortcutManagerCompat.isRequestPinShortcutSupported(this)
|
||||||
menu.findItem(R.id.action_browser).isVisible =
|
menu.findItem(R.id.action_shiki_track).isVisible = viewModel.isScrobblingAvailable
|
||||||
manga?.source != MangaSource.LOCAL
|
|
||||||
menu.findItem(R.id.action_shortcut).isVisible =
|
|
||||||
ShortcutManagerCompat.isRequestPinShortcutSupported(this)
|
|
||||||
return super.onPrepareOptionsMenu(menu)
|
return super.onPrepareOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||||
R.id.action_share -> {
|
|
||||||
viewModel.manga.value?.let {
|
|
||||||
if (it.source == MangaSource.LOCAL) {
|
|
||||||
ShareHelper(this).shareCbz(listOf(it.url.toUri().toFile()))
|
|
||||||
} else {
|
|
||||||
ShareHelper(this).shareMangaLink(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
R.id.action_delete -> {
|
R.id.action_delete -> {
|
||||||
val title = viewModel.manga.value?.title.orEmpty()
|
val title = viewModel.manga.value?.title.orEmpty()
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
@@ -212,6 +215,12 @@ class DetailsActivity :
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.action_shiki_track -> {
|
||||||
|
viewModel.manga.value?.let {
|
||||||
|
ScrobblingSelectorBottomSheet.show(supportFragmentManager, it)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.action_shortcut -> {
|
R.id.action_shortcut -> {
|
||||||
viewModel.manga.value?.let {
|
viewModel.manga.value?.let {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
|
|||||||
@@ -8,16 +8,20 @@ import android.view.*
|
|||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
|
import androidx.core.net.toFile
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.text.parseAsHtml
|
import androidx.core.text.parseAsHtml
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.request.ImageRequest
|
import coil.request.ImageRequest
|
||||||
|
import coil.size.Scale
|
||||||
import coil.util.CoilUtils
|
import coil.util.CoilUtils
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.android.ext.android.get
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.android.ext.android.inject
|
||||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
@@ -29,7 +33,9 @@ import org.koitharu.kotatsu.bookmarks.domain.Bookmark
|
|||||||
import org.koitharu.kotatsu.bookmarks.ui.BookmarksAdapter
|
import org.koitharu.kotatsu.bookmarks.ui.BookmarksAdapter
|
||||||
import org.koitharu.kotatsu.core.model.MangaHistory
|
import org.koitharu.kotatsu.core.model.MangaHistory
|
||||||
import org.koitharu.kotatsu.databinding.FragmentDetailsBinding
|
import org.koitharu.kotatsu.databinding.FragmentDetailsBinding
|
||||||
|
import org.koitharu.kotatsu.details.ui.scrobbling.ScrobblingInfoBottomSheet
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.select.FavouriteCategoriesBottomSheet
|
import org.koitharu.kotatsu.favourites.ui.categories.select.FavouriteCategoriesBottomSheet
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
import org.koitharu.kotatsu.image.ui.ImageActivity
|
import org.koitharu.kotatsu.image.ui.ImageActivity
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
@@ -37,9 +43,11 @@ import org.koitharu.kotatsu.parsers.model.MangaState
|
|||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
import org.koitharu.kotatsu.reader.ui.ReaderActivity
|
||||||
import org.koitharu.kotatsu.reader.ui.ReaderState
|
import org.koitharu.kotatsu.reader.ui.ReaderState
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.model.ScrobblingInfo
|
||||||
import org.koitharu.kotatsu.search.ui.MangaListActivity
|
import org.koitharu.kotatsu.search.ui.MangaListActivity
|
||||||
import org.koitharu.kotatsu.search.ui.SearchActivity
|
import org.koitharu.kotatsu.search.ui.SearchActivity
|
||||||
import org.koitharu.kotatsu.utils.FileSize
|
import org.koitharu.kotatsu.utils.FileSize
|
||||||
|
import org.koitharu.kotatsu.utils.ShareHelper
|
||||||
import org.koitharu.kotatsu.utils.ext.*
|
import org.koitharu.kotatsu.utils.ext.*
|
||||||
|
|
||||||
class DetailsFragment :
|
class DetailsFragment :
|
||||||
@@ -52,11 +60,6 @@ class DetailsFragment :
|
|||||||
private val viewModel by sharedViewModel<DetailsViewModel>()
|
private val viewModel by sharedViewModel<DetailsViewModel>()
|
||||||
private val coil by inject<ImageLoader>(mode = LazyThreadSafetyMode.NONE)
|
private val coil by inject<ImageLoader>(mode = LazyThreadSafetyMode.NONE)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onInflateView(
|
override fun onInflateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
@@ -69,6 +72,7 @@ class DetailsFragment :
|
|||||||
binding.buttonRead.setOnClickListener(this)
|
binding.buttonRead.setOnClickListener(this)
|
||||||
binding.buttonRead.setOnLongClickListener(this)
|
binding.buttonRead.setOnLongClickListener(this)
|
||||||
binding.imageViewCover.setOnClickListener(this)
|
binding.imageViewCover.setOnClickListener(this)
|
||||||
|
binding.scrobblingLayout.root.setOnClickListener(this)
|
||||||
binding.textViewDescription.movementMethod = LinkMovementMethod.getInstance()
|
binding.textViewDescription.movementMethod = LinkMovementMethod.getInstance()
|
||||||
binding.chipsTags.onChipClickListener = this
|
binding.chipsTags.onChipClickListener = this
|
||||||
viewModel.manga.observe(viewLifecycleOwner, ::onMangaUpdated)
|
viewModel.manga.observe(viewLifecycleOwner, ::onMangaUpdated)
|
||||||
@@ -76,11 +80,9 @@ class DetailsFragment :
|
|||||||
viewModel.favouriteCategories.observe(viewLifecycleOwner, ::onFavouriteChanged)
|
viewModel.favouriteCategories.observe(viewLifecycleOwner, ::onFavouriteChanged)
|
||||||
viewModel.readingHistory.observe(viewLifecycleOwner, ::onHistoryChanged)
|
viewModel.readingHistory.observe(viewLifecycleOwner, ::onHistoryChanged)
|
||||||
viewModel.bookmarks.observe(viewLifecycleOwner, ::onBookmarksChanged)
|
viewModel.bookmarks.observe(viewLifecycleOwner, ::onBookmarksChanged)
|
||||||
}
|
viewModel.scrobblingInfo.observe(viewLifecycleOwner, ::onScrobblingInfoChanged)
|
||||||
|
viewModel.description.observe(viewLifecycleOwner, ::onDescriptionChanged)
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
addMenuProvider(DetailsMenuProvider())
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
inflater.inflate(R.menu.opt_details_info, menu)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClick(item: Bookmark, view: View) {
|
override fun onItemClick(item: Bookmark, view: View) {
|
||||||
@@ -108,8 +110,6 @@ class DetailsFragment :
|
|||||||
textViewTitle.text = manga.title
|
textViewTitle.text = manga.title
|
||||||
textViewSubtitle.textAndVisible = manga.altTitle
|
textViewSubtitle.textAndVisible = manga.altTitle
|
||||||
textViewAuthor.textAndVisible = manga.author
|
textViewAuthor.textAndVisible = manga.author
|
||||||
textViewDescription.text = manga.description?.parseAsHtml()?.takeUnless(Spanned::isBlank)
|
|
||||||
?: getString(R.string.no_description)
|
|
||||||
when (manga.state) {
|
when (manga.state) {
|
||||||
MangaState.FINISHED -> {
|
MangaState.FINISHED -> {
|
||||||
textViewState.apply {
|
textViewState.apply {
|
||||||
@@ -172,6 +172,14 @@ class DetailsFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onDescriptionChanged(description: CharSequence?) {
|
||||||
|
if (description.isNullOrBlank()) {
|
||||||
|
binding.textViewDescription.setText(R.string.no_description)
|
||||||
|
} else {
|
||||||
|
binding.textViewDescription.text = description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun onHistoryChanged(history: MangaHistory?) {
|
private fun onHistoryChanged(history: MangaHistory?) {
|
||||||
with(binding.buttonRead) {
|
with(binding.buttonRead) {
|
||||||
if (history == null) {
|
if (history == null) {
|
||||||
@@ -182,6 +190,7 @@ class DetailsFragment :
|
|||||||
setIconResource(R.drawable.ic_play)
|
setIconResource(R.drawable.ic_play)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.progressView.setPercent(history?.percent ?: PROGRESS_NONE, animate = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFavouriteChanged(isFavourite: Boolean) {
|
private fun onFavouriteChanged(isFavourite: Boolean) {
|
||||||
@@ -215,12 +224,39 @@ class DetailsFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onScrobblingInfoChanged(scrobbling: ScrobblingInfo?) {
|
||||||
|
with(binding.scrobblingLayout) {
|
||||||
|
root.isVisible = scrobbling != null
|
||||||
|
if (scrobbling == null) {
|
||||||
|
CoilUtils.dispose(imageViewCover)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
imageViewCover.newImageRequest(scrobbling.coverUrl)
|
||||||
|
.crossfade(true)
|
||||||
|
.placeholder(R.drawable.ic_placeholder)
|
||||||
|
.fallback(R.drawable.ic_placeholder)
|
||||||
|
.error(R.drawable.ic_placeholder)
|
||||||
|
.scale(Scale.FILL)
|
||||||
|
.lifecycle(viewLifecycleOwner)
|
||||||
|
.enqueueWith(coil)
|
||||||
|
textViewTitle.text = scrobbling.title
|
||||||
|
textViewTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, scrobbling.scrobbler.iconResId, 0)
|
||||||
|
ratingBar.rating = scrobbling.rating * ratingBar.numStars
|
||||||
|
textViewStatus.text = scrobbling.status?.let {
|
||||||
|
resources.getStringArray(R.array.scrobbling_statuses).getOrNull(it.ordinal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val manga = viewModel.manga.value ?: return
|
val manga = viewModel.manga.value ?: return
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.button_favorite -> {
|
R.id.button_favorite -> {
|
||||||
FavouriteCategoriesBottomSheet.show(childFragmentManager, manga)
|
FavouriteCategoriesBottomSheet.show(childFragmentManager, manga)
|
||||||
}
|
}
|
||||||
|
R.id.scrobbling_layout -> {
|
||||||
|
ScrobblingInfoBottomSheet.show(childFragmentManager)
|
||||||
|
}
|
||||||
R.id.button_read -> {
|
R.id.button_read -> {
|
||||||
val chapterId = viewModel.readingHistory.value?.chapterId
|
val chapterId = viewModel.readingHistory.value?.chapterId
|
||||||
if (chapterId != null && manga.chapters?.none { x -> x.id == chapterId } == true) {
|
if (chapterId != null && manga.chapters?.none { x -> x.id == chapterId } == true) {
|
||||||
@@ -329,4 +365,26 @@ class DetailsFragment :
|
|||||||
} ?: request.fallback(R.drawable.ic_placeholder)
|
} ?: request.fallback(R.drawable.ic_placeholder)
|
||||||
request.enqueueWith(coil)
|
request.enqueueWith(coil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inner class DetailsMenuProvider : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_details_info, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
|
||||||
|
R.id.action_share -> {
|
||||||
|
viewModel.manga.value?.let {
|
||||||
|
val context = requireContext()
|
||||||
|
if (it.source == MangaSource.LOCAL) {
|
||||||
|
ShareHelper(context).shareCbz(listOf(it.url.toUri().toFile()))
|
||||||
|
} else {
|
||||||
|
ShareHelper(context).shareMangaLink(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,16 @@
|
|||||||
package org.koitharu.kotatsu.details.ui
|
package org.koitharu.kotatsu.details.ui
|
||||||
|
|
||||||
import androidx.lifecycle.*
|
import android.text.Html
|
||||||
import kotlinx.coroutines.*
|
import androidx.core.text.parseAsHtml
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.asFlow
|
||||||
|
import androidx.lifecycle.asLiveData
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.plus
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||||
import org.koitharu.kotatsu.base.domain.MangaIntent
|
import org.koitharu.kotatsu.base.domain.MangaIntent
|
||||||
@@ -19,6 +27,8 @@ import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
|||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
import org.koitharu.kotatsu.parsers.util.mapToSet
|
import org.koitharu.kotatsu.parsers.util.mapToSet
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.Scrobbler
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.model.ScrobblingStatus
|
||||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||||
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
import org.koitharu.kotatsu.utils.SingleLiveEvent
|
||||||
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
||||||
@@ -30,10 +40,12 @@ class DetailsViewModel(
|
|||||||
private val historyRepository: HistoryRepository,
|
private val historyRepository: HistoryRepository,
|
||||||
favouritesRepository: FavouritesRepository,
|
favouritesRepository: FavouritesRepository,
|
||||||
private val localMangaRepository: LocalMangaRepository,
|
private val localMangaRepository: LocalMangaRepository,
|
||||||
private val trackingRepository: TrackingRepository,
|
trackingRepository: TrackingRepository,
|
||||||
mangaDataRepository: MangaDataRepository,
|
mangaDataRepository: MangaDataRepository,
|
||||||
private val bookmarksRepository: BookmarksRepository,
|
private val bookmarksRepository: BookmarksRepository,
|
||||||
private val settings: AppSettings,
|
private val settings: AppSettings,
|
||||||
|
private val scrobbler: Scrobbler,
|
||||||
|
private val imageGetter: Html.ImageGetter,
|
||||||
) : BaseViewModel() {
|
) : BaseViewModel() {
|
||||||
|
|
||||||
private val delegate = MangaDetailsDelegate(
|
private val delegate = MangaDetailsDelegate(
|
||||||
@@ -54,9 +66,8 @@ class DetailsViewModel(
|
|||||||
private val favourite = favouritesRepository.observeCategoriesIds(delegate.mangaId).map { it.isNotEmpty() }
|
private val favourite = favouritesRepository.observeCategoriesIds(delegate.mangaId).map { it.isNotEmpty() }
|
||||||
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, false)
|
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, false)
|
||||||
|
|
||||||
private val newChapters = viewModelScope.async(Dispatchers.Default) {
|
private val newChapters = trackingRepository.observeNewChaptersCount(delegate.mangaId)
|
||||||
trackingRepository.getNewChaptersCount(delegate.mangaId)
|
.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, 0)
|
||||||
}
|
|
||||||
|
|
||||||
private val chaptersQuery = MutableStateFlow("")
|
private val chaptersQuery = MutableStateFlow("")
|
||||||
|
|
||||||
@@ -65,15 +76,32 @@ class DetailsViewModel(
|
|||||||
|
|
||||||
val manga = delegate.manga.filterNotNull().asLiveData(viewModelScope.coroutineContext)
|
val manga = delegate.manga.filterNotNull().asLiveData(viewModelScope.coroutineContext)
|
||||||
val favouriteCategories = favourite.asLiveData(viewModelScope.coroutineContext)
|
val favouriteCategories = favourite.asLiveData(viewModelScope.coroutineContext)
|
||||||
val newChaptersCount = liveData(viewModelScope.coroutineContext) { emit(newChapters.await()) }
|
val newChaptersCount = newChapters.asLiveData(viewModelScope.coroutineContext)
|
||||||
val readingHistory = history.asLiveData(viewModelScope.coroutineContext)
|
val readingHistory = history.asLiveData(viewModelScope.coroutineContext)
|
||||||
val isChaptersReversed = chaptersReversed.asLiveData(viewModelScope.coroutineContext)
|
val isChaptersReversed = chaptersReversed.asLiveData(viewModelScope.coroutineContext)
|
||||||
|
|
||||||
val bookmarks = delegate.manga.flatMapLatest {
|
val bookmarks = delegate.manga.flatMapLatest {
|
||||||
if (it != null) bookmarksRepository.observeBookmarks(it) else flowOf(emptyList())
|
if (it != null) bookmarksRepository.observeBookmarks(it) else flowOf(emptyList())
|
||||||
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default)
|
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default, emptyList())
|
||||||
|
|
||||||
|
val description = delegate.manga
|
||||||
|
.distinctUntilChangedBy { it?.description.orEmpty() }
|
||||||
|
.transformLatest {
|
||||||
|
val description = it?.description
|
||||||
|
if (description.isNullOrEmpty()) {
|
||||||
|
emit(null)
|
||||||
|
} else {
|
||||||
|
emit(description.parseAsHtml())
|
||||||
|
emit(description.parseAsHtml(imageGetter = imageGetter))
|
||||||
|
}
|
||||||
|
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default, null)
|
||||||
|
|
||||||
val onMangaRemoved = SingleLiveEvent<Manga>()
|
val onMangaRemoved = SingleLiveEvent<Manga>()
|
||||||
|
val isScrobblingAvailable: Boolean
|
||||||
|
get() = scrobbler.isAvailable
|
||||||
|
|
||||||
|
val scrobblingInfo = scrobbler.observeScrobblingInfo(delegate.mangaId)
|
||||||
|
.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default, null)
|
||||||
|
|
||||||
val branches: LiveData<List<String?>> = delegate.manga.map {
|
val branches: LiveData<List<String?>> = delegate.manga.map {
|
||||||
val chapters = it?.chapters ?: return@map emptyList()
|
val chapters = it?.chapters ?: return@map emptyList()
|
||||||
@@ -87,9 +115,12 @@ class DetailsViewModel(
|
|||||||
branches.indexOf(selected)
|
branches.indexOf(selected)
|
||||||
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default)
|
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default)
|
||||||
|
|
||||||
val isChaptersEmpty: LiveData<Boolean> = delegate.manga.map { m ->
|
val isChaptersEmpty: LiveData<Boolean> = combine(
|
||||||
m != null && m.chapters.isNullOrEmpty()
|
delegate.manga,
|
||||||
}.asLiveDataDistinct(viewModelScope.coroutineContext + Dispatchers.Default, false)
|
isLoading.asFlow(),
|
||||||
|
) { m, loading ->
|
||||||
|
m != null && m.chapters.isNullOrEmpty() && !loading
|
||||||
|
}.asLiveDataDistinct(viewModelScope.coroutineContext, false)
|
||||||
|
|
||||||
val chapters = combine(
|
val chapters = combine(
|
||||||
combine(
|
combine(
|
||||||
@@ -97,8 +128,9 @@ class DetailsViewModel(
|
|||||||
delegate.relatedManga,
|
delegate.relatedManga,
|
||||||
history,
|
history,
|
||||||
delegate.selectedBranch,
|
delegate.selectedBranch,
|
||||||
) { manga, related, history, branch ->
|
newChapters,
|
||||||
delegate.mapChapters(manga, related, history, newChapters.await(), branch)
|
) { manga, related, history, branch, news ->
|
||||||
|
delegate.mapChapters(manga, related, history, news, branch)
|
||||||
},
|
},
|
||||||
chaptersReversed,
|
chaptersReversed,
|
||||||
chaptersQuery,
|
chaptersQuery,
|
||||||
@@ -179,6 +211,25 @@ class DetailsViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateScrobbling(rating: Float, status: ScrobblingStatus?) {
|
||||||
|
launchJob(Dispatchers.Default) {
|
||||||
|
scrobbler.updateScrobblingInfo(
|
||||||
|
mangaId = delegate.mangaId,
|
||||||
|
rating = rating,
|
||||||
|
status = status,
|
||||||
|
comment = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unregisterScrobbling() {
|
||||||
|
launchJob(Dispatchers.Default) {
|
||||||
|
scrobbler.unregisterScrobbling(
|
||||||
|
mangaId = delegate.mangaId
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun doLoad() = launchLoadingJob(Dispatchers.Default) {
|
private fun doLoad() = launchLoadingJob(Dispatchers.Default) {
|
||||||
delegate.doLoad()
|
delegate.doLoad()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.koitharu.kotatsu.details.ui
|
|||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import org.acra.ACRA
|
||||||
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
import org.koitharu.kotatsu.base.domain.MangaDataRepository
|
||||||
import org.koitharu.kotatsu.base.domain.MangaIntent
|
import org.koitharu.kotatsu.base.domain.MangaIntent
|
||||||
import org.koitharu.kotatsu.core.exceptions.MangaNotFoundException
|
import org.koitharu.kotatsu.core.exceptions.MangaNotFoundException
|
||||||
@@ -13,6 +14,7 @@ import org.koitharu.kotatsu.details.ui.model.ChapterListItem
|
|||||||
import org.koitharu.kotatsu.details.ui.model.toListItem
|
import org.koitharu.kotatsu.details.ui.model.toListItem
|
||||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
|
||||||
|
import org.koitharu.kotatsu.parsers.exception.ParseException
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
@@ -20,6 +22,7 @@ import org.koitharu.kotatsu.parsers.util.mapToSet
|
|||||||
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
import org.koitharu.kotatsu.parsers.util.toTitleCase
|
||||||
import org.koitharu.kotatsu.utils.ext.iterator
|
import org.koitharu.kotatsu.utils.ext.iterator
|
||||||
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
|
import org.koitharu.kotatsu.utils.ext.setCurrentManga
|
||||||
|
|
||||||
class MangaDetailsDelegate(
|
class MangaDetailsDelegate(
|
||||||
private val intent: MangaIntent,
|
private val intent: MangaIntent,
|
||||||
@@ -32,6 +35,7 @@ class MangaDetailsDelegate(
|
|||||||
private val mangaData = MutableStateFlow(intent.manga)
|
private val mangaData = MutableStateFlow(intent.manga)
|
||||||
|
|
||||||
val selectedBranch = MutableStateFlow<String?>(null)
|
val selectedBranch = MutableStateFlow<String?>(null)
|
||||||
|
|
||||||
// Remote manga for saved and saved for remote
|
// Remote manga for saved and saved for remote
|
||||||
val relatedManga = MutableStateFlow<Manga?>(null)
|
val relatedManga = MutableStateFlow<Manga?>(null)
|
||||||
val manga: StateFlow<Manga?>
|
val manga: StateFlow<Manga?>
|
||||||
@@ -41,6 +45,7 @@ class MangaDetailsDelegate(
|
|||||||
suspend fun doLoad() {
|
suspend fun doLoad() {
|
||||||
var manga = mangaDataRepository.resolveIntent(intent)
|
var manga = mangaDataRepository.resolveIntent(intent)
|
||||||
?: throw MangaNotFoundException("Cannot find manga")
|
?: throw MangaNotFoundException("Cannot find manga")
|
||||||
|
ACRA.setCurrentManga(manga)
|
||||||
mangaData.value = manga
|
mangaData.value = manga
|
||||||
manga = MangaRepository(manga.source).getDetails(manga)
|
manga = MangaRepository(manga.source).getDetails(manga)
|
||||||
// find default branch
|
// find default branch
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
package org.koitharu.kotatsu.details.ui.scrobbling
|
||||||
|
|
||||||
|
import android.app.ActivityOptions
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.RatingBar
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.widget.PopupMenu
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import coil.ImageLoader
|
||||||
|
import coil.request.ImageRequest
|
||||||
|
import coil.size.Scale
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.base.ui.BaseBottomSheet
|
||||||
|
import org.koitharu.kotatsu.databinding.SheetScrobblingBinding
|
||||||
|
import org.koitharu.kotatsu.details.ui.DetailsViewModel
|
||||||
|
import org.koitharu.kotatsu.image.ui.ImageActivity
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.model.ScrobblingInfo
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.model.ScrobblingStatus
|
||||||
|
import org.koitharu.kotatsu.scrobbling.ui.selector.ScrobblingSelectorBottomSheet
|
||||||
|
import org.koitharu.kotatsu.utils.ext.enqueueWith
|
||||||
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
|
|
||||||
|
class ScrobblingInfoBottomSheet :
|
||||||
|
BaseBottomSheet<SheetScrobblingBinding>(),
|
||||||
|
AdapterView.OnItemSelectedListener,
|
||||||
|
RatingBar.OnRatingBarChangeListener,
|
||||||
|
View.OnClickListener,
|
||||||
|
PopupMenu.OnMenuItemClickListener {
|
||||||
|
|
||||||
|
private val viewModel by sharedViewModel<DetailsViewModel>()
|
||||||
|
private val coil by inject<ImageLoader>(mode = LazyThreadSafetyMode.NONE)
|
||||||
|
private var menu: PopupMenu? = null
|
||||||
|
|
||||||
|
override fun onInflateView(inflater: LayoutInflater, container: ViewGroup?): SheetScrobblingBinding {
|
||||||
|
return SheetScrobblingBinding.inflate(inflater, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
viewModel.scrobblingInfo.observe(viewLifecycleOwner, ::onScrobblingInfoChanged)
|
||||||
|
viewModel.onError.observe(viewLifecycleOwner) {
|
||||||
|
Toast.makeText(view.context, it.getDisplayMessage(view.resources), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.spinnerStatus.onItemSelectedListener = this
|
||||||
|
binding.ratingBar.onRatingBarChangeListener = this
|
||||||
|
binding.buttonMenu.setOnClickListener(this)
|
||||||
|
binding.imageViewCover.setOnClickListener(this)
|
||||||
|
binding.textViewDescription.movementMethod = LinkMovementMethod.getInstance()
|
||||||
|
|
||||||
|
menu = PopupMenu(view.context, binding.buttonMenu).apply {
|
||||||
|
inflate(R.menu.opt_scrobbling)
|
||||||
|
setOnMenuItemClickListener(this@ScrobblingInfoBottomSheet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
super.onDestroyView()
|
||||||
|
menu = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
viewModel.updateScrobbling(
|
||||||
|
rating = binding.ratingBar.rating / binding.ratingBar.numStars,
|
||||||
|
status = enumValues<ScrobblingStatus>().getOrNull(position),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) = Unit
|
||||||
|
|
||||||
|
override fun onRatingChanged(ratingBar: RatingBar, rating: Float, fromUser: Boolean) {
|
||||||
|
if (fromUser) {
|
||||||
|
viewModel.updateScrobbling(
|
||||||
|
rating = rating / ratingBar.numStars,
|
||||||
|
status = enumValues<ScrobblingStatus>().getOrNull(binding.spinnerStatus.selectedItemPosition),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onClick(v: View) {
|
||||||
|
when (v.id) {
|
||||||
|
R.id.button_menu -> menu?.show()
|
||||||
|
R.id.imageView_cover -> {
|
||||||
|
val coverUrl = viewModel.scrobblingInfo.value?.coverUrl ?: return
|
||||||
|
val options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.width, v.height)
|
||||||
|
startActivity(ImageActivity.newIntent(v.context, coverUrl), options.toBundle())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onScrobblingInfoChanged(scrobbling: ScrobblingInfo?) {
|
||||||
|
if (scrobbling == null) {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
binding.textViewTitle.text = scrobbling.title
|
||||||
|
binding.ratingBar.rating = scrobbling.rating * binding.ratingBar.numStars
|
||||||
|
binding.textViewDescription.text = scrobbling.description
|
||||||
|
binding.spinnerStatus.setSelection(scrobbling.status?.ordinal ?: -1)
|
||||||
|
ImageRequest.Builder(context ?: return)
|
||||||
|
.target(binding.imageViewCover)
|
||||||
|
.data(scrobbling.coverUrl)
|
||||||
|
.crossfade(true)
|
||||||
|
.lifecycle(viewLifecycleOwner)
|
||||||
|
.placeholder(R.drawable.ic_placeholder)
|
||||||
|
.fallback(R.drawable.ic_placeholder)
|
||||||
|
.error(R.drawable.ic_placeholder)
|
||||||
|
.scale(Scale.FILL)
|
||||||
|
.enqueueWith(coil)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
private const val TAG = "ScrobblingInfoBottomSheet"
|
||||||
|
|
||||||
|
fun show(fm: FragmentManager) = ScrobblingInfoBottomSheet().show(fm, TAG)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemClick(item: MenuItem): Boolean {
|
||||||
|
when (item.itemId) {
|
||||||
|
R.id.action_browser -> {
|
||||||
|
val url = viewModel.scrobblingInfo.value?.externalUrl ?: return false
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
|
||||||
|
startActivity(
|
||||||
|
Intent.createChooser(intent, getString(R.string.open_in_browser))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
R.id.action_unregister -> {
|
||||||
|
viewModel.unregisterScrobbling()
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
R.id.action_edit -> {
|
||||||
|
val manga = viewModel.manga.value ?: return false
|
||||||
|
ScrobblingSelectorBottomSheet.show(parentFragmentManager, manga)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@ import androidx.core.app.NotificationCompat
|
|||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.ui.CrashActivity
|
|
||||||
import org.koitharu.kotatsu.details.ui.DetailsActivity
|
import org.koitharu.kotatsu.details.ui.DetailsActivity
|
||||||
import org.koitharu.kotatsu.download.domain.DownloadState
|
import org.koitharu.kotatsu.download.domain.DownloadState
|
||||||
import org.koitharu.kotatsu.download.ui.DownloadsActivity
|
import org.koitharu.kotatsu.download.ui.DownloadsActivity
|
||||||
@@ -20,7 +20,6 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
import org.koitharu.kotatsu.parsers.util.format
|
import org.koitharu.kotatsu.parsers.util.format
|
||||||
import org.koitharu.kotatsu.utils.PendingIntentCompat
|
import org.koitharu.kotatsu.utils.PendingIntentCompat
|
||||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
import com.google.android.material.R as materialR
|
|
||||||
|
|
||||||
class DownloadNotification(private val context: Context, startId: Int) {
|
class DownloadNotification(private val context: Context, startId: Int) {
|
||||||
|
|
||||||
@@ -92,14 +91,6 @@ class DownloadNotification(private val context: Context, startId: Int) {
|
|||||||
builder.setContentText(message)
|
builder.setContentText(message)
|
||||||
builder.setAutoCancel(true)
|
builder.setAutoCancel(true)
|
||||||
builder.setOngoing(false)
|
builder.setOngoing(false)
|
||||||
builder.setContentIntent(
|
|
||||||
PendingIntent.getActivity(
|
|
||||||
context,
|
|
||||||
state.manga.hashCode(),
|
|
||||||
CrashActivity.newIntent(context, state.error),
|
|
||||||
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE
|
|
||||||
)
|
|
||||||
)
|
|
||||||
builder.setCategory(NotificationCompat.CATEGORY_ERROR)
|
builder.setCategory(NotificationCompat.CATEGORY_ERROR)
|
||||||
builder.setStyle(NotificationCompat.BigTextStyle().bigText(message))
|
builder.setStyle(NotificationCompat.BigTextStyle().bigText(message))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import org.koitharu.kotatsu.favourites.ui.list.FavouritesListViewModel
|
|||||||
val favouritesModule
|
val favouritesModule
|
||||||
get() = module {
|
get() = module {
|
||||||
|
|
||||||
factory { FavouritesRepository(get(), get()) }
|
single { FavouritesRepository(get(), get()) }
|
||||||
|
|
||||||
viewModel { categoryId ->
|
viewModel { categoryId ->
|
||||||
FavouritesListViewModel(categoryId.get(), get(), get(), get())
|
FavouritesListViewModel(categoryId.get(), get(), get(), get(), get())
|
||||||
}
|
}
|
||||||
viewModel { FavouritesCategoriesViewModel(get(), get()) }
|
viewModel { FavouritesCategoriesViewModel(get(), get()) }
|
||||||
viewModel { manga ->
|
viewModel { manga ->
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package org.koitharu.kotatsu.favourites.ui
|
package org.koitharu.kotatsu.favourites.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
@@ -19,12 +21,12 @@ import org.koitharu.kotatsu.base.ui.util.ActionModeListener
|
|||||||
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||||
import org.koitharu.kotatsu.databinding.FragmentFavouritesBinding
|
import org.koitharu.kotatsu.databinding.FragmentFavouritesBinding
|
||||||
import org.koitharu.kotatsu.databinding.ItemEmptyStateBinding
|
import org.koitharu.kotatsu.databinding.ItemEmptyStateBinding
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity
|
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesEditDelegate
|
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesEditDelegate
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.FavouritesCategoriesViewModel
|
import org.koitharu.kotatsu.favourites.ui.categories.FavouritesCategoriesViewModel
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.adapter.CategoryListModel
|
import org.koitharu.kotatsu.favourites.ui.categories.adapter.CategoryListModel
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.edit.FavouritesCategoryEditActivity
|
import org.koitharu.kotatsu.favourites.ui.categories.edit.FavouritesCategoryEditActivity
|
||||||
import org.koitharu.kotatsu.main.ui.AppBarOwner
|
import org.koitharu.kotatsu.main.ui.AppBarOwner
|
||||||
|
import org.koitharu.kotatsu.utils.ext.addMenuProvider
|
||||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
import org.koitharu.kotatsu.utils.ext.measureHeight
|
import org.koitharu.kotatsu.utils.ext.measureHeight
|
||||||
import org.koitharu.kotatsu.utils.ext.resolveDp
|
import org.koitharu.kotatsu.utils.ext.resolveDp
|
||||||
@@ -43,11 +45,6 @@ class FavouritesContainerFragment :
|
|||||||
private var pagerAdapter: FavouritesPagerAdapter? = null
|
private var pagerAdapter: FavouritesPagerAdapter? = null
|
||||||
private var stubBinding: ItemEmptyStateBinding? = null
|
private var stubBinding: ItemEmptyStateBinding? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onInflateView(
|
override fun onInflateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?
|
container: ViewGroup?
|
||||||
@@ -61,6 +58,7 @@ class FavouritesContainerFragment :
|
|||||||
pagerAdapter = adapter
|
pagerAdapter = adapter
|
||||||
TabLayoutMediator(binding.tabs, binding.pager, adapter).attach()
|
TabLayoutMediator(binding.tabs, binding.pager, adapter).attach()
|
||||||
actionModeDelegate.addListener(this, viewLifecycleOwner)
|
actionModeDelegate.addListener(this, viewLifecycleOwner)
|
||||||
|
addMenuProvider(FavouritesContainerMenuProvider(view.context))
|
||||||
|
|
||||||
viewModel.visibleCategories.observe(viewLifecycleOwner, ::onCategoriesChanged)
|
viewModel.visibleCategories.observe(viewLifecycleOwner, ::onCategoriesChanged)
|
||||||
viewModel.onError.observe(viewLifecycleOwner, ::onError)
|
viewModel.onError.observe(viewLifecycleOwner, ::onError)
|
||||||
@@ -115,21 +113,6 @@ class FavouritesContainerFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.opt_favourites, menu)
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
|
||||||
R.id.action_categories -> {
|
|
||||||
context?.let {
|
|
||||||
startActivity(CategoriesActivity.newIntent(it))
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onError(e: Throwable) {
|
private fun onError(e: Throwable) {
|
||||||
Snackbar.make(binding.pager, e.getDisplayMessage(resources), Snackbar.LENGTH_LONG).show()
|
Snackbar.make(binding.pager, e.getDisplayMessage(resources), Snackbar.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package org.koitharu.kotatsu.favourites.ui
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity
|
||||||
|
|
||||||
|
class FavouritesContainerMenuProvider(
|
||||||
|
private val context: Context,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_favourites, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
return when (menuItem.itemId) {
|
||||||
|
R.id.action_categories -> {
|
||||||
|
context.startActivity(CategoriesActivity.newIntent(context))
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
class CategoriesEditDelegate(
|
class CategoriesEditDelegate(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
@@ -11,9 +12,10 @@ class CategoriesEditDelegate(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
fun deleteCategory(category: FavouriteCategory) {
|
fun deleteCategory(category: FavouriteCategory) {
|
||||||
MaterialAlertDialogBuilder(context)
|
MaterialAlertDialogBuilder(context, materialR.style.ThemeOverlay_Material3_MaterialAlertDialog_Centered)
|
||||||
.setMessage(context.getString(R.string.category_delete_confirm, category.title))
|
.setMessage(context.getString(R.string.category_delete_confirm, category.title))
|
||||||
.setTitle(R.string.remove_category)
|
.setTitle(R.string.remove_category)
|
||||||
|
.setIcon(R.drawable.ic_delete)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.remove) { _, _ ->
|
.setPositiveButton(R.string.remove) { _, _ ->
|
||||||
callback.onDeleteCategory(category)
|
callback.onDeleteCategory(category)
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package org.koitharu.kotatsu.favourites.ui.categories.edit
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
@@ -24,7 +22,8 @@ import org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity
|
|||||||
import org.koitharu.kotatsu.parsers.model.SortOrder
|
import org.koitharu.kotatsu.parsers.model.SortOrder
|
||||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
|
|
||||||
class FavouritesCategoryEditActivity : BaseActivity<ActivityCategoryEditBinding>(), AdapterView.OnItemClickListener {
|
class FavouritesCategoryEditActivity : BaseActivity<ActivityCategoryEditBinding>(), AdapterView.OnItemClickListener,
|
||||||
|
View.OnClickListener {
|
||||||
|
|
||||||
private val viewModel by viewModel<FavouritesCategoryEditViewModel> {
|
private val viewModel by viewModel<FavouritesCategoryEditViewModel> {
|
||||||
parametersOf(intent.getLongExtra(EXTRA_ID, NO_ID))
|
parametersOf(intent.getLongExtra(EXTRA_ID, NO_ID))
|
||||||
@@ -39,6 +38,7 @@ class FavouritesCategoryEditActivity : BaseActivity<ActivityCategoryEditBinding>
|
|||||||
setHomeAsUpIndicator(com.google.android.material.R.drawable.abc_ic_clear_material)
|
setHomeAsUpIndicator(com.google.android.material.R.drawable.abc_ic_clear_material)
|
||||||
}
|
}
|
||||||
initSortSpinner()
|
initSortSpinner()
|
||||||
|
binding.buttonDone.setOnClickListener(this)
|
||||||
|
|
||||||
viewModel.onSaved.observe(this) { finishAfterTransition() }
|
viewModel.onSaved.observe(this) { finishAfterTransition() }
|
||||||
viewModel.category.observe(this, ::onCategoryChanged)
|
viewModel.category.observe(this, ::onCategoryChanged)
|
||||||
@@ -62,22 +62,14 @@ class FavouritesCategoryEditActivity : BaseActivity<ActivityCategoryEditBinding>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onClick(v: View) {
|
||||||
menuInflater.inflate(R.menu.opt_config, menu)
|
when (v.id) {
|
||||||
menu.findItem(R.id.action_done)?.setTitle(R.string.save)
|
R.id.button_done -> viewModel.save(
|
||||||
return super.onCreateOptionsMenu(menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
|
||||||
R.id.action_done -> {
|
|
||||||
viewModel.save(
|
|
||||||
title = binding.editName.text?.toString().orEmpty(),
|
title = binding.editName.text?.toString().orEmpty(),
|
||||||
sortOrder = getSelectedSortOrder(),
|
sortOrder = getSelectedSortOrder(),
|
||||||
isTrackerEnabled = binding.switchTracker.isChecked,
|
isTrackerEnabled = binding.switchTracker.isChecked,
|
||||||
)
|
)
|
||||||
true
|
|
||||||
}
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onWindowInsetsChanged(insets: Insets) {
|
override fun onWindowInsetsChanged(insets: Insets) {
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package org.koitharu.kotatsu.favourites.ui.categories.select
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
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.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
import org.koin.core.parameter.parametersOf
|
import org.koin.core.parameter.parametersOf
|
||||||
@@ -28,7 +26,7 @@ class FavouriteCategoriesBottomSheet :
|
|||||||
BaseBottomSheet<DialogFavoriteCategoriesBinding>(),
|
BaseBottomSheet<DialogFavoriteCategoriesBinding>(),
|
||||||
OnListItemClickListener<MangaCategoryItem>,
|
OnListItemClickListener<MangaCategoryItem>,
|
||||||
CategoriesEditDelegate.CategoriesEditCallback,
|
CategoriesEditDelegate.CategoriesEditCallback,
|
||||||
Toolbar.OnMenuItemClickListener, View.OnClickListener {
|
View.OnClickListener {
|
||||||
|
|
||||||
private val viewModel by viewModel<MangaCategoriesViewModel> {
|
private val viewModel by viewModel<MangaCategoriesViewModel> {
|
||||||
parametersOf(requireNotNull(arguments?.getParcelableArrayList<ParcelableManga>(KEY_MANGA_LIST)).map { it.manga })
|
parametersOf(requireNotNull(arguments?.getParcelableArrayList<ParcelableManga>(KEY_MANGA_LIST)).map { it.manga })
|
||||||
@@ -45,7 +43,7 @@ class FavouriteCategoriesBottomSheet :
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
adapter = MangaCategoriesAdapter(this)
|
adapter = MangaCategoriesAdapter(this)
|
||||||
binding.recyclerViewCategories.adapter = adapter
|
binding.recyclerViewCategories.adapter = adapter
|
||||||
binding.toolbar.setOnMenuItemClickListener(this)
|
binding.buttonDone.setOnClickListener(this)
|
||||||
binding.itemCreate.setOnClickListener(this)
|
binding.itemCreate.setOnClickListener(this)
|
||||||
|
|
||||||
viewModel.content.observe(viewLifecycleOwner, this::onContentChanged)
|
viewModel.content.observe(viewLifecycleOwner, this::onContentChanged)
|
||||||
@@ -57,19 +55,10 @@ class FavouriteCategoriesBottomSheet :
|
|||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onMenuItemClick(item: MenuItem): Boolean {
|
|
||||||
return when (item.itemId) {
|
|
||||||
R.id.action_done -> {
|
|
||||||
dismiss()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.item_create -> startActivity(FavouritesCategoryEditActivity.newIntent(requireContext()))
|
R.id.item_create -> startActivity(FavouritesCategoryEditActivity.newIntent(requireContext()))
|
||||||
|
R.id.button_done -> dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,15 @@ package org.koitharu.kotatsu.favourites.ui.list
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.core.view.iterator
|
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
import org.koin.core.parameter.parametersOf
|
import org.koin.core.parameter.parametersOf
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.ui.titleRes
|
|
||||||
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity
|
|
||||||
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.utils.ext.addMenuProvider
|
||||||
import org.koitharu.kotatsu.utils.ext.withArgs
|
import org.koitharu.kotatsu.utils.ext.withArgs
|
||||||
|
|
||||||
class FavouritesListFragment : MangaListFragment() {
|
class FavouritesListFragment : MangaListFragment() {
|
||||||
@@ -30,47 +27,14 @@ class FavouritesListFragment : MangaListFragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
viewModel.sortOrder.observe(viewLifecycleOwner) { activity?.invalidateOptionsMenu() }
|
viewModel.sortOrder.observe(viewLifecycleOwner) { activity?.invalidateOptionsMenu() }
|
||||||
|
|
||||||
|
if (categoryId != NO_ID) {
|
||||||
|
addMenuProvider(FavouritesListMenuProvider(viewModel))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onScrolledToEnd() = Unit
|
override fun onScrolledToEnd() = Unit
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
if (categoryId != NO_ID) {
|
|
||||||
inflater.inflate(R.menu.opt_favourites_list, menu)
|
|
||||||
menu.findItem(R.id.action_order)?.subMenu?.let { submenu ->
|
|
||||||
for ((i, item) in CategoriesActivity.SORT_ORDERS.withIndex()) {
|
|
||||||
val menuItem = submenu.add(R.id.group_order, Menu.NONE, i, item.titleRes)
|
|
||||||
menuItem.isCheckable = true
|
|
||||||
}
|
|
||||||
submenu.setGroupCheckable(R.id.group_order, true, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
||||||
super.onPrepareOptionsMenu(menu)
|
|
||||||
menu.findItem(R.id.action_order)?.subMenu?.let { submenu ->
|
|
||||||
val selectedOrder = viewModel.sortOrder.value
|
|
||||||
for (item in submenu) {
|
|
||||||
val order = CategoriesActivity.SORT_ORDERS.getOrNull(item.order)
|
|
||||||
item.isChecked = order == selectedOrder
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
return when {
|
|
||||||
item.itemId == R.id.action_order -> false
|
|
||||||
item.groupId == R.id.group_order -> {
|
|
||||||
val order = CategoriesActivity.SORT_ORDERS.getOrNull(item.order) ?: return false
|
|
||||||
viewModel.setSortOrder(order)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
mode.menuInflater.inflate(R.menu.mode_favourites, menu)
|
mode.menuInflater.inflate(R.menu.mode_favourites, menu)
|
||||||
return super.onCreateActionMode(mode, menu)
|
return super.onCreateActionMode(mode, menu)
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package org.koitharu.kotatsu.favourites.ui.list
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import androidx.core.view.iterator
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.core.ui.titleRes
|
||||||
|
import org.koitharu.kotatsu.favourites.ui.categories.CategoriesActivity
|
||||||
|
|
||||||
|
class FavouritesListMenuProvider(
|
||||||
|
private val viewModel: FavouritesListViewModel,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_favourites_list, menu)
|
||||||
|
menu.findItem(R.id.action_order)?.subMenu?.let { submenu ->
|
||||||
|
for ((i, item) in CategoriesActivity.SORT_ORDERS.withIndex()) {
|
||||||
|
val menuItem = submenu.add(R.id.group_order, Menu.NONE, i, item.titleRes)
|
||||||
|
menuItem.isCheckable = true
|
||||||
|
}
|
||||||
|
submenu.setGroupCheckable(R.id.group_order, true, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareMenu(menu: Menu) {
|
||||||
|
menu.findItem(R.id.action_order)?.subMenu?.let { submenu ->
|
||||||
|
val selectedOrder = viewModel.sortOrder.value
|
||||||
|
for (item in submenu) {
|
||||||
|
val order = CategoriesActivity.SORT_ORDERS.getOrNull(item.order)
|
||||||
|
item.isChecked = order == selectedOrder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
return when {
|
||||||
|
menuItem.itemId == R.id.action_order -> false
|
||||||
|
menuItem.groupId == R.id.group_order -> {
|
||||||
|
val order = CategoriesActivity.SORT_ORDERS.getOrNull(menuItem.order) ?: return false
|
||||||
|
viewModel.setSortOrder(order)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,9 @@ import org.koitharu.kotatsu.R
|
|||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
import org.koitharu.kotatsu.favourites.domain.FavouritesRepository
|
||||||
import org.koitharu.kotatsu.favourites.ui.list.FavouritesListFragment.Companion.NO_ID
|
import org.koitharu.kotatsu.favourites.ui.list.FavouritesListFragment.Companion.NO_ID
|
||||||
import org.koitharu.kotatsu.list.domain.CountersProvider
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
|
import org.koitharu.kotatsu.list.domain.ListExtraProvider
|
||||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||||
import org.koitharu.kotatsu.list.ui.model.EmptyState
|
import org.koitharu.kotatsu.list.ui.model.EmptyState
|
||||||
import org.koitharu.kotatsu.list.ui.model.LoadingState
|
import org.koitharu.kotatsu.list.ui.model.LoadingState
|
||||||
@@ -25,8 +27,9 @@ class FavouritesListViewModel(
|
|||||||
private val categoryId: Long,
|
private val categoryId: Long,
|
||||||
private val repository: FavouritesRepository,
|
private val repository: FavouritesRepository,
|
||||||
private val trackingRepository: TrackingRepository,
|
private val trackingRepository: TrackingRepository,
|
||||||
settings: AppSettings,
|
private val historyRepository: HistoryRepository,
|
||||||
) : MangaListViewModel(settings), CountersProvider {
|
private val settings: AppSettings,
|
||||||
|
) : MangaListViewModel(settings), ListExtraProvider {
|
||||||
|
|
||||||
var sortOrder: LiveData<SortOrder?> = if (categoryId == NO_ID) {
|
var sortOrder: LiveData<SortOrder?> = if (categoryId == NO_ID) {
|
||||||
MutableLiveData(null)
|
MutableLiveData(null)
|
||||||
@@ -47,7 +50,7 @@ class FavouritesListViewModel(
|
|||||||
when {
|
when {
|
||||||
list.isEmpty() -> listOf(
|
list.isEmpty() -> listOf(
|
||||||
EmptyState(
|
EmptyState(
|
||||||
icon = R.drawable.ic_heart_outline,
|
icon = R.drawable.ic_empty_favourites,
|
||||||
textPrimary = R.string.text_empty_holder_primary,
|
textPrimary = R.string.text_empty_holder_primary,
|
||||||
textSecondary = if (categoryId == NO_ID) {
|
textSecondary = if (categoryId == NO_ID) {
|
||||||
R.string.you_have_not_favourites_yet
|
R.string.you_have_not_favourites_yet
|
||||||
@@ -92,4 +95,12 @@ class FavouritesListViewModel(
|
|||||||
override suspend fun getCounter(mangaId: Long): Int {
|
override suspend fun getCounter(mangaId: Long): Int {
|
||||||
return trackingRepository.getNewChaptersCount(mangaId)
|
return trackingRepository.getNewChaptersCount(mangaId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun getProgress(mangaId: Long): Float {
|
||||||
|
return if (settings.isReadingIndicatorsEnabled) {
|
||||||
|
historyRepository.getProgress(mangaId)
|
||||||
|
} else {
|
||||||
|
PROGRESS_NONE
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import org.koitharu.kotatsu.history.ui.HistoryListViewModel
|
|||||||
val historyModule
|
val historyModule
|
||||||
get() = module {
|
get() = module {
|
||||||
|
|
||||||
factory { HistoryRepository(get(), get(), get()) }
|
single { HistoryRepository(get(), get(), get(), getAll()) }
|
||||||
|
|
||||||
viewModel { HistoryListViewModel(get(), get(), get(), get()) }
|
viewModel { HistoryListViewModel(get(), get(), get(), get()) }
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package org.koitharu.kotatsu.history.data
|
package org.koitharu.kotatsu.history.data
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
import org.koitharu.kotatsu.core.model.MangaHistory
|
import org.koitharu.kotatsu.core.model.MangaHistory
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
fun HistoryEntity.toMangaHistory() = MangaHistory(
|
fun HistoryEntity.toMangaHistory() = MangaHistory(
|
||||||
createdAt = Date(createdAt),
|
createdAt = Date(createdAt),
|
||||||
updatedAt = Date(updatedAt),
|
updatedAt = Date(updatedAt),
|
||||||
chapterId = chapterId,
|
chapterId = chapterId,
|
||||||
page = page,
|
page = page,
|
||||||
scroll = scroll.toInt()
|
scroll = scroll.toInt(),
|
||||||
|
percent = percent,
|
||||||
)
|
)
|
||||||
@@ -45,26 +45,36 @@ abstract class HistoryDao {
|
|||||||
@Query("SELECT COUNT(*) FROM history")
|
@Query("SELECT COUNT(*) FROM history")
|
||||||
abstract fun observeCount(): Flow<Int>
|
abstract fun observeCount(): Flow<Int>
|
||||||
|
|
||||||
|
@Query("SELECT percent FROM history WHERE manga_id = :id")
|
||||||
|
abstract fun findProgress(id: Long): Float?
|
||||||
|
|
||||||
@Query("DELETE FROM history")
|
@Query("DELETE FROM history")
|
||||||
abstract suspend fun clear()
|
abstract suspend fun clear()
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||||
abstract suspend fun insert(entity: HistoryEntity): Long
|
abstract suspend fun insert(entity: HistoryEntity): Long
|
||||||
|
|
||||||
@Query("UPDATE history SET page = :page, chapter_id = :chapterId, scroll = :scroll, updated_at = :updatedAt WHERE manga_id = :mangaId")
|
@Query("UPDATE history SET page = :page, chapter_id = :chapterId, scroll = :scroll, percent = :percent, updated_at = :updatedAt WHERE manga_id = :mangaId")
|
||||||
abstract suspend fun update(
|
abstract suspend fun update(
|
||||||
mangaId: Long,
|
mangaId: Long,
|
||||||
page: Int,
|
page: Int,
|
||||||
chapterId: Long,
|
chapterId: Long,
|
||||||
scroll: Float,
|
scroll: Float,
|
||||||
updatedAt: Long
|
percent: Float,
|
||||||
|
updatedAt: Long,
|
||||||
): Int
|
): Int
|
||||||
|
|
||||||
@Query("DELETE FROM history WHERE manga_id = :mangaId")
|
@Query("DELETE FROM history WHERE manga_id = :mangaId")
|
||||||
abstract suspend fun delete(mangaId: Long)
|
abstract suspend fun delete(mangaId: Long)
|
||||||
|
|
||||||
suspend fun update(entity: HistoryEntity) =
|
suspend fun update(entity: HistoryEntity) = update(
|
||||||
update(entity.mangaId, entity.page, entity.chapterId, entity.scroll, entity.updatedAt)
|
mangaId = entity.mangaId,
|
||||||
|
page = entity.page,
|
||||||
|
chapterId = entity.chapterId,
|
||||||
|
scroll = entity.scroll,
|
||||||
|
percent = entity.percent,
|
||||||
|
updatedAt = entity.updatedAt
|
||||||
|
)
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
open suspend fun upsert(entity: HistoryEntity): Boolean {
|
open suspend fun upsert(entity: HistoryEntity): Boolean {
|
||||||
|
|||||||
@@ -13,16 +13,17 @@ import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
|||||||
entity = MangaEntity::class,
|
entity = MangaEntity::class,
|
||||||
parentColumns = ["manga_id"],
|
parentColumns = ["manga_id"],
|
||||||
childColumns = ["manga_id"],
|
childColumns = ["manga_id"],
|
||||||
onDelete = ForeignKey.CASCADE
|
onDelete = ForeignKey.CASCADE,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
class HistoryEntity(
|
class HistoryEntity(
|
||||||
@PrimaryKey(autoGenerate = false)
|
@PrimaryKey(autoGenerate = false)
|
||||||
@ColumnInfo(name = "manga_id") val mangaId: Long,
|
@ColumnInfo(name = "manga_id") val mangaId: Long,
|
||||||
@ColumnInfo(name = "created_at") val createdAt: Long = System.currentTimeMillis(),
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
@ColumnInfo(name = "updated_at") val updatedAt: Long,
|
@ColumnInfo(name = "updated_at") val updatedAt: Long,
|
||||||
@ColumnInfo(name = "chapter_id") val chapterId: Long,
|
@ColumnInfo(name = "chapter_id") val chapterId: Long,
|
||||||
@ColumnInfo(name = "page") val page: Int,
|
@ColumnInfo(name = "page") val page: Int,
|
||||||
@ColumnInfo(name = "scroll") val scroll: Float,
|
@ColumnInfo(name = "scroll") val scroll: Float,
|
||||||
|
@ColumnInfo(name = "percent") val percent: Float,
|
||||||
)
|
)
|
||||||
@@ -13,13 +13,18 @@ import org.koitharu.kotatsu.history.data.HistoryEntity
|
|||||||
import org.koitharu.kotatsu.history.data.toMangaHistory
|
import org.koitharu.kotatsu.history.data.toMangaHistory
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.Scrobbler
|
||||||
|
import org.koitharu.kotatsu.scrobbling.domain.tryScrobble
|
||||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||||
import org.koitharu.kotatsu.utils.ext.mapItems
|
import org.koitharu.kotatsu.utils.ext.mapItems
|
||||||
|
|
||||||
|
const val PROGRESS_NONE = -1f
|
||||||
|
|
||||||
class HistoryRepository(
|
class HistoryRepository(
|
||||||
private val db: MangaDatabase,
|
private val db: MangaDatabase,
|
||||||
private val trackingRepository: TrackingRepository,
|
private val trackingRepository: TrackingRepository,
|
||||||
private val settings: AppSettings,
|
private val settings: AppSettings,
|
||||||
|
private val scrobblers: List<Scrobbler>,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
|
suspend fun getList(offset: Int, limit: Int = 20): List<Manga> {
|
||||||
@@ -59,7 +64,7 @@ class HistoryRepository(
|
|||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Int) {
|
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Int, percent: Float) {
|
||||||
if (manga.isNsfw && settings.isHistoryExcludeNsfw) {
|
if (manga.isNsfw && settings.isHistoryExcludeNsfw) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -75,9 +80,14 @@ class HistoryRepository(
|
|||||||
chapterId = chapterId,
|
chapterId = chapterId,
|
||||||
page = page,
|
page = page,
|
||||||
scroll = scroll.toFloat(), // we migrate to int, but decide to not update database
|
scroll = scroll.toFloat(), // we migrate to int, but decide to not update database
|
||||||
|
percent = percent,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
trackingRepository.upsert(manga)
|
trackingRepository.syncWithHistory(manga, chapterId)
|
||||||
|
val chapter = manga.chapters?.find { x -> x.id == chapterId }
|
||||||
|
if (chapter != null) {
|
||||||
|
scrobblers.forEach { it.tryScrobble(manga.id, chapter) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +95,10 @@ class HistoryRepository(
|
|||||||
return db.historyDao.find(manga.id)?.toMangaHistory()
|
return db.historyDao.find(manga.id)?.toMangaHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun getProgress(mangaId: Long): Float {
|
||||||
|
return db.historyDao.findProgress(mangaId) ?: PROGRESS_NONE
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun clear() {
|
suspend fun clear() {
|
||||||
db.historyDao.clear()
|
db.historyDao.clear()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package org.koitharu.kotatsu.history.ui
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
@@ -14,6 +12,7 @@ import org.koitharu.kotatsu.base.domain.ReversibleHandle
|
|||||||
import org.koitharu.kotatsu.base.domain.reverseAsync
|
import org.koitharu.kotatsu.base.domain.reverseAsync
|
||||||
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
||||||
|
import org.koitharu.kotatsu.utils.ext.addMenuProvider
|
||||||
|
|
||||||
class HistoryListFragment : MangaListFragment() {
|
class HistoryListFragment : MangaListFragment() {
|
||||||
|
|
||||||
@@ -22,6 +21,7 @@ class HistoryListFragment : MangaListFragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
addMenuProvider(HistoryListMenuProvider(view.context, viewModel))
|
||||||
viewModel.isGroupingEnabled.observe(viewLifecycleOwner) {
|
viewModel.isGroupingEnabled.observe(viewLifecycleOwner) {
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
@@ -30,37 +30,6 @@ class HistoryListFragment : MangaListFragment() {
|
|||||||
|
|
||||||
override fun onScrolledToEnd() = Unit
|
override fun onScrolledToEnd() = Unit
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.opt_history, menu)
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
||||||
super.onPrepareOptionsMenu(menu)
|
|
||||||
menu.findItem(R.id.action_history_grouping)?.isChecked =
|
|
||||||
viewModel.isGroupingEnabled.value == true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
return when (item.itemId) {
|
|
||||||
R.id.action_clear_history -> {
|
|
||||||
MaterialAlertDialogBuilder(context ?: return false)
|
|
||||||
.setTitle(R.string.clear_history)
|
|
||||||
.setMessage(R.string.text_clear_history_prompt)
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(R.string.clear) { _, _ ->
|
|
||||||
viewModel.clearHistory()
|
|
||||||
}.show()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
R.id.action_history_grouping -> {
|
|
||||||
viewModel.setGrouping(!item.isChecked)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
mode.menuInflater.inflate(R.menu.mode_history, menu)
|
mode.menuInflater.inflate(R.menu.mode_history, menu)
|
||||||
return super.onCreateActionMode(mode, menu)
|
return super.onCreateActionMode(mode, menu)
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package org.koitharu.kotatsu.history.ui
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
|
class HistoryListMenuProvider(
|
||||||
|
private val context: Context,
|
||||||
|
private val viewModel: HistoryListViewModel,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_history, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
|
||||||
|
R.id.action_clear_history -> {
|
||||||
|
MaterialAlertDialogBuilder(context, materialR.style.ThemeOverlay_Material3_MaterialAlertDialog_Centered)
|
||||||
|
.setTitle(R.string.clear_history)
|
||||||
|
.setMessage(R.string.text_clear_history_prompt)
|
||||||
|
.setIcon(R.drawable.ic_delete)
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.setPositiveButton(R.string.clear) { _, _ ->
|
||||||
|
viewModel.clearHistory()
|
||||||
|
}.show()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
R.id.action_history_grouping -> {
|
||||||
|
viewModel.setGrouping(!menuItem.isChecked)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPrepareMenu(menu: Menu) {
|
||||||
|
menu.findItem(R.id.action_history_grouping).isChecked = viewModel.isGroupingEnabled.value == true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,6 @@ package org.koitharu.kotatsu.history.ui
|
|||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.catch
|
import kotlinx.coroutines.flow.catch
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
@@ -19,6 +17,7 @@ import org.koitharu.kotatsu.core.prefs.observeAsFlow
|
|||||||
import org.koitharu.kotatsu.core.ui.DateTimeAgo
|
import org.koitharu.kotatsu.core.ui.DateTimeAgo
|
||||||
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
import org.koitharu.kotatsu.history.domain.HistoryRepository
|
||||||
import org.koitharu.kotatsu.history.domain.MangaWithHistory
|
import org.koitharu.kotatsu.history.domain.MangaWithHistory
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
import org.koitharu.kotatsu.list.ui.MangaListViewModel
|
||||||
import org.koitharu.kotatsu.list.ui.model.*
|
import org.koitharu.kotatsu.list.ui.model.*
|
||||||
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
import org.koitharu.kotatsu.tracker.domain.TrackingRepository
|
||||||
@@ -26,6 +25,8 @@ import org.koitharu.kotatsu.utils.SingleLiveEvent
|
|||||||
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
||||||
import org.koitharu.kotatsu.utils.ext.daysDiff
|
import org.koitharu.kotatsu.utils.ext.daysDiff
|
||||||
import org.koitharu.kotatsu.utils.ext.onFirst
|
import org.koitharu.kotatsu.utils.ext.onFirst
|
||||||
|
import java.util.*
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class HistoryListViewModel(
|
class HistoryListViewModel(
|
||||||
private val repository: HistoryRepository,
|
private val repository: HistoryRepository,
|
||||||
@@ -37,7 +38,7 @@ class HistoryListViewModel(
|
|||||||
val isGroupingEnabled = MutableLiveData<Boolean>()
|
val isGroupingEnabled = MutableLiveData<Boolean>()
|
||||||
val onItemsRemoved = SingleLiveEvent<ReversibleHandle>()
|
val onItemsRemoved = SingleLiveEvent<ReversibleHandle>()
|
||||||
|
|
||||||
private val historyGrouping = settings.observeAsFlow(AppSettings.KEY_HISTORY_GROUPING) { historyGrouping }
|
private val historyGrouping = settings.observeAsFlow(AppSettings.KEY_HISTORY_GROUPING) { isHistoryGroupingEnabled }
|
||||||
.onEach { isGroupingEnabled.postValue(it) }
|
.onEach { isGroupingEnabled.postValue(it) }
|
||||||
|
|
||||||
override val content = combine(
|
override val content = combine(
|
||||||
@@ -48,7 +49,7 @@ class HistoryListViewModel(
|
|||||||
when {
|
when {
|
||||||
list.isEmpty() -> listOf(
|
list.isEmpty() -> listOf(
|
||||||
EmptyState(
|
EmptyState(
|
||||||
icon = R.drawable.ic_history,
|
icon = R.drawable.ic_empty_history,
|
||||||
textPrimary = R.string.text_history_holder_primary,
|
textPrimary = R.string.text_history_holder_primary,
|
||||||
textSecondary = R.string.text_history_holder_secondary,
|
textSecondary = R.string.text_history_holder_secondary,
|
||||||
actionStringRes = 0,
|
actionStringRes = 0,
|
||||||
@@ -89,7 +90,7 @@ class HistoryListViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setGrouping(isGroupingEnabled: Boolean) {
|
fun setGrouping(isGroupingEnabled: Boolean) {
|
||||||
settings.historyGrouping = isGroupingEnabled
|
settings.isHistoryGroupingEnabled = isGroupingEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun mapList(
|
private suspend fun mapList(
|
||||||
@@ -98,6 +99,7 @@ class HistoryListViewModel(
|
|||||||
mode: ListMode
|
mode: ListMode
|
||||||
): List<ListModel> {
|
): List<ListModel> {
|
||||||
val result = ArrayList<ListModel>(if (grouped) (list.size * 1.4).toInt() else list.size + 1)
|
val result = ArrayList<ListModel>(if (grouped) (list.size * 1.4).toInt() else list.size + 1)
|
||||||
|
val showPercent = settings.isReadingIndicatorsEnabled
|
||||||
var prevDate: DateTimeAgo? = null
|
var prevDate: DateTimeAgo? = null
|
||||||
if (!grouped) {
|
if (!grouped) {
|
||||||
result += ListHeader(null, R.string.history, null)
|
result += ListHeader(null, R.string.history, null)
|
||||||
@@ -111,10 +113,11 @@ class HistoryListViewModel(
|
|||||||
prevDate = date
|
prevDate = date
|
||||||
}
|
}
|
||||||
val counter = trackingRepository.getNewChaptersCount(manga.id)
|
val counter = trackingRepository.getNewChaptersCount(manga.id)
|
||||||
|
val percent = if (showPercent) history.percent else PROGRESS_NONE
|
||||||
result += when (mode) {
|
result += when (mode) {
|
||||||
ListMode.LIST -> manga.toListModel(counter)
|
ListMode.LIST -> manga.toListModel(counter, percent)
|
||||||
ListMode.DETAILED_LIST -> manga.toListDetailedModel(counter)
|
ListMode.DETAILED_LIST -> manga.toListDetailedModel(counter, percent)
|
||||||
ListMode.GRID -> manga.toGridModel(counter)
|
ListMode.GRID -> manga.toGridModel(counter, percent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package org.koitharu.kotatsu.history.ui.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.*
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import androidx.annotation.StyleRes
|
||||||
|
import androidx.appcompat.content.res.AppCompatResources
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
class ReadingProgressDrawable(
|
||||||
|
context: Context,
|
||||||
|
@StyleRes styleResId: Int,
|
||||||
|
) : Drawable() {
|
||||||
|
|
||||||
|
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
private val checkDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_check)
|
||||||
|
private val lineColor: Int
|
||||||
|
private val outlineColor: Int
|
||||||
|
private val backgroundColor: Int
|
||||||
|
private val textColor: Int
|
||||||
|
private val textPattern = context.getString(R.string.percent_string_pattern)
|
||||||
|
private val textBounds = Rect()
|
||||||
|
private val tempRect = Rect()
|
||||||
|
private val hasBackground: Boolean
|
||||||
|
private val hasOutline: Boolean
|
||||||
|
private val hasText: Boolean
|
||||||
|
private val desiredHeight: Int
|
||||||
|
private val desiredWidth: Int
|
||||||
|
private val autoFitTextSize: Boolean
|
||||||
|
|
||||||
|
var progress: Float = PROGRESS_NONE
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
text = textPattern.format((value * 100f).toInt().toString())
|
||||||
|
paint.getTextBounds(text, 0, text.length, textBounds)
|
||||||
|
invalidateSelf()
|
||||||
|
}
|
||||||
|
private var text = ""
|
||||||
|
|
||||||
|
init {
|
||||||
|
val ta = context.obtainStyledAttributes(styleResId, R.styleable.ProgressDrawable)
|
||||||
|
desiredHeight = ta.getDimensionPixelSize(R.styleable.ProgressDrawable_android_height, -1)
|
||||||
|
desiredWidth = ta.getDimensionPixelSize(R.styleable.ProgressDrawable_android_width, -1)
|
||||||
|
autoFitTextSize = ta.getBoolean(R.styleable.ProgressDrawable_autoFitTextSize, false)
|
||||||
|
lineColor = ta.getColor(R.styleable.ProgressDrawable_android_strokeColor, Color.BLACK)
|
||||||
|
outlineColor = ta.getColor(R.styleable.ProgressDrawable_outlineColor, Color.TRANSPARENT)
|
||||||
|
backgroundColor = ColorUtils.setAlphaComponent(
|
||||||
|
ta.getColor(R.styleable.ProgressDrawable_android_fillColor, Color.TRANSPARENT),
|
||||||
|
(255 * ta.getFloat(R.styleable.ProgressDrawable_android_fillAlpha, 0f)).toInt(),
|
||||||
|
)
|
||||||
|
textColor = ta.getColor(R.styleable.ProgressDrawable_android_textColor, lineColor)
|
||||||
|
paint.strokeCap = Paint.Cap.ROUND
|
||||||
|
paint.textAlign = Paint.Align.CENTER
|
||||||
|
paint.textSize = ta.getDimension(R.styleable.ProgressDrawable_android_textSize, paint.textSize)
|
||||||
|
paint.strokeWidth = ta.getDimension(R.styleable.ProgressDrawable_strokeWidth, 1f)
|
||||||
|
ta.recycle()
|
||||||
|
hasBackground = Color.alpha(backgroundColor) != 0
|
||||||
|
hasOutline = Color.alpha(outlineColor) != 0
|
||||||
|
hasText = Color.alpha(textColor) != 0 && paint.textSize > 0
|
||||||
|
checkDrawable?.setTint(textColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBoundsChange(bounds: Rect) {
|
||||||
|
super.onBoundsChange(bounds)
|
||||||
|
if (autoFitTextSize) {
|
||||||
|
val innerWidth = bounds.width() - (paint.strokeWidth * 2f)
|
||||||
|
paint.textSize = getTextSizeForWidth(innerWidth, "100%")
|
||||||
|
paint.getTextBounds(text, 0, text.length, textBounds)
|
||||||
|
invalidateSelf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun draw(canvas: Canvas) {
|
||||||
|
if (progress < 0f) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val cx = bounds.exactCenterX()
|
||||||
|
val cy = bounds.exactCenterY()
|
||||||
|
val radius = minOf(bounds.width(), bounds.height()) / 2f
|
||||||
|
if (hasBackground) {
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
paint.color = backgroundColor
|
||||||
|
canvas.drawCircle(cx, cy, radius, paint)
|
||||||
|
}
|
||||||
|
val innerRadius = radius - paint.strokeWidth / 2f
|
||||||
|
paint.style = Paint.Style.STROKE
|
||||||
|
if (hasOutline) {
|
||||||
|
paint.color = outlineColor
|
||||||
|
canvas.drawCircle(cx, cy, innerRadius, paint)
|
||||||
|
}
|
||||||
|
paint.color = lineColor
|
||||||
|
canvas.drawArc(
|
||||||
|
cx - innerRadius,
|
||||||
|
cy - innerRadius,
|
||||||
|
cx + innerRadius,
|
||||||
|
cy + innerRadius,
|
||||||
|
-90f,
|
||||||
|
360f * progress,
|
||||||
|
false,
|
||||||
|
paint,
|
||||||
|
)
|
||||||
|
if (hasText) {
|
||||||
|
if (checkDrawable != null && progress >= 1f - Math.ulp(progress)) {
|
||||||
|
tempRect.set(bounds)
|
||||||
|
tempRect *= 0.6
|
||||||
|
checkDrawable.bounds = tempRect
|
||||||
|
checkDrawable.draw(canvas)
|
||||||
|
} else {
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
paint.color = textColor
|
||||||
|
val ty = bounds.height() / 2f + textBounds.height() / 2f - textBounds.bottom
|
||||||
|
canvas.drawText(text, cx, ty, paint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setAlpha(alpha: Int) {
|
||||||
|
paint.alpha = alpha
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setColorFilter(colorFilter: ColorFilter?) {
|
||||||
|
paint.colorFilter = colorFilter
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||||
|
@Deprecated("Deprecated in Java")
|
||||||
|
override fun getOpacity() = PixelFormat.TRANSLUCENT
|
||||||
|
|
||||||
|
override fun getIntrinsicHeight() = desiredHeight
|
||||||
|
|
||||||
|
override fun getIntrinsicWidth() = desiredWidth
|
||||||
|
|
||||||
|
private fun getTextSizeForWidth(width: Float, text: String): Float {
|
||||||
|
val testTextSize = 48f
|
||||||
|
paint.textSize = testTextSize
|
||||||
|
paint.getTextBounds(text, 0, text.length, tempRect)
|
||||||
|
return testTextSize * width / tempRect.width()
|
||||||
|
}
|
||||||
|
|
||||||
|
private operator fun Rect.timesAssign(factor: Double) {
|
||||||
|
val newWidth = (width() * factor).roundToInt()
|
||||||
|
val newHeight = (height() * factor).roundToInt()
|
||||||
|
inset(
|
||||||
|
(width() - newWidth) / 2,
|
||||||
|
(height() - newHeight) / 2,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
package org.koitharu.kotatsu.history.ui.util
|
||||||
|
|
||||||
|
import android.animation.Animator
|
||||||
|
import android.animation.ValueAnimator
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.Outline
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewOutlineProvider
|
||||||
|
import android.view.animation.AccelerateDecelerateInterpolator
|
||||||
|
import androidx.annotation.AttrRes
|
||||||
|
import androidx.annotation.StyleRes
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
|
|
||||||
|
class ReadingProgressView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
@AttrRes defStyleAttr: Int = 0,
|
||||||
|
) : View(context, attrs, defStyleAttr), ValueAnimator.AnimatorUpdateListener, Animator.AnimatorListener {
|
||||||
|
|
||||||
|
private var percentAnimator: ValueAnimator? = null
|
||||||
|
private val animationDuration = context.resources.getInteger(android.R.integer.config_shortAnimTime).toLong()
|
||||||
|
|
||||||
|
@StyleRes
|
||||||
|
private val drawableStyle: Int
|
||||||
|
|
||||||
|
var percent: Float
|
||||||
|
get() = peekProgressDrawable()?.progress ?: PROGRESS_NONE
|
||||||
|
set(value) {
|
||||||
|
cancelAnimation()
|
||||||
|
getProgressDrawable().progress = value
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
val ta = context.obtainStyledAttributes(attrs, R.styleable.ReadingProgressView, defStyleAttr, 0)
|
||||||
|
drawableStyle = ta.getResourceId(R.styleable.ReadingProgressView_progressStyle, R.style.ProgressDrawable)
|
||||||
|
ta.recycle()
|
||||||
|
outlineProvider = OutlineProvider()
|
||||||
|
if (isInEditMode) {
|
||||||
|
percent = 0.27f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow()
|
||||||
|
percentAnimator?.run {
|
||||||
|
if (isRunning) end()
|
||||||
|
}
|
||||||
|
percentAnimator = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAnimationUpdate(animation: ValueAnimator) {
|
||||||
|
val p = animation.animatedValue as Float
|
||||||
|
getProgressDrawable().progress = p
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAnimationStart(animation: Animator?) = Unit
|
||||||
|
|
||||||
|
override fun onAnimationEnd(animation: Animator?) {
|
||||||
|
if (percentAnimator === animation) {
|
||||||
|
percentAnimator = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAnimationCancel(animation: Animator?) = Unit
|
||||||
|
|
||||||
|
override fun onAnimationRepeat(animation: Animator?) = Unit
|
||||||
|
|
||||||
|
fun setPercent(value: Float, animate: Boolean) {
|
||||||
|
val currentDrawable = peekProgressDrawable()
|
||||||
|
if (!animate || currentDrawable == null || value == PROGRESS_NONE) {
|
||||||
|
percent = value
|
||||||
|
return
|
||||||
|
}
|
||||||
|
percentAnimator?.cancel()
|
||||||
|
percentAnimator = ValueAnimator.ofFloat(
|
||||||
|
currentDrawable.progress.coerceAtLeast(0f),
|
||||||
|
value
|
||||||
|
).apply {
|
||||||
|
duration = animationDuration
|
||||||
|
interpolator = AccelerateDecelerateInterpolator()
|
||||||
|
addUpdateListener(this@ReadingProgressView)
|
||||||
|
addListener(this@ReadingProgressView)
|
||||||
|
start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cancelAnimation() {
|
||||||
|
percentAnimator?.cancel()
|
||||||
|
percentAnimator = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun peekProgressDrawable(): ReadingProgressDrawable? {
|
||||||
|
return background as? ReadingProgressDrawable
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getProgressDrawable(): ReadingProgressDrawable {
|
||||||
|
var d = peekProgressDrawable()
|
||||||
|
if (d != null) {
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
d = ReadingProgressDrawable(context, drawableStyle)
|
||||||
|
background = d
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
private class OutlineProvider : ViewOutlineProvider() {
|
||||||
|
|
||||||
|
override fun getOutline(view: View, outline: Outline) {
|
||||||
|
outline.setOval(0, 0, view.width, view.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.koitharu.kotatsu.list.domain
|
package org.koitharu.kotatsu.list.domain
|
||||||
|
|
||||||
fun interface CountersProvider {
|
interface ListExtraProvider {
|
||||||
|
|
||||||
suspend fun getCounter(mangaId: Long): Int
|
suspend fun getCounter(mangaId: Long): Int
|
||||||
|
|
||||||
|
suspend fun getProgress(mangaId: Long): Float
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package org.koitharu.kotatsu.list.ui
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import androidx.annotation.CallSuper
|
import androidx.annotation.CallSuper
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.appcompat.view.ActionMode
|
import androidx.appcompat.view.ActionMode
|
||||||
import androidx.collection.ArraySet
|
import androidx.collection.ArraySet
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
@@ -18,6 +17,7 @@ import org.koitharu.kotatsu.R
|
|||||||
import org.koitharu.kotatsu.base.ui.BaseFragment
|
import org.koitharu.kotatsu.base.ui.BaseFragment
|
||||||
import org.koitharu.kotatsu.base.ui.list.FitHeightGridLayoutManager
|
import org.koitharu.kotatsu.base.ui.list.FitHeightGridLayoutManager
|
||||||
import org.koitharu.kotatsu.base.ui.list.FitHeightLinearLayoutManager
|
import org.koitharu.kotatsu.base.ui.list.FitHeightLinearLayoutManager
|
||||||
|
import org.koitharu.kotatsu.base.ui.list.ListSelectionController
|
||||||
import org.koitharu.kotatsu.base.ui.list.PaginationScrollListener
|
import org.koitharu.kotatsu.base.ui.list.PaginationScrollListener
|
||||||
import org.koitharu.kotatsu.base.ui.list.decor.SpacingItemDecoration
|
import org.koitharu.kotatsu.base.ui.list.decor.SpacingItemDecoration
|
||||||
import org.koitharu.kotatsu.base.ui.list.decor.TypedSpacingItemDecoration
|
import org.koitharu.kotatsu.base.ui.list.decor.TypedSpacingItemDecoration
|
||||||
@@ -46,12 +46,11 @@ abstract class MangaListFragment :
|
|||||||
PaginationScrollListener.Callback,
|
PaginationScrollListener.Callback,
|
||||||
MangaListListener,
|
MangaListListener,
|
||||||
SwipeRefreshLayout.OnRefreshListener,
|
SwipeRefreshLayout.OnRefreshListener,
|
||||||
ActionMode.Callback {
|
ListSelectionController.Callback {
|
||||||
|
|
||||||
private var listAdapter: MangaListAdapter? = null
|
private var listAdapter: MangaListAdapter? = null
|
||||||
private var paginationListener: PaginationScrollListener? = null
|
private var paginationListener: PaginationScrollListener? = null
|
||||||
private var selectionDecoration: MangaSelectionDecoration? = null
|
private var selectionController: ListSelectionController? = null
|
||||||
private var actionMode: ActionMode? = null
|
|
||||||
private val spanResolver = MangaListSpanResolver()
|
private val spanResolver = MangaListSpanResolver()
|
||||||
private val spanSizeLookup = SpanSizeLookup()
|
private val spanSizeLookup = SpanSizeLookup()
|
||||||
private val listCommitCallback = Runnable {
|
private val listCommitCallback = Runnable {
|
||||||
@@ -62,16 +61,11 @@ abstract class MangaListFragment :
|
|||||||
protected abstract val viewModel: MangaListViewModel
|
protected abstract val viewModel: MangaListViewModel
|
||||||
|
|
||||||
protected val selectedItemsIds: Set<Long>
|
protected val selectedItemsIds: Set<Long>
|
||||||
get() = selectionDecoration?.checkedItemsIds?.toSet().orEmpty()
|
get() = selectionController?.snapshot().orEmpty()
|
||||||
|
|
||||||
protected val selectedItems: Set<Manga>
|
protected val selectedItems: Set<Manga>
|
||||||
get() = collectSelectedItems()
|
get() = collectSelectedItems()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setHasOptionsMenu(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onInflateView(
|
override fun onInflateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?
|
container: ViewGroup?
|
||||||
@@ -84,12 +78,17 @@ abstract class MangaListFragment :
|
|||||||
lifecycleOwner = viewLifecycleOwner,
|
lifecycleOwner = viewLifecycleOwner,
|
||||||
listener = this,
|
listener = this,
|
||||||
)
|
)
|
||||||
selectionDecoration = MangaSelectionDecoration(view.context)
|
selectionController = ListSelectionController(
|
||||||
|
activity = requireActivity(),
|
||||||
|
decoration = MangaSelectionDecoration(view.context),
|
||||||
|
registryOwner = this,
|
||||||
|
callback = this,
|
||||||
|
)
|
||||||
paginationListener = PaginationScrollListener(4, this)
|
paginationListener = PaginationScrollListener(4, this)
|
||||||
with(binding.recyclerView) {
|
with(binding.recyclerView) {
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
adapter = listAdapter
|
adapter = listAdapter
|
||||||
addItemDecoration(selectionDecoration!!)
|
checkNotNull(selectionController).attachToRecyclerView(binding.recyclerView)
|
||||||
addOnScrollListener(paginationListener!!)
|
addOnScrollListener(paginationListener!!)
|
||||||
}
|
}
|
||||||
with(binding.swipeRefreshLayout) {
|
with(binding.swipeRefreshLayout) {
|
||||||
@@ -98,6 +97,7 @@ abstract class MangaListFragment :
|
|||||||
setOnRefreshListener(this@MangaListFragment)
|
setOnRefreshListener(this@MangaListFragment)
|
||||||
isEnabled = isSwipeRefreshEnabled
|
isEnabled = isSwipeRefreshEnabled
|
||||||
}
|
}
|
||||||
|
addMenuProvider(MangaListMenuProvider(childFragmentManager))
|
||||||
|
|
||||||
viewModel.listMode.observe(viewLifecycleOwner, ::onListModeChanged)
|
viewModel.listMode.observe(viewLifecycleOwner, ::onListModeChanged)
|
||||||
viewModel.gridScale.observe(viewLifecycleOwner, ::onGridScaleChanged)
|
viewModel.gridScale.observe(viewLifecycleOwner, ::onGridScaleChanged)
|
||||||
@@ -109,47 +109,19 @@ abstract class MangaListFragment :
|
|||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
listAdapter = null
|
listAdapter = null
|
||||||
paginationListener = null
|
paginationListener = null
|
||||||
selectionDecoration = null
|
selectionController = null
|
||||||
spanSizeLookup.invalidateCache()
|
spanSizeLookup.invalidateCache()
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.opt_list, menu)
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
|
||||||
R.id.action_list_mode -> {
|
|
||||||
ListModeSelectDialog.show(childFragmentManager)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onItemClick(item: Manga, view: View) {
|
override fun onItemClick(item: Manga, view: View) {
|
||||||
if (selectionDecoration?.checkedItemsCount != 0) {
|
if (selectionController?.onItemClick(item.id) != true) {
|
||||||
selectionDecoration?.toggleItemChecked(item.id)
|
startActivity(DetailsActivity.newIntent(context ?: return, item))
|
||||||
if (selectionDecoration?.checkedItemsCount == 0) {
|
|
||||||
actionMode?.finish()
|
|
||||||
} else {
|
|
||||||
actionMode?.invalidate()
|
|
||||||
binding.recyclerView.invalidateItemDecorations()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
startActivity(DetailsActivity.newIntent(context ?: return, item))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(item: Manga, view: View): Boolean {
|
override fun onItemLongClick(item: Manga, view: View): Boolean {
|
||||||
if (actionMode == null) {
|
return selectionController?.onItemLongClick(item.id) ?: false
|
||||||
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
|
||||||
}
|
|
||||||
return actionMode?.also {
|
|
||||||
selectionDecoration?.setItemIsChecked(item.id, true)
|
|
||||||
binding.recyclerView.invalidateItemDecorations()
|
|
||||||
it.invalidate()
|
|
||||||
} != null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
@@ -266,7 +238,7 @@ abstract class MangaListFragment :
|
|||||||
addOnLayoutChangeListener(spanResolver)
|
addOnLayoutChangeListener(spanResolver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selectionDecoration?.let { addItemDecoration(it) }
|
selectionController?.attachToRecyclerView(binding.recyclerView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +248,7 @@ abstract class MangaListFragment :
|
|||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
||||||
mode.title = selectionDecoration?.checkedItemsCount?.toString()
|
mode.title = selectionController?.count?.toString()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,9 +258,7 @@ abstract class MangaListFragment :
|
|||||||
val ids = listAdapter?.items?.mapNotNull {
|
val ids = listAdapter?.items?.mapNotNull {
|
||||||
(it as? MangaItemModel)?.id
|
(it as? MangaItemModel)?.id
|
||||||
} ?: return false
|
} ?: return false
|
||||||
selectionDecoration?.checkAll(ids)
|
selectionController?.addAll(ids)
|
||||||
binding.recyclerView.invalidateItemDecorations()
|
|
||||||
mode.invalidate()
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_share -> {
|
R.id.action_share -> {
|
||||||
@@ -310,14 +280,12 @@ abstract class MangaListFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyActionMode(mode: ActionMode) {
|
override fun onSelectionChanged(count: Int) {
|
||||||
selectionDecoration?.clearSelection()
|
|
||||||
binding.recyclerView.invalidateItemDecorations()
|
binding.recyclerView.invalidateItemDecorations()
|
||||||
actionMode = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectSelectedItems(): Set<Manga> {
|
private fun collectSelectedItems(): Set<Manga> {
|
||||||
val checkedIds = selectionDecoration?.checkedItemsIds ?: return emptySet()
|
val checkedIds = selectionController?.peekCheckedIds() ?: return emptySet()
|
||||||
val items = listAdapter?.items ?: return emptySet()
|
val items = listAdapter?.items ?: return emptySet()
|
||||||
val result = ArraySet<Manga>(checkedIds.size)
|
val result = ArraySet<Manga>(checkedIds.size)
|
||||||
for (item in items) {
|
for (item in items) {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package org.koitharu.kotatsu.list.ui
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
|
||||||
|
class MangaListMenuProvider(
|
||||||
|
private val fragmentManager: FragmentManager,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_list, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean = when (menuItem.itemId) {
|
||||||
|
R.id.action_list_mode -> {
|
||||||
|
ListModeSelectDialog.show(fragmentManager)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,17 +18,17 @@ import org.koitharu.kotatsu.utils.ext.getItem
|
|||||||
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
import org.koitharu.kotatsu.utils.ext.getThemeColor
|
||||||
import com.google.android.material.R as materialR
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
class MangaSelectionDecoration(context: Context) : AbstractSelectionItemDecoration() {
|
open class MangaSelectionDecoration(context: Context) : AbstractSelectionItemDecoration() {
|
||||||
|
|
||||||
private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
protected val paint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
private val checkIcon = ContextCompat.getDrawable(context, materialR.drawable.ic_mtrl_checked_circle)
|
protected val checkIcon = ContextCompat.getDrawable(context, materialR.drawable.ic_mtrl_checked_circle)
|
||||||
private val iconOffset = context.resources.getDimensionPixelOffset(R.dimen.grid_spacing_outer)
|
protected val iconOffset = context.resources.getDimensionPixelOffset(R.dimen.grid_spacing_outer)
|
||||||
private val strokeColor = context.getThemeColor(materialR.attr.colorPrimary, Color.RED)
|
protected val strokeColor = context.getThemeColor(materialR.attr.colorPrimary, Color.RED)
|
||||||
private val fillColor = ColorUtils.setAlphaComponent(
|
protected val fillColor = ColorUtils.setAlphaComponent(
|
||||||
ColorUtils.blendARGB(strokeColor, context.getThemeColor(materialR.attr.colorSurface), 0.8f),
|
ColorUtils.blendARGB(strokeColor, context.getThemeColor(materialR.attr.colorSurface), 0.8f),
|
||||||
0x74
|
0x74
|
||||||
)
|
)
|
||||||
private val defaultRadius = context.resources.getDimension(R.dimen.list_selector_corner)
|
protected val defaultRadius = context.resources.getDimension(R.dimen.list_selector_corner)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
hasBackground = false
|
hasBackground = false
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
|||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
||||||
import org.koitharu.kotatsu.databinding.ItemMangaGridBinding
|
import org.koitharu.kotatsu.databinding.ItemMangaGridBinding
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
import org.koitharu.kotatsu.list.ui.model.ListModel
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||||
import org.koitharu.kotatsu.list.ui.model.MangaGridModel
|
import org.koitharu.kotatsu.list.ui.model.MangaGridModel
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
@@ -43,8 +44,9 @@ fun mangaGridItemAD(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bind {
|
bind { payloads ->
|
||||||
binding.textViewTitle.text = item.title
|
binding.textViewTitle.text = item.title
|
||||||
|
binding.progressView.setPercent(item.progress, MangaListAdapter.PAYLOAD_PROGRESS in payloads)
|
||||||
imageRequest?.dispose()
|
imageRequest?.dispose()
|
||||||
imageRequest = binding.imageViewCover.newImageRequest(item.coverUrl)
|
imageRequest = binding.imageViewCover.newImageRequest(item.coverUrl)
|
||||||
.referer(item.manga.publicUrl)
|
.referer(item.manga.publicUrl)
|
||||||
@@ -60,6 +62,7 @@ fun mangaGridItemAD(
|
|||||||
|
|
||||||
onViewRecycled {
|
onViewRecycled {
|
||||||
itemView.clearBadge(badge)
|
itemView.clearBadge(badge)
|
||||||
|
binding.progressView.percent = PROGRESS_NONE
|
||||||
badge = null
|
badge = null
|
||||||
imageRequest?.dispose()
|
imageRequest?.dispose()
|
||||||
imageRequest = null
|
imageRequest = null
|
||||||
|
|||||||
@@ -54,9 +54,14 @@ class MangaListAdapter(
|
|||||||
|
|
||||||
override fun getChangePayload(oldItem: ListModel, newItem: ListModel): Any? {
|
override fun getChangePayload(oldItem: ListModel, newItem: ListModel): Any? {
|
||||||
return when (newItem) {
|
return when (newItem) {
|
||||||
is MangaListModel,
|
is MangaItemModel -> {
|
||||||
is MangaGridModel,
|
oldItem as MangaItemModel
|
||||||
is MangaListDetailedModel,
|
if (oldItem.progress != newItem.progress) {
|
||||||
|
PAYLOAD_PROGRESS
|
||||||
|
} else {
|
||||||
|
Unit
|
||||||
|
}
|
||||||
|
}
|
||||||
is CurrentFilterModel -> Unit
|
is CurrentFilterModel -> Unit
|
||||||
else -> super.getChangePayload(oldItem, newItem)
|
else -> super.getChangePayload(oldItem, newItem)
|
||||||
}
|
}
|
||||||
@@ -77,5 +82,7 @@ class MangaListAdapter(
|
|||||||
const val ITEM_TYPE_HEADER = 9
|
const val ITEM_TYPE_HEADER = 9
|
||||||
const val ITEM_TYPE_FILTER = 10
|
const val ITEM_TYPE_FILTER = 10
|
||||||
const val ITEM_TYPE_HEADER_FILTER = 11
|
const val ITEM_TYPE_HEADER_FILTER = 11
|
||||||
|
|
||||||
|
val PAYLOAD_PROGRESS = Any()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
|||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
import org.koitharu.kotatsu.base.ui.list.OnListItemClickListener
|
||||||
import org.koitharu.kotatsu.databinding.ItemMangaListDetailsBinding
|
import org.koitharu.kotatsu.databinding.ItemMangaListDetailsBinding
|
||||||
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
import org.koitharu.kotatsu.list.ui.model.ListModel
|
import org.koitharu.kotatsu.list.ui.model.ListModel
|
||||||
import org.koitharu.kotatsu.list.ui.model.MangaListDetailedModel
|
import org.koitharu.kotatsu.list.ui.model.MangaListDetailedModel
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
@@ -36,10 +37,11 @@ fun mangaListDetailedItemAD(
|
|||||||
clickListener.onItemLongClick(item.manga, it)
|
clickListener.onItemLongClick(item.manga, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
bind {
|
bind { payloads ->
|
||||||
imageRequest?.dispose()
|
imageRequest?.dispose()
|
||||||
binding.textViewTitle.text = item.title
|
binding.textViewTitle.text = item.title
|
||||||
binding.textViewSubtitle.textAndVisible = item.subtitle
|
binding.textViewSubtitle.textAndVisible = item.subtitle
|
||||||
|
binding.progressView.setPercent(item.progress, MangaListAdapter.PAYLOAD_PROGRESS in payloads)
|
||||||
imageRequest = binding.imageViewCover.newImageRequest(item.coverUrl)
|
imageRequest = binding.imageViewCover.newImageRequest(item.coverUrl)
|
||||||
.referer(item.manga.publicUrl)
|
.referer(item.manga.publicUrl)
|
||||||
.placeholder(R.drawable.ic_placeholder)
|
.placeholder(R.drawable.ic_placeholder)
|
||||||
@@ -56,6 +58,7 @@ fun mangaListDetailedItemAD(
|
|||||||
|
|
||||||
onViewRecycled {
|
onViewRecycled {
|
||||||
itemView.clearBadge(badge)
|
itemView.clearBadge(badge)
|
||||||
|
binding.progressView.percent = PROGRESS_NONE
|
||||||
badge = null
|
badge = null
|
||||||
imageRequest?.dispose()
|
imageRequest?.dispose()
|
||||||
imageRequest = null
|
imageRequest = null
|
||||||
|
|||||||
@@ -4,21 +4,23 @@ import org.koitharu.kotatsu.R
|
|||||||
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
||||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
import org.koitharu.kotatsu.core.prefs.ListMode
|
import org.koitharu.kotatsu.core.prefs.ListMode
|
||||||
import org.koitharu.kotatsu.list.domain.CountersProvider
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
||||||
|
import org.koitharu.kotatsu.list.domain.ListExtraProvider
|
||||||
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
|
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.utils.ext.ifZero
|
import org.koitharu.kotatsu.utils.ext.ifZero
|
||||||
|
|
||||||
fun Manga.toListModel(counter: Int) = MangaListModel(
|
fun Manga.toListModel(counter: Int, progress: Float) = MangaListModel(
|
||||||
id = id,
|
id = id,
|
||||||
title = title,
|
title = title,
|
||||||
subtitle = tags.joinToString(", ") { it.title },
|
subtitle = tags.joinToString(", ") { it.title },
|
||||||
coverUrl = coverUrl,
|
coverUrl = coverUrl,
|
||||||
manga = this,
|
manga = this,
|
||||||
counter = counter,
|
counter = counter,
|
||||||
|
progress = progress,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Manga.toListDetailedModel(counter: Int) = MangaListDetailedModel(
|
fun Manga.toListDetailedModel(counter: Int, progress: Float) = MangaListDetailedModel(
|
||||||
id = id,
|
id = id,
|
||||||
title = title,
|
title = title,
|
||||||
subtitle = altTitle,
|
subtitle = altTitle,
|
||||||
@@ -27,50 +29,48 @@ fun Manga.toListDetailedModel(counter: Int) = MangaListDetailedModel(
|
|||||||
coverUrl = coverUrl,
|
coverUrl = coverUrl,
|
||||||
manga = this,
|
manga = this,
|
||||||
counter = counter,
|
counter = counter,
|
||||||
|
progress = progress,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun Manga.toGridModel(counter: Int) = MangaGridModel(
|
fun Manga.toGridModel(counter: Int, progress: Float) = MangaGridModel(
|
||||||
id = id,
|
id = id,
|
||||||
title = title,
|
title = title,
|
||||||
coverUrl = coverUrl,
|
coverUrl = coverUrl,
|
||||||
manga = this,
|
manga = this,
|
||||||
counter = counter,
|
counter = counter,
|
||||||
|
progress = progress,
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun List<Manga>.toUi(
|
suspend fun List<Manga>.toUi(
|
||||||
mode: ListMode,
|
mode: ListMode,
|
||||||
countersProvider: CountersProvider,
|
extraProvider: ListExtraProvider,
|
||||||
): List<MangaItemModel> = when (mode) {
|
): List<MangaItemModel> = when (mode) {
|
||||||
ListMode.LIST -> map { it.toListModel(countersProvider.getCounter(it.id)) }
|
ListMode.LIST -> map {
|
||||||
ListMode.DETAILED_LIST -> map { it.toListDetailedModel(countersProvider.getCounter(it.id)) }
|
it.toListModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
||||||
ListMode.GRID -> map { it.toGridModel(countersProvider.getCounter(it.id)) }
|
}
|
||||||
}
|
ListMode.DETAILED_LIST -> map {
|
||||||
|
it.toListDetailedModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
||||||
suspend fun <C : MutableCollection<ListModel>> List<Manga>.toUi(
|
}
|
||||||
destination: C,
|
ListMode.GRID -> map {
|
||||||
mode: ListMode,
|
it.toGridModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
||||||
countersProvider: CountersProvider,
|
}
|
||||||
): C = when (mode) {
|
|
||||||
ListMode.LIST -> mapTo(destination) { it.toListModel(countersProvider.getCounter(it.id)) }
|
|
||||||
ListMode.DETAILED_LIST -> mapTo(destination) { it.toListDetailedModel(countersProvider.getCounter(it.id)) }
|
|
||||||
ListMode.GRID -> mapTo(destination) { it.toGridModel(countersProvider.getCounter(it.id)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun List<Manga>.toUi(
|
fun List<Manga>.toUi(
|
||||||
mode: ListMode,
|
mode: ListMode,
|
||||||
): List<MangaItemModel> = when (mode) {
|
): List<MangaItemModel> = when (mode) {
|
||||||
ListMode.LIST -> map { it.toListModel(0) }
|
ListMode.LIST -> map { it.toListModel(0, PROGRESS_NONE) }
|
||||||
ListMode.DETAILED_LIST -> map { it.toListDetailedModel(0) }
|
ListMode.DETAILED_LIST -> map { it.toListDetailedModel(0, PROGRESS_NONE) }
|
||||||
ListMode.GRID -> map { it.toGridModel(0) }
|
ListMode.GRID -> map { it.toGridModel(0, PROGRESS_NONE) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <C : MutableCollection<ListModel>> List<Manga>.toUi(
|
fun <C : MutableCollection<ListModel>> List<Manga>.toUi(
|
||||||
destination: C,
|
destination: C,
|
||||||
mode: ListMode,
|
mode: ListMode,
|
||||||
): C = when (mode) {
|
): C = when (mode) {
|
||||||
ListMode.LIST -> mapTo(destination) { it.toListModel(0) }
|
ListMode.LIST -> mapTo(destination) { it.toListModel(0, PROGRESS_NONE) }
|
||||||
ListMode.DETAILED_LIST -> mapTo(destination) { it.toListDetailedModel(0) }
|
ListMode.DETAILED_LIST -> mapTo(destination) { it.toListDetailedModel(0, PROGRESS_NONE) }
|
||||||
ListMode.GRID -> mapTo(destination) { it.toGridModel(0) }
|
ListMode.GRID -> mapTo(destination) { it.toGridModel(0, PROGRESS_NONE) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Throwable.toErrorState(canRetry: Boolean = true) = ErrorState(
|
fun Throwable.toErrorState(canRetry: Boolean = true) = ErrorState(
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
|
|
||||||
data class MangaGridModel(
|
data class MangaGridModel(
|
||||||
override val id: Long,
|
override val id: Long,
|
||||||
val title: String,
|
override val title: String,
|
||||||
val coverUrl: String,
|
override val coverUrl: String,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
val counter: Int,
|
override val counter: Int,
|
||||||
|
override val progress: Float,
|
||||||
) : MangaItemModel
|
) : MangaItemModel
|
||||||
@@ -6,4 +6,8 @@ sealed interface MangaItemModel : ListModel {
|
|||||||
|
|
||||||
val id: Long
|
val id: Long
|
||||||
val manga: Manga
|
val manga: Manga
|
||||||
|
val title: String
|
||||||
|
val coverUrl: String
|
||||||
|
val counter: Int
|
||||||
|
val progress: Float
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,12 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
|
|
||||||
data class MangaListDetailedModel(
|
data class MangaListDetailedModel(
|
||||||
override val id: Long,
|
override val id: Long,
|
||||||
val title: String,
|
override val title: String,
|
||||||
val subtitle: String?,
|
val subtitle: String?,
|
||||||
val tags: String,
|
val tags: String,
|
||||||
val coverUrl: String,
|
override val coverUrl: String,
|
||||||
val rating: String?,
|
val rating: String?,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
val counter: Int,
|
override val counter: Int,
|
||||||
|
override val progress: Float,
|
||||||
) : MangaItemModel
|
) : MangaItemModel
|
||||||
@@ -4,9 +4,10 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
|
|
||||||
data class MangaListModel(
|
data class MangaListModel(
|
||||||
override val id: Long,
|
override val id: Long,
|
||||||
val title: String,
|
override val title: String,
|
||||||
val subtitle: String,
|
val subtitle: String,
|
||||||
val coverUrl: String,
|
override val coverUrl: String,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
val counter: Int,
|
override val counter: Int,
|
||||||
|
override val progress: Float,
|
||||||
) : MangaItemModel
|
) : MangaItemModel
|
||||||
@@ -13,9 +13,9 @@ import java.io.InputStream
|
|||||||
class PagesCache(context: Context) {
|
class PagesCache(context: Context) {
|
||||||
|
|
||||||
private val cacheDir = context.externalCacheDir ?: context.cacheDir
|
private val cacheDir = context.externalCacheDir ?: context.cacheDir
|
||||||
private val lruCache = DiskLruCache.create(
|
private val lruCache = createDiskLruCacheSafe(
|
||||||
cacheDir.subdir(CacheDir.PAGES.dir),
|
dir = cacheDir.subdir(CacheDir.PAGES.dir),
|
||||||
FileSize.MEGABYTES.convert(200, FileSize.BYTES),
|
size = FileSize.MEGABYTES.convert(200, FileSize.BYTES),
|
||||||
)
|
)
|
||||||
|
|
||||||
operator fun get(url: String): File? {
|
operator fun get(url: String): File? {
|
||||||
@@ -60,4 +60,14 @@ class PagesCache(context: Context) {
|
|||||||
progress.value = (bytesCopied.toDouble() / contentLength.toDouble()).toFloat()
|
progress.value = (bytesCopied.toDouble() / contentLength.toDouble()).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDiskLruCacheSafe(dir: File, size: Long): DiskLruCache {
|
||||||
|
return try {
|
||||||
|
DiskLruCache.create(dir, size)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
dir.deleteRecursively()
|
||||||
|
dir.mkdir()
|
||||||
|
DiskLruCache.create(dir, size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,12 @@ import androidx.annotation.WorkerThread
|
|||||||
import androidx.collection.ArraySet
|
import androidx.collection.ArraySet
|
||||||
import androidx.core.net.toFile
|
import androidx.core.net.toFile
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
import kotlin.coroutines.CoroutineContext
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import org.koitharu.kotatsu.core.exceptions.UnsupportedFileException
|
import org.koitharu.kotatsu.core.exceptions.UnsupportedFileException
|
||||||
import org.koitharu.kotatsu.core.parser.MangaRepository
|
import org.koitharu.kotatsu.core.parser.MangaRepository
|
||||||
@@ -22,12 +28,6 @@ import org.koitharu.kotatsu.utils.ext.deleteAwait
|
|||||||
import org.koitharu.kotatsu.utils.ext.longHashCode
|
import org.koitharu.kotatsu.utils.ext.longHashCode
|
||||||
import org.koitharu.kotatsu.utils.ext.readText
|
import org.koitharu.kotatsu.utils.ext.readText
|
||||||
import org.koitharu.kotatsu.utils.ext.resolveName
|
import org.koitharu.kotatsu.utils.ext.resolveName
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.*
|
|
||||||
import java.util.zip.ZipEntry
|
|
||||||
import java.util.zip.ZipFile
|
|
||||||
import kotlin.coroutines.CoroutineContext
|
|
||||||
|
|
||||||
private const val MAX_PARALLELISM = 4
|
private const val MAX_PARALLELISM = 4
|
||||||
|
|
||||||
@@ -37,28 +37,25 @@ class LocalMangaRepository(private val storageManager: LocalStorageManager) : Ma
|
|||||||
private val filenameFilter = CbzFilter()
|
private val filenameFilter = CbzFilter()
|
||||||
private val locks = CompositeMutex<Long>()
|
private val locks = CompositeMutex<Long>()
|
||||||
|
|
||||||
override suspend fun getList(
|
override suspend fun getList(offset: Int, query: String): List<Manga> {
|
||||||
offset: Int,
|
|
||||||
query: String?,
|
|
||||||
tags: Set<MangaTag>?,
|
|
||||||
sortOrder: SortOrder?
|
|
||||||
): List<Manga> {
|
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
val files = getAllFiles()
|
val list = getRawList()
|
||||||
val list = coroutineScope {
|
if (query.isNotEmpty()) {
|
||||||
val dispatcher = Dispatchers.IO.limitedParallelism(MAX_PARALLELISM)
|
|
||||||
files.map { file ->
|
|
||||||
getFromFileAsync(file, dispatcher)
|
|
||||||
}.awaitAll()
|
|
||||||
}.filterNotNullTo(ArrayList(files.size))
|
|
||||||
if (!query.isNullOrEmpty()) {
|
|
||||||
list.retainAll { x ->
|
list.retainAll { x ->
|
||||||
x.title.contains(query, ignoreCase = true) ||
|
x.title.contains(query, ignoreCase = true) ||
|
||||||
x.altTitle?.contains(query, ignoreCase = true) == true
|
x.altTitle?.contains(query, ignoreCase = true) == true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getList(offset: Int, tags: Set<MangaTag>?, sortOrder: SortOrder?): List<Manga> {
|
||||||
|
if (offset > 0) {
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
val list = getRawList()
|
||||||
if (!tags.isNullOrEmpty()) {
|
if (!tags.isNullOrEmpty()) {
|
||||||
list.retainAll { x ->
|
list.retainAll { x ->
|
||||||
x.tags.containsAll(tags)
|
x.tags.containsAll(tags)
|
||||||
@@ -244,7 +241,7 @@ class LocalMangaRepository(private val storageManager: LocalStorageManager) : Ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override val sortOrders = emptySet<SortOrder>()
|
override val sortOrders = setOf(SortOrder.ALPHABETICAL)
|
||||||
|
|
||||||
override suspend fun getPageUrl(page: MangaPage) = page.url
|
override suspend fun getPageUrl(page: MangaPage) = page.url
|
||||||
|
|
||||||
@@ -295,6 +292,16 @@ class LocalMangaRepository(private val storageManager: LocalStorageManager) : Ma
|
|||||||
locks.unlock(id)
|
locks.unlock(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun getRawList(): ArrayList<Manga> {
|
||||||
|
val files = getAllFiles()
|
||||||
|
return coroutineScope {
|
||||||
|
val dispatcher = Dispatchers.IO.limitedParallelism(MAX_PARALLELISM)
|
||||||
|
files.map { file ->
|
||||||
|
getFromFileAsync(file, dispatcher)
|
||||||
|
}.awaitAll()
|
||||||
|
}.filterNotNullTo(ArrayList(files.size))
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun getAllFiles() = storageManager.getReadableDirs().flatMap { dir ->
|
private suspend fun getAllFiles() = storageManager.getReadableDirs().flatMap { dir ->
|
||||||
dir.listFiles(filenameFilter)?.toList().orEmpty()
|
dir.listFiles(filenameFilter)?.toList().orEmpty()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.*
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.ActivityResultCallback
|
import androidx.activity.result.ActivityResultCallback
|
||||||
@@ -19,6 +18,7 @@ import org.koitharu.kotatsu.R
|
|||||||
import org.koitharu.kotatsu.download.ui.service.DownloadService
|
import org.koitharu.kotatsu.download.ui.service.DownloadService
|
||||||
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
import org.koitharu.kotatsu.list.ui.MangaListFragment
|
||||||
import org.koitharu.kotatsu.utils.ShareHelper
|
import org.koitharu.kotatsu.utils.ShareHelper
|
||||||
|
import org.koitharu.kotatsu.utils.ext.addMenuProvider
|
||||||
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
import org.koitharu.kotatsu.utils.progress.Progress
|
import org.koitharu.kotatsu.utils.progress.Progress
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ class LocalListFragment : MangaListFragment(), ActivityResultCallback<List<@JvmS
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
addMenuProvider(LocalListMenuProvider(this::onEmptyActionClick))
|
||||||
viewModel.onMangaRemoved.observe(viewLifecycleOwner) { onItemRemoved() }
|
viewModel.onMangaRemoved.observe(viewLifecycleOwner) { onItemRemoved() }
|
||||||
viewModel.importProgress.observe(viewLifecycleOwner, ::onImportProgressChanged)
|
viewModel.importProgress.observe(viewLifecycleOwner, ::onImportProgressChanged)
|
||||||
}
|
}
|
||||||
@@ -77,21 +78,6 @@ class LocalListFragment : MangaListFragment(), ActivityResultCallback<List<@JvmS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
||||||
inflater.inflate(R.menu.opt_local, menu)
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
||||||
return when (item.itemId) {
|
|
||||||
R.id.action_import -> {
|
|
||||||
onEmptyActionClick()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResult(result: List<@JvmSuppressWildcards Uri>) {
|
override fun onActivityResult(result: List<@JvmSuppressWildcards Uri>) {
|
||||||
if (result.isEmpty()) return
|
if (result.isEmpty()) return
|
||||||
viewModel.importFiles(result)
|
viewModel.importFiles(result)
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.koitharu.kotatsu.local.ui
|
||||||
|
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuInflater
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.core.view.MenuProvider
|
||||||
|
import org.koitharu.kotatsu.R
|
||||||
|
|
||||||
|
class LocalListMenuProvider(
|
||||||
|
private val onImportClick: Function0<Unit>,
|
||||||
|
) : MenuProvider {
|
||||||
|
|
||||||
|
override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) {
|
||||||
|
menuInflater.inflate(R.menu.opt_local, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
|
||||||
|
return when (menuItem.itemId) {
|
||||||
|
R.id.action_import -> {
|
||||||
|
onImportClick()
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ package org.koitharu.kotatsu.local.ui
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import java.io.IOException
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
@@ -24,6 +23,7 @@ import org.koitharu.kotatsu.utils.SingleLiveEvent
|
|||||||
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
import org.koitharu.kotatsu.utils.ext.asLiveDataDistinct
|
||||||
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
import org.koitharu.kotatsu.utils.ext.printStackTraceDebug
|
||||||
import org.koitharu.kotatsu.utils.progress.Progress
|
import org.koitharu.kotatsu.utils.progress.Progress
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class LocalListViewModel(
|
class LocalListViewModel(
|
||||||
private val repository: LocalMangaRepository,
|
private val repository: LocalMangaRepository,
|
||||||
@@ -49,7 +49,7 @@ class LocalListViewModel(
|
|||||||
list == null -> listOf(LoadingState)
|
list == null -> listOf(LoadingState)
|
||||||
list.isEmpty() -> listOf(
|
list.isEmpty() -> listOf(
|
||||||
EmptyState(
|
EmptyState(
|
||||||
icon = R.drawable.ic_storage,
|
icon = R.drawable.ic_empty_local,
|
||||||
textPrimary = R.string.text_local_holder_primary,
|
textPrimary = R.string.text_local_holder_primary,
|
||||||
textSecondary = R.string.text_local_holder_secondary,
|
textSecondary = R.string.text_local_holder_secondary,
|
||||||
actionStringRes = R.string._import,
|
actionStringRes = R.string._import,
|
||||||
@@ -115,7 +115,7 @@ class LocalListViewModel(
|
|||||||
private suspend fun doRefresh() {
|
private suspend fun doRefresh() {
|
||||||
try {
|
try {
|
||||||
listError.value = null
|
listError.value = null
|
||||||
mangaList.value = repository.getList(0)
|
mangaList.value = repository.getList(0, null, null)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
listError.value = e
|
listError.value = e
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,8 +145,15 @@ class MainActivity :
|
|||||||
|
|
||||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||||
super.onRestoreInstanceState(savedInstanceState)
|
super.onRestoreInstanceState(savedInstanceState)
|
||||||
drawerToggle?.isDrawerIndicatorEnabled =
|
val isSearchOpened = isSearchOpened()
|
||||||
drawer?.getDrawerLockMode(GravityCompat.START) == DrawerLayout.LOCK_MODE_UNLOCKED
|
adjustDrawerLock(isSearchOpened)
|
||||||
|
if (isSearchOpened) {
|
||||||
|
binding.toolbarCard.updateLayoutParams<AppBarLayout.LayoutParams> {
|
||||||
|
scrollFlags = SCROLL_FLAG_NO_SCROLL
|
||||||
|
}
|
||||||
|
binding.appbar.setBackgroundColor(getThemeColor(materialR.attr.colorSurfaceVariant))
|
||||||
|
binding.appbar.updatePadding(left = 0, right = 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||||
@@ -299,8 +306,9 @@ class MainActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onClearSearchHistory() {
|
override fun onClearSearchHistory() {
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this, materialR.style.ThemeOverlay_Material3_MaterialAlertDialog_Centered)
|
||||||
.setTitle(R.string.clear_search_history)
|
.setTitle(R.string.clear_search_history)
|
||||||
|
.setIcon(R.drawable.ic_clear_all)
|
||||||
.setMessage(R.string.text_clear_search_history_prompt)
|
.setMessage(R.string.text_clear_search_history_prompt)
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setPositiveButton(R.string.clear) { _, _ ->
|
.setPositiveButton(R.string.clear) { _, _ ->
|
||||||
@@ -395,29 +403,31 @@ class MainActivity :
|
|||||||
|
|
||||||
private fun onSearchOpened() {
|
private fun onSearchOpened() {
|
||||||
TransitionManager.beginDelayedTransition(binding.appbar)
|
TransitionManager.beginDelayedTransition(binding.appbar)
|
||||||
drawerToggle?.isDrawerIndicatorEnabled = false
|
|
||||||
binding.toolbarCard.updateLayoutParams<AppBarLayout.LayoutParams> {
|
binding.toolbarCard.updateLayoutParams<AppBarLayout.LayoutParams> {
|
||||||
scrollFlags = SCROLL_FLAG_NO_SCROLL
|
scrollFlags = SCROLL_FLAG_NO_SCROLL
|
||||||
}
|
}
|
||||||
binding.appbar.setBackgroundColor(getThemeColor(materialR.attr.colorSurfaceVariant))
|
binding.appbar.setBackgroundColor(getThemeColor(materialR.attr.colorSurfaceVariant))
|
||||||
binding.appbar.updatePadding(left = 0, right = 0)
|
binding.appbar.updatePadding(left = 0, right = 0)
|
||||||
adjustDrawerLock()
|
adjustDrawerLock(isSearchOpened = true)
|
||||||
adjustFabVisibility(isSearchOpened = true)
|
adjustFabVisibility(isSearchOpened = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onSearchClosed() {
|
private fun onSearchClosed() {
|
||||||
TransitionManager.beginDelayedTransition(binding.appbar)
|
TransitionManager.beginDelayedTransition(binding.appbar)
|
||||||
drawerToggle?.isDrawerIndicatorEnabled = true
|
|
||||||
binding.toolbarCard.updateLayoutParams<AppBarLayout.LayoutParams> {
|
binding.toolbarCard.updateLayoutParams<AppBarLayout.LayoutParams> {
|
||||||
scrollFlags = SCROLL_FLAG_SCROLL or SCROLL_FLAG_ENTER_ALWAYS
|
scrollFlags = SCROLL_FLAG_SCROLL or SCROLL_FLAG_ENTER_ALWAYS
|
||||||
}
|
}
|
||||||
binding.appbar.background = null
|
binding.appbar.background = null
|
||||||
val padding = resources.getDimensionPixelOffset(R.dimen.margin_normal)
|
val padding = resources.getDimensionPixelOffset(R.dimen.margin_normal)
|
||||||
binding.appbar.updatePadding(left = padding, right = padding)
|
binding.appbar.updatePadding(left = padding, right = padding)
|
||||||
adjustDrawerLock()
|
adjustDrawerLock(isSearchOpened = false)
|
||||||
adjustFabVisibility(isSearchOpened = false)
|
adjustFabVisibility(isSearchOpened = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isSearchOpened(): Boolean {
|
||||||
|
return supportFragmentManager.findFragmentByTag(TAG_SEARCH)?.isVisible == true
|
||||||
|
}
|
||||||
|
|
||||||
private fun onFirstStart() {
|
private fun onFirstStart() {
|
||||||
lifecycleScope.launchWhenResumed {
|
lifecycleScope.launchWhenResumed {
|
||||||
val isUpdateSupported = withContext(Dispatchers.Default) {
|
val isUpdateSupported = withContext(Dispatchers.Default) {
|
||||||
@@ -439,7 +449,7 @@ class MainActivity :
|
|||||||
private fun adjustFabVisibility(
|
private fun adjustFabVisibility(
|
||||||
isResumeEnabled: Boolean = viewModel.isResumeEnabled.value == true,
|
isResumeEnabled: Boolean = viewModel.isResumeEnabled.value == true,
|
||||||
topFragment: Fragment? = supportFragmentManager.findFragmentByTag(TAG_PRIMARY),
|
topFragment: Fragment? = supportFragmentManager.findFragmentByTag(TAG_PRIMARY),
|
||||||
isSearchOpened: Boolean = supportFragmentManager.findFragmentByTag(TAG_SEARCH)?.isVisible == true,
|
isSearchOpened: Boolean = isSearchOpened(),
|
||||||
) {
|
) {
|
||||||
val fab = binding.fab
|
val fab = binding.fab
|
||||||
if (isResumeEnabled && !isSearchOpened && topFragment is HistoryListFragment) {
|
if (isResumeEnabled && !isSearchOpened && topFragment is HistoryListFragment) {
|
||||||
@@ -453,12 +463,15 @@ class MainActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun adjustDrawerLock() {
|
private fun adjustDrawerLock(
|
||||||
|
isSearchOpened: Boolean = isSearchOpened(),
|
||||||
|
) {
|
||||||
val drawer = drawer ?: return
|
val drawer = drawer ?: return
|
||||||
val isLocked = actionModeDelegate.isActionModeStarted || (drawerToggle?.isDrawerIndicatorEnabled == false)
|
val isLocked = actionModeDelegate.isActionModeStarted || isSearchOpened
|
||||||
drawer.setDrawerLockMode(
|
drawer.setDrawerLockMode(
|
||||||
if (isLocked) DrawerLayout.LOCK_MODE_LOCKED_CLOSED else DrawerLayout.LOCK_MODE_UNLOCKED
|
if (isLocked) DrawerLayout.LOCK_MODE_LOCKED_CLOSED else DrawerLayout.LOCK_MODE_UNLOCKED
|
||||||
)
|
)
|
||||||
|
drawerToggle?.isDrawerIndicatorEnabled = !isLocked
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class VoiceInputCallback : ActivityResultCallback<String?> {
|
private inner class VoiceInputCallback : ActivityResultCallback<String?> {
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ import android.view.View
|
|||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.biometric.BiometricManager
|
||||||
|
import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK
|
||||||
|
import androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS
|
||||||
|
import androidx.biometric.BiometricPrompt
|
||||||
|
import androidx.biometric.BiometricPrompt.AuthenticationCallback
|
||||||
import androidx.core.graphics.Insets
|
import androidx.core.graphics.Insets
|
||||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
@@ -17,8 +22,11 @@ import org.koitharu.kotatsu.base.ui.BaseActivity
|
|||||||
import org.koitharu.kotatsu.databinding.ActivityProtectBinding
|
import org.koitharu.kotatsu.databinding.ActivityProtectBinding
|
||||||
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
||||||
|
|
||||||
class ProtectActivity : BaseActivity<ActivityProtectBinding>(), TextView.OnEditorActionListener,
|
class ProtectActivity :
|
||||||
TextWatcher, View.OnClickListener {
|
BaseActivity<ActivityProtectBinding>(),
|
||||||
|
TextView.OnEditorActionListener,
|
||||||
|
TextWatcher,
|
||||||
|
View.OnClickListener {
|
||||||
|
|
||||||
private val viewModel by viewModel<ProtectViewModel>()
|
private val viewModel by viewModel<ProtectViewModel>()
|
||||||
|
|
||||||
@@ -39,7 +47,9 @@ class ProtectActivity : BaseActivity<ActivityProtectBinding>(), TextView.OnEdito
|
|||||||
finishAfterTransition()
|
finishAfterTransition()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.editPassword.requestFocus()
|
if (!useFingerprint()) {
|
||||||
|
binding.editPassword.requestFocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onWindowInsetsChanged(insets: Insets) {
|
override fun onWindowInsetsChanged(insets: Insets) {
|
||||||
@@ -85,6 +95,31 @@ class ProtectActivity : BaseActivity<ActivityProtectBinding>(), TextView.OnEdito
|
|||||||
binding.layoutPassword.isEnabled = !isLoading
|
binding.layoutPassword.isEnabled = !isLoading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun useFingerprint(): Boolean {
|
||||||
|
if (!viewModel.isBiometricEnabled) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (BiometricManager.from(this).canAuthenticate(BIOMETRIC_WEAK) != BIOMETRIC_SUCCESS) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
val prompt = BiometricPrompt(this, BiometricCallback())
|
||||||
|
val promptInfo = BiometricPrompt.PromptInfo.Builder()
|
||||||
|
.setAllowedAuthenticators(BIOMETRIC_WEAK)
|
||||||
|
.setTitle(getString(R.string.app_name))
|
||||||
|
.setConfirmationRequired(false)
|
||||||
|
.setNegativeButtonText(getString(android.R.string.cancel))
|
||||||
|
.build()
|
||||||
|
prompt.authenticate(promptInfo)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class BiometricCallback : AuthenticationCallback() {
|
||||||
|
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||||
|
super.onAuthenticationSucceeded(result)
|
||||||
|
viewModel.unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private const val EXTRA_INTENT = "src_intent"
|
private const val EXTRA_INTENT = "src_intent"
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ class ProtectViewModel(
|
|||||||
|
|
||||||
val onUnlockSuccess = SingleLiveEvent<Unit>()
|
val onUnlockSuccess = SingleLiveEvent<Unit>()
|
||||||
|
|
||||||
|
val isBiometricEnabled
|
||||||
|
get() = settings.isBiometricProtectionEnabled
|
||||||
|
|
||||||
fun tryUnlock(password: String) {
|
fun tryUnlock(password: String) {
|
||||||
if (job?.isActive == true) {
|
if (job?.isActive == true) {
|
||||||
return
|
return
|
||||||
@@ -27,12 +30,16 @@ class ProtectViewModel(
|
|||||||
val passwordHash = password.md5()
|
val passwordHash = password.md5()
|
||||||
val appPasswordHash = settings.appPassword
|
val appPasswordHash = settings.appPassword
|
||||||
if (passwordHash == appPasswordHash) {
|
if (passwordHash == appPasswordHash) {
|
||||||
protectHelper.unlock()
|
unlock()
|
||||||
onUnlockSuccess.call(Unit)
|
|
||||||
} else {
|
} else {
|
||||||
delay(PASSWORD_COMPARE_DELAY)
|
delay(PASSWORD_COMPARE_DELAY)
|
||||||
throw WrongPasswordException()
|
throw WrongPasswordException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun unlock() {
|
||||||
|
protectHelper.unlock()
|
||||||
|
onUnlockSuccess.call(Unit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user