mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-11-18 01:27:46 +01:00
Compare commits
249 Commits
v0.0.3
...
feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5092f50f6 | ||
|
|
d216fc4640 | ||
|
|
f61c12a30b | ||
|
|
495a1d025f | ||
|
|
0e31e40ef1 | ||
|
|
bae68d4a99 | ||
|
|
3e17e3364d | ||
|
|
9626500586 | ||
|
|
92fcb811c3 | ||
|
|
81e2fdcf91 | ||
|
|
171338f492 | ||
|
|
cc21588a66 | ||
|
|
b5356ee5eb | ||
|
|
ec9be3f6af | ||
|
|
ac5e67c032 | ||
|
|
fd24f04254 | ||
|
|
0b74574fa6 | ||
|
|
2704ff0ecf | ||
|
|
f4c33e08e2 | ||
|
|
5dddf2e39d | ||
|
|
487afce565 | ||
|
|
f31a13568c | ||
|
|
04341991bf | ||
|
|
a7c2a67d0c | ||
|
|
4ec6666f93 | ||
|
|
fcc0181075 | ||
|
|
1c4e5f3659 | ||
|
|
a120fcf068 | ||
|
|
0328f34df2 | ||
|
|
7849115000 | ||
|
|
41e14aab9d | ||
|
|
074b5d012c | ||
|
|
8a3ee7931d | ||
|
|
dce5a8d89c | ||
|
|
a82f2b68e3 | ||
|
|
a36ddccefd | ||
|
|
bbe696a37b | ||
|
|
13ec5f84c4 | ||
|
|
587ebbb309 | ||
|
|
485611970f | ||
|
|
c0738947b7 | ||
|
|
f1145d826e | ||
|
|
aa4f587443 | ||
|
|
e559e4acd2 | ||
|
|
db1e000325 | ||
|
|
4f57c17f73 | ||
|
|
21af736fa4 | ||
|
|
72ba80ff87 | ||
|
|
450e96fdbe | ||
|
|
fcc60e1b16 | ||
|
|
e888282d24 | ||
|
|
237d33f2e4 | ||
|
|
babb0d28bb | ||
|
|
53eb7cbe91 | ||
|
|
fed84f9942 | ||
|
|
d4896a1f87 | ||
|
|
21879bec7d | ||
|
|
bb143cfecb | ||
|
|
6475b4808a | ||
|
|
57a58cc518 | ||
|
|
8a5b6aa972 | ||
|
|
6813770d57 | ||
|
|
118b6cd430 | ||
|
|
b984e35284 | ||
|
|
f2a2a3029d | ||
|
|
b4ab1ba414 | ||
|
|
d244e0ed42 | ||
|
|
81c190a9c0 | ||
|
|
e2f36c334b | ||
|
|
891215fcb3 | ||
|
|
04e022cbbc | ||
|
|
1f4f3a475d | ||
|
|
3e6d435116 | ||
|
|
9c6f946602 | ||
|
|
053c9e73b0 | ||
|
|
acd1aef851 | ||
|
|
a3a753a9dd | ||
|
|
0ea491bcfc | ||
|
|
946d35b5d9 | ||
|
|
5098cb698d | ||
|
|
47a06c372e | ||
|
|
7877001533 | ||
|
|
23d41846d0 | ||
|
|
dc4dc17b6c | ||
|
|
6c8892938a | ||
|
|
2f2d86bc3f | ||
|
|
ecd3d008de | ||
|
|
f5172a17db | ||
|
|
662a5bd597 | ||
|
|
6621748de5 | ||
|
|
37fa76b79a | ||
|
|
c7acb50522 | ||
|
|
64304ad637 | ||
|
|
635ca332da | ||
|
|
e2a15ab925 | ||
|
|
016801419f | ||
|
|
48d79bc353 | ||
|
|
b8094fded8 | ||
|
|
8c82ba0e91 | ||
|
|
3ff9c06843 | ||
|
|
45ae8342ee | ||
|
|
b8c3dae807 | ||
|
|
3afd2601f0 | ||
|
|
82414bba55 | ||
|
|
7a39b2341b | ||
|
|
37ab47bc34 | ||
|
|
21b111cc2d | ||
|
|
b3c2f6213d | ||
|
|
c3de94012a | ||
|
|
804eb64b5b | ||
|
|
6a4aa8075d | ||
|
|
692aca4eca | ||
|
|
dd00802561 | ||
|
|
a3e0fea200 | ||
|
|
304125ea0d | ||
|
|
a465ebb5b4 | ||
|
|
b39d00eba6 | ||
|
|
1ebdce309d | ||
|
|
d29b7585f7 | ||
|
|
276560678c | ||
|
|
10c23a65c5 | ||
|
|
4e4f4377e7 | ||
|
|
2e6c9db614 | ||
|
|
2375ba9d35 | ||
|
|
a11ccb7cf6 | ||
|
|
a54241294d | ||
|
|
46b509c1fb | ||
|
|
b13dd58c70 | ||
|
|
4312b250ce | ||
|
|
ff4c9180a0 | ||
|
|
be0bd40995 | ||
|
|
726d6d0faf | ||
|
|
14ce356c4d | ||
|
|
930a425af5 | ||
|
|
7168cecbcb | ||
|
|
7f067023e7 | ||
|
|
167aecb696 | ||
|
|
9872e6e806 | ||
|
|
05adc343a2 | ||
|
|
58e3dfa084 | ||
|
|
3068423c01 | ||
|
|
3c960f60d1 | ||
|
|
a153fc4afb | ||
|
|
4a19fbb745 | ||
|
|
bb8c10fc98 | ||
|
|
97af73f055 | ||
|
|
73d18082c4 | ||
|
|
4b78e80edd | ||
|
|
78ba4b0fda | ||
|
|
a1c5baac6b | ||
|
|
c4b811090d | ||
|
|
fbdccfb639 | ||
|
|
c1162fd618 | ||
|
|
4d7a148cfe | ||
|
|
c7b1602648 | ||
|
|
a82a454ad2 | ||
|
|
9533378003 | ||
|
|
dc1edcc78c | ||
|
|
6d8b040f6d | ||
|
|
60f07f7707 | ||
|
|
f6b7130d0c | ||
|
|
9fea056063 | ||
|
|
859e9ab5d6 | ||
|
|
4821718407 | ||
|
|
67a13f8ecb | ||
|
|
40e4782b32 | ||
|
|
2ab5ab3ce5 | ||
|
|
88fb054640 | ||
|
|
4ce8fd6a63 | ||
|
|
ffc2d669e5 | ||
|
|
926e1162f0 | ||
|
|
6cf69ee26d | ||
|
|
279820c1be | ||
|
|
1d7031f3d4 | ||
|
|
252e00b67a | ||
|
|
a8d63c7480 | ||
|
|
2020172b56 | ||
|
|
2d55a4c8ec | ||
|
|
20a3e0220b | ||
|
|
feeeefa2d2 | ||
|
|
d25137020f | ||
|
|
3c4fb4162e | ||
|
|
28e9ae950e | ||
|
|
888e741aa9 | ||
|
|
9f7a6e1738 | ||
|
|
76f4a0738f | ||
|
|
63327946be | ||
|
|
84d90adc54 | ||
|
|
cf15732a39 | ||
|
|
2eee73753f | ||
|
|
62d097357a | ||
|
|
c35a690335 | ||
|
|
18af76ce92 | ||
|
|
6e7256d9a5 | ||
|
|
2af6c5a742 | ||
|
|
5c39fddbc6 | ||
|
|
a708853199 | ||
|
|
acb651cf92 | ||
|
|
562c91acb2 | ||
|
|
484f9607b1 | ||
|
|
9149ee224c | ||
|
|
1bb1d3b9af | ||
|
|
0b76390069 | ||
|
|
5de8751079 | ||
|
|
4bfe1b0c02 | ||
|
|
15c1676d0b | ||
|
|
49ff90aad1 | ||
|
|
6adaaf1965 | ||
|
|
6d114f84fa | ||
|
|
394cff9ebe | ||
|
|
465abd4498 | ||
|
|
0178569f14 | ||
|
|
f7185445e1 | ||
|
|
d4b107bc79 | ||
|
|
fd14753a1d | ||
|
|
7cc4e93ad4 | ||
|
|
4c95404fe1 | ||
|
|
1c2212f0fe | ||
|
|
065fcedd34 | ||
|
|
3a66a79f49 | ||
|
|
907f6e92c3 | ||
|
|
426c3e6979 | ||
|
|
92292be472 | ||
|
|
3e10186c7c | ||
|
|
1974322013 | ||
|
|
a2e22bc525 | ||
|
|
7e433954c5 | ||
|
|
d47e2dac92 | ||
|
|
de3bea0729 | ||
|
|
3c91007d93 | ||
|
|
debb3e04df | ||
|
|
8c758460bc | ||
|
|
2bb1189e15 | ||
|
|
233fc38c23 | ||
|
|
215d31f8ea | ||
|
|
8ae681c753 | ||
|
|
554eb3c2fe | ||
|
|
c1f8f5a681 | ||
|
|
bb5c82aa60 | ||
|
|
72ba41c940 | ||
|
|
40b6722e66 | ||
|
|
dd3b72bc1f | ||
|
|
e9ecae117d | ||
|
|
5e4793bdaf | ||
|
|
fe351a8466 | ||
|
|
b1b12aba31 | ||
|
|
d2b95e1db6 | ||
|
|
20c317b63f | ||
|
|
f2d14a975d |
BIN
.assets/IzzyOnDroid.png
Normal file
BIN
.assets/IzzyOnDroid.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
.assets/codeberg.png
Normal file
BIN
.assets/codeberg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
49
.gitea/issue_template/bug_report.md
Normal file
49
.gitea/issue_template/bug_report.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
name: "Bug Report"
|
||||||
|
about: "Report a Bug!"
|
||||||
|
title: " [Bug] "
|
||||||
|
ref: "master"
|
||||||
|
labels:
|
||||||
|
|
||||||
|
- Kind/Bug
|
||||||
|
|
||||||
|
---
|
||||||
|
### Description of the Issue:
|
||||||
|
|
||||||
|
<!-- Provide a clear and concise description of what the issue is about. -->
|
||||||
|
|
||||||
|
### Steps to Reproduce:
|
||||||
|
|
||||||
|
<!-- Explain the steps to reproduce the issue, if applicable. -->
|
||||||
|
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
|
||||||
|
### Expected Behavior:
|
||||||
|
|
||||||
|
<!-- Describe what you expected to happen. -->
|
||||||
|
|
||||||
|
### Actual Behavior:
|
||||||
|
|
||||||
|
<!-- Describe what actually happened. Include screenshots if applicable. -->
|
||||||
|
|
||||||
|
### App Information:
|
||||||
|
|
||||||
|
- **Version:** <!-- e.g. 1.0.0 -->
|
||||||
|
- **Device:** <!-- e.g. Samsung Galaxy S10 -->
|
||||||
|
- **Android Version:** <!-- e.g. Android 11 -->
|
||||||
|
- **Installation Source:** <!-- e.g. Google Play Store, APK -->
|
||||||
|
|
||||||
|
### Log Files:
|
||||||
|
|
||||||
|
<!-- If applicable, include log files or error messages related to this issue. -->
|
||||||
|
|
||||||
|
### Additional Context:
|
||||||
|
|
||||||
|
<!-- Add any other context about the problem here, such as relevant system configuration or screenshots. -->
|
||||||
|
|
||||||
|
### Potential Solutions or Workarounds:
|
||||||
|
|
||||||
|
<!-- If you know of any potential solutions or workarounds for this issue, please describe them here. -->
|
||||||
1
.github/CODE_OF_CONDUCT.md
vendored
1
.github/CODE_OF_CONDUCT.md
vendored
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
14
.github/DISCUSSION_TEMPLATE/announcements.yml
vendored
14
.github/DISCUSSION_TEMPLATE/announcements.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thanks for taking the time to read this announcement!
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: description
|
|
||||||
description: Please describe the announcement in as much detail as possible.
|
|
||||||
placeholder: Make an announcement here...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
74
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
74
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
@@ -1,74 +0,0 @@
|
|||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Have an idea for a new feature or an improvement? Let us know here!
|
|
||||||
|
|
||||||
- type: checkboxes
|
|
||||||
id: checklist
|
|
||||||
attributes:
|
|
||||||
label: Checklist
|
|
||||||
options:
|
|
||||||
- label: I have used the search function for [open](https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/ideas) **and** [closed](https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/completed-ideas) ideas to see if someone else has already submitted the same request.
|
|
||||||
required: true
|
|
||||||
- label: I will describe the feature with as much detail as possible.
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thanks for taking the time to share your idea!
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: description
|
|
||||||
attributes:
|
|
||||||
label: Description
|
|
||||||
description: Please describe your idea in as much detail as possible.
|
|
||||||
placeholder: I think it would be great if...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: alternatives
|
|
||||||
attributes:
|
|
||||||
label: Alternatives
|
|
||||||
description: Please describe any alternative solutions or features you've considered.
|
|
||||||
placeholder: I've considered...
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: additional
|
|
||||||
attributes:
|
|
||||||
label: Additional context
|
|
||||||
description: Add your use-case, screenshots, mock-up, or anything else you think might be helpful.
|
|
||||||
placeholder: I think this would be a great addition because...
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: dropdown
|
|
||||||
id: importance
|
|
||||||
attributes:
|
|
||||||
label: How important is this feature?
|
|
||||||
multiple: false
|
|
||||||
options:
|
|
||||||
- Critical
|
|
||||||
- Important
|
|
||||||
- Nice to have
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: other
|
|
||||||
attributes:
|
|
||||||
label: Anything else?
|
|
||||||
description: Is there anything else you'd like to add?
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: solution
|
|
||||||
attributes:
|
|
||||||
label: Solution
|
|
||||||
description: If you have an idea of how this can be implemented, please share it here.
|
|
||||||
placeholder: I think this could be done by...
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
|||||||
github: Docile-Alligator
|
|
||||||
patreon: docile_alligator
|
|
||||||
94
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
94
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
@@ -1,94 +0,0 @@
|
|||||||
name: Bug Report
|
|
||||||
description: Create a report to help us improve existing features
|
|
||||||
labels: ['type: possible bug']
|
|
||||||
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thanks for taking the time to fill out this bug report!
|
|
||||||
|
|
||||||
- type: checkboxes
|
|
||||||
id: checklist
|
|
||||||
attributes:
|
|
||||||
label: Checklist
|
|
||||||
options:
|
|
||||||
- label: I have used the search function for [open](https://github.com/Docile-Alligator/Infinity-For-Reddit/issues) **and** [closed](https://github.com/Docile-Alligator/Infinity-For-Reddit/issues?q=is%3Aissue+is%3Aclosed) issues to see if someone else has already submitted the same bug report.
|
|
||||||
required: true
|
|
||||||
- label: I will describe the problem with as much detail as possible.
|
|
||||||
required: true
|
|
||||||
- label: If the bug only occurs with a certain link, post, image..., I will include the URL.
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: input
|
|
||||||
id: version
|
|
||||||
attributes:
|
|
||||||
label: App version
|
|
||||||
description: We need the actual version number found on the settings screen.
|
|
||||||
placeholder: x.y.z
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: dropdown
|
|
||||||
id: source
|
|
||||||
attributes:
|
|
||||||
label: Where did you get the app from
|
|
||||||
multiple: false
|
|
||||||
options:
|
|
||||||
- Google Play
|
|
||||||
- F-Droid
|
|
||||||
- Other
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: input
|
|
||||||
id: android_version
|
|
||||||
attributes:
|
|
||||||
label: Android version
|
|
||||||
description: Please mention if you are using a custom rom!
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: input
|
|
||||||
id: device
|
|
||||||
attributes:
|
|
||||||
label: Device model
|
|
||||||
|
|
||||||
- type: input
|
|
||||||
id: first
|
|
||||||
attributes:
|
|
||||||
label: First occurred
|
|
||||||
placeholder: about x days/weeks ago
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: steps
|
|
||||||
attributes:
|
|
||||||
label: Steps to reproduce
|
|
||||||
placeholder: |
|
|
||||||
1. This
|
|
||||||
2. Then that
|
|
||||||
3. Then this
|
|
||||||
4. Etc.
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: links
|
|
||||||
attributes:
|
|
||||||
label: Example post, link, markdown...
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: expected
|
|
||||||
attributes:
|
|
||||||
label: Expected behaviour
|
|
||||||
description: After following the steps, what did you think Infinity would do?
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: current
|
|
||||||
attributes:
|
|
||||||
label: Current behaviour
|
|
||||||
description: What did Infinity do instead? Screenshots might help. Usually, you can take a screenshot of your smartphone by pressing *Power* + *Volume down* for a few seconds.
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
id: logs
|
|
||||||
attributes:
|
|
||||||
label: Logs
|
|
||||||
description: If you are experiencing a crash, including the stacktrace will likely get it fixed sooner.
|
|
||||||
11
.github/ISSUE_TEMPLATE/config.yml
vendored
11
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,11 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Feature Request
|
|
||||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/ideas
|
|
||||||
about: Discuss ideas for new features of changes
|
|
||||||
- name: Questions
|
|
||||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/q-a
|
|
||||||
about: Please ask and answer questions here.
|
|
||||||
- name: Help needed
|
|
||||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/help-needed
|
|
||||||
about: Please ask for help here
|
|
||||||
23
.github/dependabot.yml
vendored
23
.github/dependabot.yml
vendored
@@ -1,23 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
# Updates for Gradle dependencies used in the app
|
|
||||||
- package-ecosystem: gradle
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
commit-message:
|
|
||||||
prefix: "⬆[Gradle]"
|
|
||||||
reviewers:
|
|
||||||
- "Wladefant"
|
|
||||||
- "Docile-Alligator"
|
|
||||||
|
|
||||||
# Updates for GitHub Actions used in the repository
|
|
||||||
- package-ecosystem: github-actions
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
commit-message:
|
|
||||||
prefix: "⬆[GitHub Actions]"
|
|
||||||
reviewers:
|
|
||||||
- "Wladefant"
|
|
||||||
- "Docile-Alligator"
|
|
||||||
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
@@ -1,32 +0,0 @@
|
|||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set-up JDK 11
|
|
||||||
uses: actions/setup-java@v3
|
|
||||||
with:
|
|
||||||
java-version: '11'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Setup and build with Gradle
|
|
||||||
uses: gradle/gradle-build-action@v2
|
|
||||||
with:
|
|
||||||
arguments: build -x lint
|
|
||||||
|
|
||||||
- name: Upload apk
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: Infinity-${{github.sha}}
|
|
||||||
path: app/build/outputs/apk/
|
|
||||||
if-no-files-found: error
|
|
||||||
34
.github/workflows/codeql-analysis.yml
vendored
34
.github/workflows/codeql-analysis.yml
vendored
@@ -1,34 +0,0 @@
|
|||||||
name: CodeQL
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 12 * * *'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Analyze:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v2
|
|
||||||
with:
|
|
||||||
languages: java
|
|
||||||
|
|
||||||
- name: Autobuild
|
|
||||||
uses: github/codeql-action/autobuild@v2
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v2
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
pipeline:
|
steps:
|
||||||
build:
|
build:
|
||||||
image: alvrme/alpine-android:android-33-jdk11
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
commands:
|
commands:
|
||||||
@@ -25,3 +25,5 @@ pipeline:
|
|||||||
note: "This is an alpha release. Expect many bugs and unfinished features!"
|
note: "This is an alpha release. Expect many bugs and unfinished features!"
|
||||||
when:
|
when:
|
||||||
event: [ tag ]
|
event: [ tag ]
|
||||||
|
when:
|
||||||
|
event: [ push, tag, pull_request ]
|
||||||
|
|||||||
76
.woodpecker/nightly.yaml
Normal file
76
.woodpecker/nightly.yaml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
clone:
|
||||||
|
git:
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
partial: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
build:
|
||||||
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
|
commands:
|
||||||
|
- ./gradlew :app:assembleNightly
|
||||||
|
sign:
|
||||||
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
|
commands:
|
||||||
|
- ./scripts/apk-sign.sh eu.toldi.infinityforlemmy.nightly.apk app/build/outputs/apk/nightly/eu.toldi.infinityforlemmy.nightly.apk
|
||||||
|
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]
|
||||||
|
pull-repo-config:
|
||||||
|
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest
|
||||||
|
commands:
|
||||||
|
- cd ..
|
||||||
|
- pwd
|
||||||
|
- mkdir repoconfig
|
||||||
|
- cd repoconfig
|
||||||
|
- pwd
|
||||||
|
- git clone --depth 1 https://codeberg.org/Bazsalanszky/fdroid-repo-config
|
||||||
|
- cp /woodpecker/src/codeberg.org/Bazsalanszky/Infinity-For-Lemmy/eu.toldi.infinityforlemmy.nightly.apk fdroid-repo-config/repo/
|
||||||
|
|
||||||
|
pull-pages:
|
||||||
|
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest
|
||||||
|
commands:
|
||||||
|
- cd ..
|
||||||
|
- pwd
|
||||||
|
- mkdir pages
|
||||||
|
- cd pages
|
||||||
|
- pwd
|
||||||
|
- git clone --depth 2 https://codeberg.org/Bazsalanszky/pages
|
||||||
|
- cd pages
|
||||||
|
- git config user.name "CODEBERG CI"
|
||||||
|
- git config user.email "noreply@nodomain.nodomain"
|
||||||
|
# reset and remove, later force push, to keep repo size small
|
||||||
|
- git reset --soft HEAD~1
|
||||||
|
- git status
|
||||||
|
|
||||||
|
update-fdroid-data:
|
||||||
|
image: cs8898/android-fdroid-sdk:33.0.0
|
||||||
|
commands:
|
||||||
|
- pwd
|
||||||
|
- cd ../repoconfig/fdroid-repo-config/
|
||||||
|
- echo -n "$${FDROID_KS}" | base64 -d > keystore.p12
|
||||||
|
- cat keystore.p12 | sha256sum
|
||||||
|
- sed -i "s|KS_PASS|$${FDROID_KS_PASS}|g" config.yml
|
||||||
|
- sed -i "s|KEY_PASS|$${FDROID_KEY_PASS}|g" config.yml
|
||||||
|
- fdroid update
|
||||||
|
- fdroid deploy
|
||||||
|
- ls -laR repo
|
||||||
|
secrets: [ FDROID_KS_PASS, FDROID_KEY_PASS, FDROID_KS ]
|
||||||
|
push-pages-update-repo:
|
||||||
|
image: codeberg.org/freeyourgadget/android-fdroid-tools:latest
|
||||||
|
commands:
|
||||||
|
- if [ -f .do_not_build ]; then return 0; fi
|
||||||
|
- cd ../pages/pages/
|
||||||
|
- git add -A
|
||||||
|
- git status
|
||||||
|
- git diff
|
||||||
|
- ls -lsR fdroid/repo
|
||||||
|
- git commit -m "autodeploy"
|
||||||
|
- git remote remove origin
|
||||||
|
- git remote add origin https://Bazsalanszky:"$${GITEA_ACCESS_TOKEN}"@codeberg.org/Bazsalanszky/pages.git
|
||||||
|
# force push as we removed all data
|
||||||
|
- git push -f origin main
|
||||||
|
- cd ../../
|
||||||
|
- pwd
|
||||||
|
- ls -la
|
||||||
|
secrets: [ GITEA_ACCESS_TOKEN ]
|
||||||
|
when:
|
||||||
|
event: cron
|
||||||
39
README.md
39
README.md
@@ -6,31 +6,28 @@
|
|||||||
|
|
||||||
A Lemmy client for Android written in Java. It's a fork of the [Infinity for Reddit](https://github.com/Docile-Alligator/Infinity-For-Reddit) project, currenty in early development.
|
A Lemmy client for Android written in Java. It's a fork of the [Infinity for Reddit](https://github.com/Docile-Alligator/Infinity-For-Reddit) project, currenty in early development.
|
||||||
|
|
||||||
<img align="right" src="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=200>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
<img src="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
|
||||||
|
|
||||||
[](https://ci.codeberg.org/12474)
|
[](https://ci.codeberg.org/repos/12474)
|
||||||
|
[](https://liberapay.com/Bazsalanszky)
|
||||||
|
|
||||||
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues">Report a Bug</a>
|
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues">Report a Bug</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
<a href="https://apt.izzysoft.de/fdroid/index/apk/eu.toldi.infinityforlemmy">
|
||||||
|
<img src="./.assets/IzzyOnDroid.png" height="80">
|
||||||
|
</a>
|
||||||
|
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/releases/">
|
||||||
|
<img src="./.assets/codeberg.png" height="80">
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Action Items for Infinity for Lemmy
|
## Action Items for Infinity for Lemmy
|
||||||
@@ -41,15 +38,17 @@ Infinity for Lemmy is currently in the early stages of development. Expect many
|
|||||||
- [x] Support for multiple account handling
|
- [x] Support for multiple account handling
|
||||||
- [x] Functionality for post upvotes/downvotes
|
- [x] Functionality for post upvotes/downvotes
|
||||||
- [x] Functionality to browse comments
|
- [x] Functionality to browse comments
|
||||||
- [ ] Capability for creating a new post
|
- [x] Capability for creating a new post
|
||||||
- [x] Ability to create comments
|
- [x] Ability to create comments
|
||||||
|
- [x] Edit/Delete posts and comments
|
||||||
|
- [x] Basic inbox
|
||||||
- [ ] Elimination of code/string references specific to Reddit
|
- [ ] Elimination of code/string references specific to Reddit
|
||||||
- [ ] Incorporation of private messaging feature
|
- [ ] Incorporation of private messaging feature
|
||||||
- [ ] Feature for saving posts
|
- [x] Feature for saving posts/comments
|
||||||
|
- [x] Resolving links
|
||||||
- [ ] Account editing function
|
- [ ] Account editing function
|
||||||
- [ ] Multi community view?
|
- [ ] Multi community view?
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
First off, thanks for taking the time to contribute! Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
First off, thanks for taking the time to contribute! Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||||
@@ -65,10 +64,15 @@ Don't forget to give the project a star! Thanks again!
|
|||||||
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
||||||
5. Open a Pull Request
|
5. Open a Pull Request
|
||||||
|
|
||||||
Here are other ways you can help:
|
### Translation
|
||||||
|
|
||||||
- [Report Bugs](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues)
|
You can alos help Infinity for Lemmy by translating it to your native langugage! Translations are done via [Weblate](https://translate.codeberg.org/projects/infinity-for-lemmy/app/)!
|
||||||
|
|
||||||
|
[](https://translate.codeberg.org/engage/infinity-for-lemmy/)
|
||||||
|
|
||||||
|
### Reporting bugs
|
||||||
|
|
||||||
|
You can also contribute by [reporting bugs](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues)
|
||||||
|
|
||||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||||
|
|
||||||
@@ -82,7 +86,6 @@ Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsal
|
|||||||
|
|
||||||
[@bazsalanszky@lemmy.toldi.eu](https://lemmy.toldi.eu/u/bazsalanszky) - (Owner)
|
[@bazsalanszky@lemmy.toldi.eu](https://lemmy.toldi.eu/u/bazsalanszky) - (Owner)
|
||||||
|
|
||||||
|
|
||||||
Project Link: [https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy)
|
Project Link: [https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy)
|
||||||
|
|
||||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application'
|
id 'com.android.application'
|
||||||
|
id 'org.jetbrains.kotlin.android'
|
||||||
|
}
|
||||||
|
def getCommitVersionCode = { ->
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'rev-list', 'HEAD', '--count'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return Integer.valueOf(stdout.toString().trim())
|
||||||
|
} catch (ignored) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
@@ -8,8 +21,8 @@ android {
|
|||||||
applicationId "eu.toldi.infinityforlemmy"
|
applicationId "eu.toldi.infinityforlemmy"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 123
|
versionCode 128
|
||||||
versionName "0.0.3"
|
versionName "0.0.8"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
@@ -18,10 +31,12 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
|
||||||
minifiedRelease {
|
minifiedRelease {
|
||||||
initWith buildTypes.release
|
initWith buildTypes.release
|
||||||
zipAlignEnabled true
|
zipAlignEnabled true
|
||||||
@@ -33,7 +48,33 @@ android {
|
|||||||
applicationIdSuffix '.debug'
|
applicationIdSuffix '.debug'
|
||||||
versionNameSuffix ' (DEBUG)'
|
versionNameSuffix ' (DEBUG)'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nightly {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
applicationIdSuffix '.nightly'
|
||||||
|
versionNameSuffix ' (NIGHTLY)'
|
||||||
|
}
|
||||||
|
applicationVariants.all { variant ->
|
||||||
|
variant.resValue "string", "applicationId", variant.applicationId
|
||||||
|
|
||||||
|
|
||||||
|
if (variant.buildType.name == 'nightly') {
|
||||||
|
variant.outputs.all {
|
||||||
|
setVersionCodeOverride(getCommitVersionCode())
|
||||||
|
|
||||||
|
setVersionNameOverride(variant.versionName)
|
||||||
|
outputFileName = "${applicationId}.apk"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
@@ -52,6 +93,10 @@ android {
|
|||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
doNotStrip '**/*.so'
|
||||||
|
}
|
||||||
namespace 'eu.toldi.infinityforlemmy'
|
namespace 'eu.toldi.infinityforlemmy'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +210,7 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
||||||
implementation "io.noties.markwon:inline-parser:$markwonVersion"
|
implementation "io.noties.markwon:inline-parser:$markwonVersion"
|
||||||
|
implementation "io.noties.markwon:image-glide:$markwonVersion"
|
||||||
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
||||||
implementation 'me.saket:better-link-movement-method:2.2.0'
|
implementation 'me.saket:better-link-movement-method:2.2.0'
|
||||||
|
|
||||||
@@ -196,3 +242,4 @@ dependencies {
|
|||||||
// debugImplementation because LeakCanary should only run in debug builds.
|
// debugImplementation because LeakCanary should only run in debug builds.
|
||||||
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:x.y'
|
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:x.y'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -402,6 +402,11 @@
|
|||||||
android:label="@string/subscriptions"
|
android:label="@string/subscriptions"
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
android:theme="@style/AppTheme.Slidable" />
|
android:theme="@style/AppTheme.Slidable" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.BlockedThingListingActivity"
|
||||||
|
android:label="@string/blocks"
|
||||||
|
android:parentActivityName=".activities.MainActivity"
|
||||||
|
android:theme="@style/AppTheme.Slidable" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.SubredditSelectionActivity"
|
android:name=".activities.SubredditSelectionActivity"
|
||||||
android:label="@string/community_selection_activity_label"
|
android:label="@string/community_selection_activity_label"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import dagger.BindsInstance;
|
|||||||
import dagger.Component;
|
import dagger.Component;
|
||||||
import eu.toldi.infinityforlemmy.activities.AccountPostsActivity;
|
import eu.toldi.infinityforlemmy.activities.AccountPostsActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.AccountSavedThingActivity;
|
import eu.toldi.infinityforlemmy.activities.AccountSavedThingActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BlockedThingListingActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CreateMultiRedditActivity;
|
import eu.toldi.infinityforlemmy.activities.CreateMultiRedditActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CustomThemeListingActivity;
|
import eu.toldi.infinityforlemmy.activities.CustomThemeListingActivity;
|
||||||
@@ -65,7 +66,10 @@ import eu.toldi.infinityforlemmy.activities.ViewVideoActivity;
|
|||||||
import eu.toldi.infinityforlemmy.activities.WebViewActivity;
|
import eu.toldi.infinityforlemmy.activities.WebViewActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.WikiActivity;
|
import eu.toldi.infinityforlemmy.activities.WikiActivity;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentMoreBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.HistoryPostFragment;
|
import eu.toldi.infinityforlemmy.fragments.HistoryPostFragment;
|
||||||
@@ -73,6 +77,7 @@ import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
|||||||
import eu.toldi.infinityforlemmy.fragments.MorePostsInfoFragment;
|
import eu.toldi.infinityforlemmy.fragments.MorePostsInfoFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.PrivateMessageFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
|
||||||
@@ -307,6 +312,16 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
||||||
|
|
||||||
|
void inject(BlockedThingListingActivity blockedThingListingActivity);
|
||||||
|
|
||||||
|
void inject(BlockedCommunitiesListingFragment blockedCommunitiesListingFragment);
|
||||||
|
|
||||||
|
void inject(BlockedUsersListingFragment blockedUsersListingFragment);
|
||||||
|
|
||||||
|
void inject(CommentMoreBottomSheetFragment commentMoreBottomSheetFragment);
|
||||||
|
|
||||||
|
void inject(PrivateMessageFragment privateMessageFragment);
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
AppComponent create(@BindsInstance Application application);
|
AppComponent create(@BindsInstance Application application);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import dagger.Module;
|
|||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LoopAvailableExoCreator;
|
import eu.toldi.infinityforlemmy.customviews.LoopAvailableExoCreator;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
|
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.videoautoplay.Config;
|
import eu.toldi.infinityforlemmy.videoautoplay.Config;
|
||||||
@@ -192,8 +194,8 @@ abstract class AppModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
static ExoCreator provideExoCreator(Config config,
|
static ExoCreator provideExoCreator(Config config,
|
||||||
ToroExo toroExo,
|
ToroExo toroExo,
|
||||||
@Named("default") SharedPreferences sharedPreferences) {
|
@Named("default") SharedPreferences sharedPreferences) {
|
||||||
return new LoopAvailableExoCreator(toroExo, config, sharedPreferences);
|
return new LoopAvailableExoCreator(toroExo, config, sharedPreferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,4 +204,16 @@ abstract class AppModule {
|
|||||||
static Executor provideExecutor() {
|
static Executor provideExecutor() {
|
||||||
return Executors.newFixedThreadPool(4);
|
return Executors.newFixedThreadPool(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static ObjectResolver provideObjectResolver(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||||
|
return new ObjectResolver(retrofitHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static MarkPostAsRead provideMarkPostAsRead(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||||
|
return new MarkPostAsRead(retrofitHolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.DeletePostDTO;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@@ -13,10 +15,11 @@ import retrofit2.Response;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class DeleteThing {
|
public class DeleteThing {
|
||||||
public static void delete(Retrofit oauthRetrofit, String fullname, String accessToken, DeleteThingListener deleteThingListener) {
|
|
||||||
|
public static void deletePost(Retrofit retrofit, int post_id, String accessToken, DeleteThingListener deleteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(APIUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, String.valueOf(post_id));
|
||||||
oauthRetrofit.create(RedditAPI.class).delete(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
retrofit.create(LemmyAPI.class).postDelete(new DeletePostDTO(post_id, true, accessToken)).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@@ -33,6 +36,27 @@ public class DeleteThing {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteComment(Retrofit retrofit, int comment_id, String accessToken, DeleteThingListener deleteThingListener) {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put(APIUtils.ID_KEY, String.valueOf(comment_id));
|
||||||
|
retrofit.create(LemmyAPI.class).commentDelete(new DeleteCommentDTO(comment_id, true, accessToken)).enqueue(new Callback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
deleteThingListener.deleteSuccess();
|
||||||
|
} else {
|
||||||
|
deleteThingListener.deleteFailed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
deleteThingListener.deleteFailed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public interface DeleteThingListener {
|
public interface DeleteThingListener {
|
||||||
void deleteSuccess();
|
void deleteSuccess();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package eu.toldi.infinityforlemmy;
|
package eu.toldi.infinityforlemmy;
|
||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.text.Html;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
@@ -9,9 +8,6 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@@ -83,7 +79,7 @@ public class FetchMyInfo {
|
|||||||
if (!person.isNull("banner")) {
|
if (!person.isNull("banner")) {
|
||||||
bannerImageUrl = person.getString("banner");
|
bannerImageUrl = person.getString("banner");
|
||||||
}
|
}
|
||||||
display_name = person.getString("name");
|
display_name = (person.has("display_name")) ? person.getString("display_name") : person.getString("name");
|
||||||
redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl);
|
redditDataRoomDatabase.accountDao().updateAccountInfo(name, profileImageUrl, bannerImageUrl);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
parseFailed = true;
|
parseFailed = true;
|
||||||
|
|||||||
@@ -10,15 +10,14 @@ import javax.inject.Singleton;
|
|||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||||
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
|
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import okhttp3.ConnectionPool;
|
import okhttp3.ConnectionPool;
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
|
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
|
||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
|
||||||
|
|
||||||
@Module(includes = AppModule.class)
|
@Module(includes = AppModule.class)
|
||||||
abstract class NetworkModule {
|
abstract class NetworkModule {
|
||||||
@@ -216,4 +215,22 @@ abstract class NetworkModule {
|
|||||||
static StreamableAPI provideStreamableApi(@Named("streamable") Retrofit streamableRetrofit) {
|
static StreamableAPI provideStreamableApi(@Named("streamable") Retrofit streamableRetrofit) {
|
||||||
return streamableRetrofit.create(StreamableAPI.class);
|
return streamableRetrofit.create(StreamableAPI.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static LemmyPostAPI providePostAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||||
|
return new LemmyPostAPI(retrofitHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static LemmyCommentAPI provideCommentAPI(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||||
|
return new LemmyCommentAPI(retrofitHolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static LemmyPrivateMessageAPI provideLemmyPrivateMessageAPI(@Named("base") RetrofitHolder retrofit) {
|
||||||
|
return new LemmyPrivateMessageAPI(retrofit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ class ParseSubscribedThing {
|
|||||||
boolean postingRestrictedToMods = community.getBoolean("posting_restricted_to_mods");
|
boolean postingRestrictedToMods = community.getBoolean("posting_restricted_to_mods");
|
||||||
int instanceId = community.getInt("instance_id");
|
int instanceId = community.getInt("instance_id");
|
||||||
int subscribers = data.getJSONObject("counts").getInt("subscribers");
|
int subscribers = data.getJSONObject("counts").getInt("subscribers");
|
||||||
|
boolean isBlocked = data.getBoolean("blocked");
|
||||||
newSubscribedSubredditData.add(new SubscribedSubredditData(id, title, LemmyUtils.actorID2FullName(actorId), iconUrl, accountName));
|
newSubscribedSubredditData.add(new SubscribedSubredditData(id, title, LemmyUtils.actorID2FullName(actorId), iconUrl, accountName));
|
||||||
newSubredditData.add(new SubredditData(id,name,title,description,removed,published,updated,deleted,nsfw,actorId,local,iconUrl,bannerImageUrl,hidden,postingRestrictedToMods,instanceId,subscribers));
|
newSubredditData.add(new SubredditData(id, name, title, description, removed, published, updated, deleted, nsfw, actorId, local, iconUrl, bannerImageUrl, hidden, postingRestrictedToMods, instanceId, subscribers, isBlocked));
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
import androidx.work.Worker;
|
import androidx.work.Worker;
|
||||||
@@ -28,13 +30,11 @@ import javax.inject.Named;
|
|||||||
import eu.toldi.infinityforlemmy.account.Account;
|
import eu.toldi.infinityforlemmy.account.Account;
|
||||||
import eu.toldi.infinityforlemmy.activities.InboxActivity;
|
import eu.toldi.infinityforlemmy.activities.InboxActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||||
import eu.toldi.infinityforlemmy.message.Message;
|
|
||||||
import eu.toldi.infinityforlemmy.message.ParseMessage;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
|
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@@ -88,9 +88,16 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
if (response != null && response.isSuccessful() && response.body() != null) {
|
if (response != null && response.isSuccessful() && response.body() != null) {
|
||||||
String responseBody = response.body();
|
String responseBody = response.body();
|
||||||
JSONArray messageArray = new JSONObject(responseBody).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
JSONArray messageArray = new JSONObject(responseBody).getJSONArray("replies");
|
||||||
ArrayList<Message> messages = ParseMessage.parseMessages(messageArray,
|
List<CommentInteraction> messages = new ArrayList<>();
|
||||||
context.getResources().getConfiguration().locale, FetchMessage.MESSAGE_TYPE_NOTIFICATION);
|
for (int i = 0; i < messageArray.length(); i++) {
|
||||||
|
JSONObject commentInteractionObject = messageArray.getJSONObject(i);
|
||||||
|
Comment comment = ParseComment.parseSingleComment(commentInteractionObject);
|
||||||
|
boolean isRead = !commentInteractionObject.getJSONObject("comment_reply").getBoolean("read");
|
||||||
|
int id = commentInteractionObject.getJSONObject("comment_reply").getInt("id");
|
||||||
|
messages.add(new CommentInteraction(id, comment, isRead));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!messages.isEmpty()) {
|
if (!messages.isEmpty()) {
|
||||||
NotificationCompat.Builder summaryBuilder = NotificationUtils.buildSummaryNotification(context,
|
NotificationCompat.Builder summaryBuilder = NotificationUtils.buildSummaryNotification(context,
|
||||||
@@ -110,77 +117,36 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
int pendingIntentFlags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
|
int pendingIntentFlags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
|
||||||
for (int messageIndex = messageSize - 1; messageIndex >= 0; messageIndex--) {
|
for (int messageIndex = messageSize - 1; messageIndex >= 0; messageIndex--) {
|
||||||
Message message = messages.get(messageIndex);
|
CommentInteraction message = messages.get(messageIndex);
|
||||||
if (message.getTimeUTC() <= lastNotificationTime) {
|
if (message.getComment().getCommentTimeMillis() <= lastNotificationTime) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasValidMessage = true;
|
hasValidMessage = true;
|
||||||
|
|
||||||
inboxStyle.addLine(message.getAuthor() + " " + message.getBody());
|
inboxStyle.addLine(message.getComment().getAuthorQualifiedName() + " " + message.getComment().getCommentMarkdown());
|
||||||
|
|
||||||
|
|
||||||
|
String title = message.getComment().getAuthorQualifiedName();
|
||||||
|
String summary = message.getComment().getCommunityQualifiedName();
|
||||||
|
|
||||||
String kind = message.getKind();
|
|
||||||
String title;
|
|
||||||
String summary;
|
|
||||||
if (kind.equals(Message.TYPE_COMMENT) || kind.equals(Message.TYPE_LINK)) {
|
|
||||||
title = message.getAuthor();
|
|
||||||
summary = message.getSubject().substring(0, 1).toUpperCase() + message.getSubject().substring(1);
|
|
||||||
} else {
|
|
||||||
title = message.getTitle() == null || message.getTitle().equals("") ? message.getSubject() : message.getTitle();
|
|
||||||
if (kind.equals(Message.TYPE_ACCOUNT)) {
|
|
||||||
summary = context.getString(R.string.notification_summary_account);
|
|
||||||
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
|
||||||
summary = context.getString(R.string.notification_summary_message);
|
|
||||||
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
|
||||||
summary = context.getString(R.string.notification_summary_community);
|
|
||||||
} else {
|
|
||||||
summary = context.getString(R.string.notification_summary_award);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager,
|
NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager,
|
||||||
context, title, message.getBody(), summary,
|
context, title, message.getComment().getCommentMarkdown(), summary,
|
||||||
NotificationUtils.CHANNEL_ID_NEW_MESSAGES,
|
NotificationUtils.CHANNEL_ID_NEW_MESSAGES,
|
||||||
NotificationUtils.CHANNEL_NEW_MESSAGES,
|
NotificationUtils.CHANNEL_NEW_MESSAGES,
|
||||||
NotificationUtils.getAccountGroupName(accountName), color);
|
NotificationUtils.getAccountGroupName(accountName), color);
|
||||||
|
|
||||||
if (kind.equals(Message.TYPE_COMMENT)) {
|
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
Uri uri = Uri.parse(message.getComment().getPermalink());
|
||||||
Uri uri = Uri.parse(message.getContext());
|
intent.setData(uri);
|
||||||
intent.setData(uri);
|
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getId());
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, pendingIntentFlags);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, pendingIntentFlags);
|
builder.setContentIntent(pendingIntent);
|
||||||
builder.setContentIntent(pendingIntent);
|
|
||||||
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
|
if (ActivityCompat.checkSelfPermission(this.getApplicationContext(), android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
return Result.failure();
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
|
||||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 1, intent, pendingIntentFlags);
|
|
||||||
builder.setContentIntent(summaryPendingIntent);
|
|
||||||
} else if (kind.equals(Message.TYPE_LINK)) {
|
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
|
||||||
Uri uri = Uri.parse(message.getContext());
|
|
||||||
intent.setData(uri);
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 2, intent, pendingIntentFlags);
|
|
||||||
builder.setContentIntent(pendingIntent);
|
|
||||||
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
|
||||||
intent.putExtra(InboxActivity.EXTRA_VIEW_MESSAGE, true);
|
|
||||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 3, intent, pendingIntentFlags);
|
|
||||||
builder.setContentIntent(summaryPendingIntent);
|
|
||||||
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
|
||||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 4, intent, pendingIntentFlags);
|
|
||||||
builder.setContentIntent(summaryPendingIntent);
|
|
||||||
} else {
|
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
|
||||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 5, intent, pendingIntentFlags);
|
|
||||||
builder.setContentIntent(summaryPendingIntent);
|
|
||||||
}
|
}
|
||||||
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
|
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
|
||||||
}
|
}
|
||||||
@@ -216,10 +182,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
if (retryCount < 0) {
|
if (retryCount < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Call<String> call = mRetrofit.getRetrofit().create(LemmyAPI.class).userReplies("New", 1, 25, true, account.getAccessToken());
|
||||||
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
|
||||||
.getMessages(APIUtils.getOAuthHeader(account.getAccessToken()),
|
|
||||||
FetchMessage.WHERE_UNREAD, null);
|
|
||||||
Response<String> response = call.execute();
|
Response<String> response = call.execute();
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
|
|||||||
|
|
||||||
import eu.toldi.infinityforlemmy.account.Account;
|
import eu.toldi.infinityforlemmy.account.Account;
|
||||||
import eu.toldi.infinityforlemmy.account.AccountDao;
|
import eu.toldi.infinityforlemmy.account.AccountDao;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomTheme;
|
import eu.toldi.infinityforlemmy.customtheme.CustomTheme;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeDao;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeDao;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.AnonymousMultiredditSubreddit;
|
import eu.toldi.infinityforlemmy.multireddit.AnonymousMultiredditSubreddit;
|
||||||
@@ -38,7 +42,7 @@ import eu.toldi.infinityforlemmy.user.UserData;
|
|||||||
|
|
||||||
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
|
||||||
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
|
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
|
||||||
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class}, version = 23)
|
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class, BlockedUserData.class, BlockedCommunityData.class}, version = 26)
|
||||||
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
||||||
|
|
||||||
public static RedditDataRoomDatabase create(final Context context) {
|
public static RedditDataRoomDatabase create(final Context context) {
|
||||||
@@ -49,7 +53,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
|
MIGRATION_9_10, MIGRATION_10_11, MIGRATION_11_12, MIGRATION_12_13,
|
||||||
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
|
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
|
||||||
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
|
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
|
||||||
MIGRATION_21_22, MIGRATION_22_23)
|
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +63,10 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
|
|
||||||
public abstract SubscribedSubredditDao subscribedSubredditDao();
|
public abstract SubscribedSubredditDao subscribedSubredditDao();
|
||||||
|
|
||||||
|
public abstract BlockedUserDao blockedUserDao();
|
||||||
|
|
||||||
|
public abstract BlockedCommunityDao blockedCommunityDao();
|
||||||
|
|
||||||
public abstract UserDao userDao();
|
public abstract UserDao userDao();
|
||||||
|
|
||||||
public abstract SubscribedUserDao subscribedUserDao();
|
public abstract SubscribedUserDao subscribedUserDao();
|
||||||
@@ -383,4 +391,29 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_23_24 = new Migration(23, 24) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE accounts ADD COLUMN can_downvote INTEGER DEFAULT 1 NOT NULL");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_24_25 = new Migration(24, 25) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE subreddits ADD COLUMN blocked INTEGER DEFAULT 1 NOT NULL");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_25_26 = new Migration(25, 26) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("CREATE TABLE blocked_users" +
|
||||||
|
"(name TEXT, id INTEGER NOT NULL, avatar TEXT, qualified_name TEXT, account_name TEXT NOT NULL, PRIMARY KEY( id, account_name))");
|
||||||
|
database.execSQL("CREATE TABLE blocked_communities" +
|
||||||
|
"(name TEXT, icon TEXT, id INTEGER NOT NULL, qualified_name TEXT, account_name TEXT NOT NULL, PRIMARY KEY( id, account_name))");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,11 @@ public class RetrofitHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseURL() {
|
public String getBaseURL() {
|
||||||
return baseURL;
|
String result = baseURL;
|
||||||
|
if (baseURL.endsWith("/")) {
|
||||||
|
result = baseURL.substring(0, baseURL.length() - 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetrofitHolder(OkHttpClient okHttpClient) {
|
public RetrofitHolder(OkHttpClient okHttpClient) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class SortType {
|
|||||||
TOP_TWELVE_HOURS("TopTwelveHour", "Top"),
|
TOP_TWELVE_HOURS("TopTwelveHour", "Top"),
|
||||||
TOP_DAY("TopDay", "Top"),
|
TOP_DAY("TopDay", "Top"),
|
||||||
TOP_WEEK("TopWeek", "Top"),
|
TOP_WEEK("TopWeek", "Top"),
|
||||||
TOP_MONTH("month", "Top"),
|
TOP_MONTH("TopMonth", "Top"),
|
||||||
TOP_THREE_MONTHS("TopThreeMonths", "Top"),
|
TOP_THREE_MONTHS("TopThreeMonths", "Top"),
|
||||||
TOP_SIX_MONTHS("TopSixMonths", "Top"),
|
TOP_SIX_MONTHS("TopSixMonths", "Top"),
|
||||||
TOP_NINE_MONTHS("TopNineMonths", "Top"),
|
TOP_NINE_MONTHS("TopNineMonths", "Top"),
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ public class Account implements Parcelable {
|
|||||||
@ColumnInfo(name = "instance_url")
|
@ColumnInfo(name = "instance_url")
|
||||||
private String instance_url;
|
private String instance_url;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "can_downvote")
|
||||||
|
private boolean canDownvote = true;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
protected Account(Parcel in) {
|
protected Account(Parcel in) {
|
||||||
accountName = in.readString();
|
accountName = in.readString();
|
||||||
@@ -42,6 +45,7 @@ public class Account implements Parcelable {
|
|||||||
code = in.readString();
|
code = in.readString();
|
||||||
isCurrentUser = in.readByte() != 0;
|
isCurrentUser = in.readByte() != 0;
|
||||||
instance_url = in.readString();
|
instance_url = in.readString();
|
||||||
|
canDownvote = in.readByte() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||||
@@ -58,11 +62,11 @@ public class Account implements Parcelable {
|
|||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public static Account getAnonymousAccount() {
|
public static Account getAnonymousAccount() {
|
||||||
return new Account("-",null, null, null, null, null, false,null);
|
return new Account("-",null, null, null, null, null, false,null,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Account(@NonNull String accountName, String display_name, String accessToken, String code,
|
public Account(@NonNull String accountName, String display_name, String accessToken, String code,
|
||||||
String profileImageUrl, String bannerImageUrl, boolean isCurrentUser,String instance_url) {
|
String profileImageUrl, String bannerImageUrl, boolean isCurrentUser,String instance_url, boolean canDownvote) {
|
||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
this.display_name = display_name;
|
this.display_name = display_name;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
@@ -71,6 +75,7 @@ public class Account implements Parcelable {
|
|||||||
this.bannerImageUrl = bannerImageUrl;
|
this.bannerImageUrl = bannerImageUrl;
|
||||||
this.isCurrentUser = isCurrentUser;
|
this.isCurrentUser = isCurrentUser;
|
||||||
this.instance_url = instance_url;
|
this.instance_url = instance_url;
|
||||||
|
this.canDownvote = canDownvote;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -116,6 +121,10 @@ public class Account implements Parcelable {
|
|||||||
return instance_url;
|
return instance_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canDownvote() {
|
||||||
|
return canDownvote;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeString(accountName);
|
dest.writeString(accountName);
|
||||||
@@ -126,5 +135,6 @@ public class Account implements Parcelable {
|
|||||||
dest.writeString(code);
|
dest.writeString(code);
|
||||||
dest.writeByte((byte) (isCurrentUser ? 1 : 0));
|
dest.writeByte((byte) (isCurrentUser ? 1 : 0));
|
||||||
dest.writeString(instance_url);
|
dest.writeString(instance_url);
|
||||||
|
dest.writeByte((byte) (canDownvote ? 1 : 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.account;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class FetchBlockedThings {
|
||||||
|
|
||||||
|
public static void fetchBlockedThings(Retrofit mRetrofit, String accessToken, String accountName, FetchBlockedThingsListener fetchBlockedThingsListener) {
|
||||||
|
LemmyAPI lemmyAPI = mRetrofit.create(LemmyAPI.class);
|
||||||
|
|
||||||
|
Call<String> call = lemmyAPI.getSiteInfo(accessToken);
|
||||||
|
call.enqueue(new Callback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<String> call, retrofit2.Response<String> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
String siteInfo = response.body();
|
||||||
|
if (siteInfo != null) {
|
||||||
|
List<BlockedUserData> blockedUsers = new ArrayList<>();
|
||||||
|
List<BlockedCommunityData> blockedCommunities = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
JSONObject siteInfoJson = new JSONObject(siteInfo).getJSONObject("my_user");
|
||||||
|
JSONArray blockedUsersJson = (siteInfoJson.has("person_blocks")) ? siteInfoJson.getJSONArray("person_blocks") : null;
|
||||||
|
JSONArray blockedCommunitiesJson = (siteInfoJson.has("community_blocks")) ? siteInfoJson.getJSONArray("community_blocks") : null;
|
||||||
|
if (blockedUsersJson != null) {
|
||||||
|
for (int i = 0; i < blockedUsersJson.length(); i++) {
|
||||||
|
JSONObject blockedUserJson = blockedUsersJson.getJSONObject(i).getJSONObject("target");
|
||||||
|
int id = blockedUserJson.getInt("id");
|
||||||
|
String name = blockedUserJson.getString("name");
|
||||||
|
String avatar = "";
|
||||||
|
if (blockedUserJson.has("avatar"))
|
||||||
|
avatar = blockedUserJson.getString("avatar");
|
||||||
|
|
||||||
|
String qualifiedName = LemmyUtils.actorID2FullName(blockedUserJson.getString("actor_id"));
|
||||||
|
BlockedUserData blockedUserData = new BlockedUserData(id, name, avatar, qualifiedName, accountName);
|
||||||
|
|
||||||
|
blockedUsers.add(blockedUserData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (blockedCommunitiesJson != null) {
|
||||||
|
for (int i = 0; i < blockedCommunitiesJson.length(); i++) {
|
||||||
|
JSONObject blockedCommunityJson = blockedCommunitiesJson.getJSONObject(i);
|
||||||
|
SubredditData blockedCommunityData = ParseSubredditData.parseSubredditData(blockedCommunityJson, true);
|
||||||
|
blockedCommunities.add(new BlockedCommunityData(blockedCommunityData, accountName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchBlockedThingsListener.onFetchBlockedThingsSuccess(blockedUsers, blockedCommunities);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<String> call, Throwable t) {
|
||||||
|
fetchBlockedThingsListener.onFetchBlockedThingsFailure();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface FetchBlockedThingsListener {
|
||||||
|
void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities);
|
||||||
|
|
||||||
|
void onFetchBlockedThingsFailure();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -40,6 +41,7 @@ import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
|||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
@@ -64,10 +66,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
MarkPostAsRead markPostAsRead;
|
||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
|
|
||||||
|
private String mAccountQualifiedName;
|
||||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||||
private ActivityAccountSavedThingBinding binding;
|
private ActivityAccountSavedThingBinding binding;
|
||||||
|
|
||||||
@@ -116,6 +123,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
|
|
||||||
initializeViewPager();
|
initializeViewPager();
|
||||||
}
|
}
|
||||||
@@ -249,7 +257,17 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadSuccess() {
|
||||||
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadFailed() {
|
||||||
|
Toast.makeText(AccountSavedThingActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ import androidx.viewpager2.widget.ViewPager2;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.google.android.material.shape.CornerFamily;
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||||
|
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -377,9 +380,18 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
|
|||||||
button.setTextColor(customThemeWrapper.getFABIconColor());
|
button.setTextColor(customThemeWrapper.getFABIconColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyFABTheme(FloatingActionButton fab) {
|
protected void applyFABTheme(FloatingActionButton fab, boolean isCircular) {
|
||||||
fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent()));
|
fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent()));
|
||||||
fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor()));
|
fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor()));
|
||||||
|
if (isCircular) {
|
||||||
|
ShapeAppearanceModel shapeAppearanceModel = ShapeAppearanceModel.builder()
|
||||||
|
.setAllCorners(CornerFamily.ROUNDED, 100) // Adjust the radius value to control the roundness
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Apply the circular shape to the FAB
|
||||||
|
MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
|
||||||
|
fab.setShapeAppearanceModel(shapeAppearanceModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fixViewPager2Sensitivity(ViewPager2 viewPager2) {
|
protected void fixViewPager2Sensitivity(ViewPager2 viewPager2) {
|
||||||
|
|||||||
@@ -0,0 +1,462 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.core.view.inputmethod.EditorInfoCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentPagerAdapter;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.google.android.material.tabs.TabLayout;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||||
|
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||||
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
|
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
|
||||||
|
import eu.toldi.infinityforlemmy.asynctasks.InsertBlockedThings;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.ViewPagerBugFixed;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
|
import eu.toldi.infinityforlemmy.events.GoBackToMainPageEvent;
|
||||||
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
|
||||||
|
public class BlockedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
|
public static final String EXTRA_SHOW_MULTIREDDITS = "ESM";
|
||||||
|
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
||||||
|
private static final String INSERT_MULTIREDDIT_STATE = "IMS";
|
||||||
|
|
||||||
|
@BindView(R.id.coordinator_layout_subscribed_thing_listing_activity)
|
||||||
|
CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.appbar_layout_subscribed_thing_listing_activity)
|
||||||
|
AppBarLayout appBarLayout;
|
||||||
|
@BindView(R.id.collapsing_toolbar_layout_subscribed_thing_listing_activity)
|
||||||
|
CollapsingToolbarLayout collapsingToolbarLayout;
|
||||||
|
@BindView(R.id.toolbar_subscribed_thing_listing_activity)
|
||||||
|
Toolbar toolbar;
|
||||||
|
@BindView(R.id.search_edit_text_subscribed_thing_listing_activity)
|
||||||
|
EditText searchEditText;
|
||||||
|
@BindView(R.id.tab_layout_subscribed_thing_listing_activity)
|
||||||
|
TabLayout tabLayout;
|
||||||
|
@BindView(R.id.view_pager_subscribed_thing_listing_activity)
|
||||||
|
ViewPagerBugFixed viewPager;
|
||||||
|
@BindView(R.id.fab_subscribed_thing_listing_activity)
|
||||||
|
FloatingActionButton fab;
|
||||||
|
@Inject
|
||||||
|
@Named("oauth")
|
||||||
|
Retrofit mOauthRetrofit;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
RetrofitHolder mRetrofit;
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("current_account")
|
||||||
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor mExecutor;
|
||||||
|
private String mAccessToken;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
private String mAccountQualifiedName;
|
||||||
|
private boolean mInsertSuccess = false;
|
||||||
|
private boolean mInsertMultiredditSuccess = false;
|
||||||
|
private boolean showMultiReddits = false;
|
||||||
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
|
private Menu mMenu;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_subscribed_thing_listing);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
EventBus.getDefault().register(this);
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
||||||
|
mSliderPanel = Slidr.attach(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
Window window = getWindow();
|
||||||
|
|
||||||
|
if (isChangeStatusBarIconColor()) {
|
||||||
|
addOnOffsetChangedListener(appBarLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isImmersiveInterface()) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
window.setDecorFitsSystemWindows(false);
|
||||||
|
} else {
|
||||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
|
||||||
|
}
|
||||||
|
adjustToolbar(toolbar);
|
||||||
|
|
||||||
|
int navBarHeight = getNavBarHeight();
|
||||||
|
if (navBarHeight > 0) {
|
||||||
|
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
|
||||||
|
params.bottomMargin += navBarHeight;
|
||||||
|
fab.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setToolbarGoToTop(toolbar);
|
||||||
|
|
||||||
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE);
|
||||||
|
mInsertMultiredditSuccess = savedInstanceState.getBoolean(INSERT_MULTIREDDIT_STATE);
|
||||||
|
} else {
|
||||||
|
showMultiReddits = getIntent().getBooleanExtra(EXTRA_SHOW_MULTIREDDITS, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mAccessToken == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
searchEditText.setImeOptions(searchEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
searchEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
sectionsPagerAdapter.changeSearchQuery(editable.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
initializeViewPagerAndLoadSubscriptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return mSharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return mCustomThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
|
applyTabLayoutTheme(tabLayout);
|
||||||
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
|
searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
||||||
|
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeViewPagerAndLoadSubscriptions() {
|
||||||
|
fab.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, CreateMultiRedditActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
|
viewPager.setOffscreenPageLimit(2);
|
||||||
|
if (viewPager.getCurrentItem() != 2) {
|
||||||
|
fab.hide();
|
||||||
|
}
|
||||||
|
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
if (position == 0) {
|
||||||
|
unlockSwipeRightToGoBack();
|
||||||
|
fab.hide();
|
||||||
|
} else {
|
||||||
|
lockSwipeRightToGoBack();
|
||||||
|
if (position != 2) {
|
||||||
|
fab.hide();
|
||||||
|
} else {
|
||||||
|
fab.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
|
if (showMultiReddits) {
|
||||||
|
viewPager.setCurrentItem(2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadBlocks(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.subscribed_thing_listing_activity, menu);
|
||||||
|
mMenu = menu;
|
||||||
|
applyMenuItemTheme(menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.action_search_subscribed_thing_listing_activity) {
|
||||||
|
item.setVisible(false);
|
||||||
|
searchEditText.setVisibility(View.VISIBLE);
|
||||||
|
searchEditText.requestFocus();
|
||||||
|
if (searchEditText.requestFocus()) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == android.R.id.home) {
|
||||||
|
if (searchEditText.getVisibility() == View.VISIBLE) {
|
||||||
|
Utils.hideKeyboard(this);
|
||||||
|
searchEditText.setVisibility(View.GONE);
|
||||||
|
searchEditText.setText("");
|
||||||
|
mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true);
|
||||||
|
sectionsPagerAdapter.changeSearchQuery("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (searchEditText.getVisibility() == View.VISIBLE) {
|
||||||
|
Utils.hideKeyboard(this);
|
||||||
|
searchEditText.setVisibility(View.GONE);
|
||||||
|
searchEditText.setText("");
|
||||||
|
mMenu.findItem(R.id.action_search_subscribed_thing_listing_activity).setVisible(true);
|
||||||
|
sectionsPagerAdapter.changeSearchQuery("");
|
||||||
|
} else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE, mInsertSuccess);
|
||||||
|
outState.putBoolean(INSERT_MULTIREDDIT_STATE, mInsertMultiredditSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
EventBus.getDefault().unregister(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadBlocks(boolean forceLoad) {
|
||||||
|
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
||||||
|
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
|
||||||
|
InsertBlockedThings.insertBlockedThings(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountQualifiedName,
|
||||||
|
blockedCommunities, blockedUsers, () -> {
|
||||||
|
mInsertSuccess = true;
|
||||||
|
sectionsPagerAdapter.stopRefreshProgressbar();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchBlockedThingsFailure() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void goBackToMainPageEvent(GoBackToMainPageEvent event) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLongPress() {
|
||||||
|
if (sectionsPagerAdapter != null) {
|
||||||
|
sectionsPagerAdapter.goBackToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void lockSwipeRightToGoBack() {
|
||||||
|
if (mSliderPanel != null) {
|
||||||
|
mSliderPanel.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unlockSwipeRightToGoBack() {
|
||||||
|
if (mSliderPanel != null) {
|
||||||
|
mSliderPanel.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
|
private BlockedCommunitiesListingFragment blockedCommunitiesListingFragment;
|
||||||
|
private BlockedUsersListingFragment followedUsersListingFragment;
|
||||||
|
|
||||||
|
public SectionsPagerAdapter(FragmentManager fm) {
|
||||||
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
switch (position) {
|
||||||
|
default:
|
||||||
|
case 0: {
|
||||||
|
BlockedCommunitiesListingFragment fragment = new BlockedCommunitiesListingFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putBoolean(BlockedCommunitiesListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, false);
|
||||||
|
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
|
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||||
|
bundle.putString(BlockedCommunitiesListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
BlockedUsersListingFragment fragment = new BlockedUsersListingFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(BlockedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
||||||
|
bundle.putString(BlockedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence getPageTitle(int position) {
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.communities));
|
||||||
|
case 1:
|
||||||
|
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
|
||||||
|
case 2:
|
||||||
|
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||||
|
Fragment fragment = (Fragment) super.instantiateItem(container, position);
|
||||||
|
if (position == 0) {
|
||||||
|
blockedCommunitiesListingFragment = (BlockedCommunitiesListingFragment) fragment;
|
||||||
|
} else if (position == 1) {
|
||||||
|
followedUsersListingFragment = (BlockedUsersListingFragment) fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopRefreshProgressbar() {
|
||||||
|
if (blockedCommunitiesListingFragment != null) {
|
||||||
|
((FragmentCommunicator) blockedCommunitiesListingFragment).stopRefreshProgressbar();
|
||||||
|
}
|
||||||
|
if (followedUsersListingFragment != null) {
|
||||||
|
((FragmentCommunicator) followedUsersListingFragment).stopRefreshProgressbar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void goBackToTop() {
|
||||||
|
if (viewPager.getCurrentItem() == 0) {
|
||||||
|
blockedCommunitiesListingFragment.goBackToTop();
|
||||||
|
} else if (viewPager.getCurrentItem() == 1) {
|
||||||
|
followedUsersListingFragment.goBackToTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void changeSearchQuery(String searchQuery) {
|
||||||
|
if (blockedCommunitiesListingFragment != null) {
|
||||||
|
blockedCommunitiesListingFragment.changeSearchQuery(searchQuery);
|
||||||
|
}
|
||||||
|
if (followedUsersListingFragment != null) {
|
||||||
|
followedUsersListingFragment.changeSearchQuery(searchQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -513,8 +513,8 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
|||||||
int start = Math.max(binding.commentCommentEditText.getSelectionStart(), 0);
|
int start = Math.max(binding.commentCommentEditText.getSelectionStart(), 0);
|
||||||
int end = Math.max(binding.commentCommentEditText.getSelectionEnd(), 0);
|
int end = Math.max(binding.commentCommentEditText.getSelectionEnd(), 0);
|
||||||
binding.commentCommentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
binding.commentCommentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
"",
|
||||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeViewModel;
|
|||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
||||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
public class CustomThemeListingActivity extends BaseActivity implements
|
public class CustomThemeListingActivity extends BaseActivity implements
|
||||||
@@ -154,7 +155,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
|
|||||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
"",
|
||||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ package eu.toldi.infinityforlemmy.activities;
|
|||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -23,18 +26,22 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
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.snackbar.Snackbar;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -48,14 +55,16 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
|
|||||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@@ -64,16 +73,19 @@ import retrofit2.Retrofit;
|
|||||||
|
|
||||||
public class EditPostActivity extends BaseActivity implements UploadImageEnabledActivity {
|
public class EditPostActivity extends BaseActivity implements UploadImageEnabledActivity {
|
||||||
|
|
||||||
public static final String EXTRA_TITLE = "ET";
|
public static final String EXTRA_DATA = "ED";
|
||||||
public static final String EXTRA_CONTENT = "EC";
|
|
||||||
public static final String EXTRA_FULLNAME = "EF";
|
|
||||||
|
|
||||||
|
|
||||||
|
private static final int UPLOAD_IMAGE_REQUEST_CODE = 1;
|
||||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||||
|
|
||||||
private static final String UPLOADED_IMAGES_STATE = "UIS";
|
private static final String UPLOADED_IMAGES_STATE = "UIS";
|
||||||
|
|
||||||
|
private static final String picturePattern = "https:\\/\\/[^\\/]+\\/pictrs\\/image\\/([a-f\\d-]+\\.jpeg)";
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_edit_post_activity)
|
@BindView(R.id.coordinator_layout_edit_post_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@BindView(R.id.appbar_layout_edit_post_activity)
|
@BindView(R.id.appbar_layout_edit_post_activity)
|
||||||
@@ -81,13 +93,22 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
@BindView(R.id.toolbar_edit_post_activity)
|
@BindView(R.id.toolbar_edit_post_activity)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.post_title_text_view_edit_post_activity)
|
@BindView(R.id.post_title_text_view_edit_post_activity)
|
||||||
TextView titleTextView;
|
EditText titleEditText;
|
||||||
@BindView(R.id.divider_edit_post_activity)
|
@BindView(R.id.divider_edit_post_activity)
|
||||||
View divider;
|
View divider;
|
||||||
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
|
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
|
||||||
EditText contentEditText;
|
EditText contentEditText;
|
||||||
@BindView(R.id.markdown_bottom_bar_recycler_view_edit_post_activity)
|
@BindView(R.id.markdown_bottom_bar_recycler_view_edit_post_activity)
|
||||||
RecyclerView markdownBottomBarRecyclerView;
|
RecyclerView markdownBottomBarRecyclerView;
|
||||||
|
@BindView(R.id.post_link_edit_text_post_edit_activity)
|
||||||
|
EditText linkEditText;
|
||||||
|
|
||||||
|
@BindView(R.id.upload_image_button_post_edit_activity)
|
||||||
|
MaterialButton uploadImageButton;
|
||||||
|
|
||||||
|
@BindView(R.id.image_view_post_edit_activity)
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("no_oauth")
|
@Named("no_oauth")
|
||||||
RetrofitHolder mRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
@@ -104,13 +125,16 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private String mFullName;
|
private Post mPost;
|
||||||
|
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mPostContent;
|
|
||||||
private boolean isSubmitting = false;
|
private boolean isSubmitting = false;
|
||||||
private Uri capturedImageUri;
|
private Uri capturedImageUri;
|
||||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
private RequestManager mGlide;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
@@ -138,11 +162,49 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
|
mPost = getIntent().getParcelableExtra(EXTRA_DATA);
|
||||||
|
if (mPost == null) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
|
titleEditText.setText(mPost.getTitle());
|
||||||
mPostContent = getIntent().getStringExtra(EXTRA_CONTENT);
|
contentEditText.setText(mPost.getSelfText());
|
||||||
contentEditText.setText(mPostContent);
|
linkEditText.setText(mPost.getUrl());
|
||||||
|
|
||||||
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
|
if (mPost.getUrl() != null && mPost.getUrl().matches(picturePattern)) {
|
||||||
|
loadImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
linkEditText.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||||
|
if (charSequence.toString().matches(picturePattern)) {
|
||||||
|
loadImage();
|
||||||
|
} else {
|
||||||
|
uploadImageButton.setVisibility(View.VISIBLE);
|
||||||
|
imageView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
uploadImageButton.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setType("image/*");
|
||||||
|
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
|
startActivityForResult(Intent.createChooser(intent, getString(R.string.select_from_gallery)), UPLOAD_IMAGE_REQUEST_CODE);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
uploadedImages = savedInstanceState.getParcelableArrayList(UPLOADED_IMAGES_STATE);
|
uploadedImages = savedInstanceState.getParcelableArrayList(UPLOADED_IMAGES_STATE);
|
||||||
@@ -190,18 +252,27 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||||
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
titleEditText.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
||||||
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
|
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
|
||||||
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
||||||
|
linkEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
||||||
|
|
||||||
|
uploadImageButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
|
||||||
|
uploadImageButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
|
||||||
if (titleTypeface != null) {
|
if (titleTypeface != null) {
|
||||||
titleTextView.setTypeface(titleTypeface);
|
titleEditText.setTypeface(titleTypeface);
|
||||||
}
|
}
|
||||||
if (contentTypeface != null) {
|
if (contentTypeface != null) {
|
||||||
contentEditText.setTypeface(contentTypeface);
|
contentEditText.setTypeface(contentTypeface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadImage() {
|
||||||
|
uploadImageButton.setVisibility(View.GONE);
|
||||||
|
imageView.setVisibility(View.VISIBLE);
|
||||||
|
mGlide.load(mPost.getUrl()).into(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
@@ -237,21 +308,19 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
isSubmitting = true;
|
isSubmitting = true;
|
||||||
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
||||||
|
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), titleEditText.getText().toString(), (linkEditText.getText().toString().isEmpty()) ? null : linkEditText.getText().toString(), contentEditText.getText().toString(), mPost.isNSFW(), null, mAccessToken))
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put(APIUtils.THING_ID_KEY, mFullName);
|
|
||||||
params.put(APIUtils.TEXT_KEY, contentEditText.getText().toString());
|
|
||||||
|
|
||||||
mRetrofit.getRetrofit().create(RedditAPI.class)
|
|
||||||
.editPostOrComment(APIUtils.getOAuthHeader(mAccessToken), params)
|
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
isSubmitting = false;
|
isSubmitting = false;
|
||||||
Toast.makeText(EditPostActivity.this, R.string.edit_success, Toast.LENGTH_SHORT).show();
|
if (response.isSuccessful()) {
|
||||||
Intent returnIntent = new Intent();
|
Toast.makeText(EditPostActivity.this, R.string.edit_success, Toast.LENGTH_SHORT).show();
|
||||||
setResult(RESULT_OK, returnIntent);
|
Intent returnIntent = new Intent();
|
||||||
finish();
|
setResult(RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -275,6 +344,39 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
}
|
}
|
||||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||||
|
} else if (requestCode == UPLOAD_IMAGE_REQUEST_CODE) {
|
||||||
|
if (data == null) {
|
||||||
|
Snackbar.make(coordinatorLayout, R.string.error_getting_image, Snackbar.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.makeText(this, R.string.uploading_image, Toast.LENGTH_SHORT).show();
|
||||||
|
Handler handler = new Handler();
|
||||||
|
Uri imageUri = data.getData();
|
||||||
|
mExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
|
Bitmap bitmap = Glide.with(this).asBitmap().load(imageUri).submit().get();
|
||||||
|
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, mAccessToken, bitmap);
|
||||||
|
handler.post(() -> {
|
||||||
|
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
||||||
|
String fileName = Utils.getFileName(this, imageUri);
|
||||||
|
if (fileName == null) {
|
||||||
|
fileName = imageUrlOrError;
|
||||||
|
}
|
||||||
|
mPost.setUrl(imageUrlOrError);
|
||||||
|
linkEditText.setText(imageUrlOrError);
|
||||||
|
Snackbar.make(coordinatorLayout, R.string.upload_image_success, Snackbar.LENGTH_LONG).show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.upload_image_failed, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
handler.post(() -> Toast.makeText(this, R.string.get_image_bitmap_failed, Toast.LENGTH_LONG).show());
|
||||||
|
} catch (XmlPullParserException | JSONException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
handler.post(() -> Toast.makeText(this, R.string.error_processing_image, Toast.LENGTH_LONG).show());
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||||
@@ -282,6 +384,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
editPost();
|
editPost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -305,7 +408,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
if (isSubmitting) {
|
if (isSubmitting) {
|
||||||
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_edit_post_detail);
|
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_edit_post_detail);
|
||||||
} else {
|
} else {
|
||||||
if (contentEditText.getText().toString().equals(mPostContent)) {
|
if (contentEditText.getText().toString().equals(mPost.getSelfText())) {
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
promptAlertDialog(R.string.discard, R.string.discard_detail);
|
promptAlertDialog(R.string.discard, R.string.discard_detail);
|
||||||
@@ -353,7 +456,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
|||||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
"",
|
||||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
public SubredditViewModel mSubredditViewModel;
|
public SubredditViewModel mSubredditViewModel;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
|
|
||||||
|
private String mAccountQualifiedName;
|
||||||
private String name;
|
private String name;
|
||||||
private String userWhere;
|
private String userWhere;
|
||||||
private int postType;
|
private int postType;
|
||||||
@@ -158,6 +160,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
name = getIntent().getStringExtra(EXTRA_NAME);
|
name = getIntent().getStringExtra(EXTRA_NAME);
|
||||||
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
||||||
|
|
||||||
@@ -262,14 +265,14 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindView(PostFilter postFilter, boolean initializeFragment) {
|
private void bindView(PostFilter postFilter, boolean initializeFragment) {
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostPagingSource.TYPE_FRONT_PAGE:
|
case PostPagingSource.TYPE_FRONT_PAGE:
|
||||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||||
getSupportActionBar().setTitle(R.string.home);
|
getSupportActionBar().setTitle(R.string.subscribed_feed);
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_SEARCH:
|
case PostPagingSource.TYPE_SEARCH:
|
||||||
getSupportActionBar().setTitle(R.string.search);
|
getSupportActionBar().setTitle(R.string.search);
|
||||||
@@ -470,7 +473,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import eu.toldi.infinityforlemmy.R;
|
|||||||
import eu.toldi.infinityforlemmy.RecyclerViewContentScrollingInterface;
|
import eu.toldi.infinityforlemmy.RecyclerViewContentScrollingInterface;
|
||||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
@@ -56,14 +55,12 @@ import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
|||||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.fragments.PrivateMessageFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||||
import eu.toldi.infinityforlemmy.message.Message;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import retrofit2.Response;
|
|
||||||
|
|
||||||
public class InboxActivity extends BaseActivity implements ActivityToolbarInterface, RecyclerViewContentScrollingInterface {
|
public class InboxActivity extends BaseActivity implements ActivityToolbarInterface, RecyclerViewContentScrollingInterface {
|
||||||
|
|
||||||
@@ -184,7 +181,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
//pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||||
startActivity(pmIntent);
|
startActivity(pmIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -197,7 +194,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
//pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, thingEditText.getText().toString());
|
||||||
startActivity(pmIntent);
|
startActivity(pmIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
@@ -229,7 +226,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
|
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
|
||||||
@@ -268,13 +265,16 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(2);
|
viewPager2.setOffscreenPageLimit(3);
|
||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.notifications));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.replies));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.mentions));
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.messages));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.messages));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -302,31 +302,21 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
|
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
|
ReadMessage.readAllMessages(mRetrofit.getRetrofit(), mAccessToken, new ReadMessage.ReadMessageListener() {
|
||||||
mRetrofit.getRetrofit().create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
|
@Override
|
||||||
.enqueue(new Callback<>() {
|
public void readSuccess() {
|
||||||
@Override
|
Toast.makeText(InboxActivity.this, R.string.read_all_messages_success, Toast.LENGTH_SHORT).show();
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
if (sectionsPagerAdapter != null) {
|
||||||
if (response.isSuccessful()) {
|
sectionsPagerAdapter.readAllMessages();
|
||||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_success, Toast.LENGTH_SHORT).show();
|
}
|
||||||
if (sectionsPagerAdapter != null) {
|
EventBus.getDefault().post(new ChangeInboxCountEvent(0));
|
||||||
sectionsPagerAdapter.readAllMessages();
|
}
|
||||||
}
|
|
||||||
EventBus.getDefault().post(new ChangeInboxCountEvent(0));
|
|
||||||
} else {
|
|
||||||
if (response.code() == 429) {
|
|
||||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_time_limit, Toast.LENGTH_LONG).show();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_failed, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void readFailed() {
|
||||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_failed, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (item.getItemId() == android.R.id.home) {
|
} else if (item.getItemId() == android.R.id.home) {
|
||||||
finish();
|
finish();
|
||||||
@@ -341,7 +331,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
if (resultCode == RESULT_OK && requestCode == SEARCH_USER_REQUEST_CODE && data != null) {
|
if (resultCode == RESULT_OK && requestCode == SEARCH_USER_REQUEST_CODE && data != null) {
|
||||||
String username = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
|
String username = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME);
|
||||||
Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
||||||
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
//intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,7 +428,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Message getPrivateMessage(int index) {
|
CommentInteraction getPrivateMessage(int index) {
|
||||||
if (viewPager2 == null || fragmentManager == null) {
|
if (viewPager2 == null || fragmentManager == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -452,26 +442,27 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Fragment createFragment(int position) {
|
public Fragment createFragment(int position) {
|
||||||
if (position == 0) {
|
Fragment fragment = new InboxFragment();
|
||||||
InboxFragment fragment = new InboxFragment();
|
Bundle bundle = new Bundle();
|
||||||
Bundle bundle = new Bundle();
|
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
switch (position) {
|
||||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
|
case 0:
|
||||||
fragment.setArguments(bundle);
|
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_REPLIES);
|
||||||
return fragment;
|
break;
|
||||||
} else {
|
case 1:
|
||||||
InboxFragment fragment = new InboxFragment();
|
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MENTIONS);
|
||||||
Bundle bundle = new Bundle();
|
break;
|
||||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
case 2:
|
||||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
|
fragment = new PrivateMessageFragment();
|
||||||
fragment.setArguments(bundle);
|
break;
|
||||||
return fragment;
|
|
||||||
}
|
}
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ import javax.inject.Named;
|
|||||||
|
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||||
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
@@ -35,10 +40,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||||
public static final String EXTRA_IS_NSFW = "EIN";
|
public static final String EXTRA_IS_NSFW = "EIN";
|
||||||
|
|
||||||
private static final String POST_PATTERN = "/r/[\\w-]+/comments/\\w+/?\\w+/?";
|
private static final String POST_PATTERN = "https?:\\/\\/\\S+\\/post\\/\\d+";
|
||||||
private static final String POST_PATTERN_2 = "/(u|U|user)/[\\w-]+/comments/\\w+/?\\w+/?";
|
|
||||||
private static final String POST_PATTERN_3 = "/[\\w-]+$";
|
private static final String POST_PATTERN_3 = "/[\\w-]+$";
|
||||||
private static final String COMMENT_PATTERN = "/(r|u|U|user)/[\\w-]+/comments/\\w+/?[\\w-]+/\\w+/?";
|
private static final String COMMENT_PATTERN = "https?:\\/\\/\\S+\\/comment\\/\\d+";
|
||||||
private static final String SUBREDDIT_PATTERN = "(?:https?://[\\w.-]+)?/c/[\\w-]+(@[\\w.-]+)?";
|
private static final String SUBREDDIT_PATTERN = "(?:https?://[\\w.-]+)?/c/[\\w-]+(@[\\w.-]+)?";
|
||||||
private static final String USER_PATTERN = "(?:https?://[\\w.-]+)?/u(sers)?/[\\w-]+(@[\\w.-]+)?";
|
private static final String USER_PATTERN = "(?:https?://[\\w.-]+)?/u(sers)?/[\\w-]+(@[\\w.-]+)?";
|
||||||
private static final String SIDEBAR_PATTERN = "/[rR]/[\\w-]+/about/sidebar";
|
private static final String SIDEBAR_PATTERN = "/[rR]/[\\w-]+/about/sidebar";
|
||||||
@@ -60,11 +64,24 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ObjectResolver mObjectResolver;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("current_account")
|
||||||
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
RetrofitHolder mRetrofit;
|
||||||
|
|
||||||
|
private String mAccessToken;
|
||||||
|
|
||||||
private Uri getRedditUriByPath(String path) {
|
private Uri getRedditUriByPath(String path) {
|
||||||
if (path.charAt(0) != '/') {
|
if (path.charAt(0) != '/') {
|
||||||
return Uri.parse("https://www.reddit.com/" + path);
|
return Uri.parse(mRetrofit.getBaseURL() + path);
|
||||||
} else {
|
} else {
|
||||||
return Uri.parse("https://www.reddit.com" + path);
|
return Uri.parse(mRetrofit.getBaseURL() + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +90,11 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
|
if (mAccessToken != null) {
|
||||||
|
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||||
|
mRetrofit.setBaseURL(instance);
|
||||||
|
}
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
@@ -169,6 +191,77 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} else if (uri.toString().matches(POST_PATTERN)) {
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
// switch retrofit to use the current instance for anonymous requests
|
||||||
|
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||||
|
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, Integer.parseInt(segments.get(segments.size() - 1)));
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||||
|
@Override
|
||||||
|
public void onResolveObjectSuccess(Object p) {
|
||||||
|
Post post = (Post) p;
|
||||||
|
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResolveObjectFailed() {
|
||||||
|
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (uri.toString().matches(COMMENT_PATTERN)) {
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||||
|
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), null, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
|
||||||
|
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||||
|
Comment comment = comments.get(0);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchCommentFailed() {
|
||||||
|
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||||
|
@Override
|
||||||
|
public void onResolveObjectSuccess(Object c) {
|
||||||
|
Comment comment = (Comment) c;
|
||||||
|
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResolveObjectFailed() {
|
||||||
|
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (authority.equals("v.redd.it")) {
|
} else if (authority.equals("v.redd.it")) {
|
||||||
Intent intent = new Intent(this, ViewVideoActivity.class);
|
Intent intent = new Intent(this, ViewVideoActivity.class);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
||||||
@@ -187,35 +280,12 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.equals("/report")) {
|
} else if (path.equals("/report")) {
|
||||||
openInWebView(uri);
|
openInWebView(uri);
|
||||||
} else if (path.matches(POST_PATTERN) || path.matches(POST_PATTERN_2)) {
|
|
||||||
int commentsIndex = segments.lastIndexOf("comments");
|
|
||||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
|
||||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
|
||||||
deepLinkError(uri);
|
|
||||||
}
|
|
||||||
} else if (path.matches(POST_PATTERN_3)) {
|
} else if (path.matches(POST_PATTERN_3)) {
|
||||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.matches(COMMENT_PATTERN)) {
|
|
||||||
int commentsIndex = segments.lastIndexOf("comments");
|
|
||||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
|
||||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, segments.get(segments.size() - 1));
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
|
||||||
deepLinkError(uri);
|
|
||||||
}
|
|
||||||
} else if (path.matches(WIKI_PATTERN)) {
|
} else if (path.matches(WIKI_PATTERN)) {
|
||||||
String[] pathSegments = path.split("/");
|
String[] pathSegments = path.split("/");
|
||||||
String wikiPage;
|
String wikiPage;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.text.Editable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.InflateException;
|
import android.view.InflateException;
|
||||||
@@ -26,6 +27,8 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -43,6 +46,8 @@ import eu.toldi.infinityforlemmy.asynctasks.ParseAndInsertNewAccount;
|
|||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
||||||
|
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@@ -137,22 +142,26 @@ public class LoginActivity extends BaseActivity {
|
|||||||
|
|
||||||
loginButton.setOnClickListener(view -> {
|
loginButton.setOnClickListener(view -> {
|
||||||
Log.i("LoginActivity", "Login button clicked");
|
Log.i("LoginActivity", "Login button clicked");
|
||||||
|
if(!checkFields())
|
||||||
|
return;
|
||||||
loginButton.setEnabled(false);
|
loginButton.setEnabled(false);
|
||||||
progressBar.setVisibility(ProgressBar.VISIBLE);
|
progressBar.setVisibility(ProgressBar.VISIBLE);
|
||||||
String username = username_input.getText().toString();
|
String username = username_input.getText().toString().trim();
|
||||||
String instance = correctURL(instance_input.getText().toString());
|
String instance = correctURL(instance_input.getText().toString().trim());
|
||||||
if(!Patterns.WEB_URL.matcher(instance).matches()){
|
try {
|
||||||
instance_input.setError("Invalid instance URL");
|
URL urlObj = new URL(instance);
|
||||||
|
instance = urlObj.getProtocol() + "://" + urlObj.getHost() + "/";
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
instance_input.setError("Invalid URL");
|
||||||
Toast.makeText(LoginActivity.this, "Invalid instance URL", Toast.LENGTH_SHORT).show();
|
Toast.makeText(LoginActivity.this, "Invalid instance URL", Toast.LENGTH_SHORT).show();
|
||||||
loginButton.setEnabled(true);
|
|
||||||
progressBar.setVisibility(ProgressBar.GONE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.i("LoginActivity", "Instance: " + instance);
|
Log.i("LoginActivity", "Instance: " + instance);
|
||||||
AccountLoginDTO accountLoginDTO = new AccountLoginDTO(username,password_input.getText().toString(),token_2fa_input.getText().toString());
|
AccountLoginDTO accountLoginDTO = new AccountLoginDTO(username, password_input.getText().toString(), token_2fa_input.getText().toString());
|
||||||
mRetrofit.setBaseURL(instance);
|
mRetrofit.setBaseURL(instance);
|
||||||
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
|
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
|
||||||
Call<String> accessTokenCall = api.userLogin(accountLoginDTO);
|
Call<String> accessTokenCall = api.userLogin(accountLoginDTO);
|
||||||
|
String finalInstance = instance;
|
||||||
accessTokenCall.enqueue(new Callback<String>() {
|
accessTokenCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@@ -176,17 +185,35 @@ public class LoginActivity extends BaseActivity {
|
|||||||
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchMyInfoSuccess(String name, String display_name, String profileImageUrl, String bannerImageUrl) {
|
public void onFetchMyInfoSuccess(String name, String display_name, String profileImageUrl, String bannerImageUrl) {
|
||||||
|
FetchSiteInfo.fetchSiteInfo(mRetrofit.getRetrofit(), accessToken, new FetchSiteInfo.FetchSiteInfoListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||||
|
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||||
|
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,canDownvote, mRedditDataRoomDatabase.accountDao(),
|
||||||
|
() -> {
|
||||||
|
Intent resultIntent = new Intent();
|
||||||
|
setResult(Activity.RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSiteInfoFailed() {
|
||||||
|
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,true, mRedditDataRoomDatabase.accountDao(),
|
||||||
|
() -> {
|
||||||
|
Intent resultIntent = new Intent();
|
||||||
|
setResult(Activity.RESULT_OK, resultIntent);
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
|
mCurrentAccountSharedPreferences.edit().putString(SharedPreferencesUtils.ACCESS_TOKEN, accessToken)
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
|
.putString(SharedPreferencesUtils.ACCOUNT_NAME, display_name)
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
|
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, name)
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,instance)
|
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,finalInstance)
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
|
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, profileImageUrl).apply();
|
||||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode,instance, mRedditDataRoomDatabase.accountDao(),
|
|
||||||
() -> {
|
|
||||||
Intent resultIntent = new Intent();
|
|
||||||
setResult(Activity.RESULT_OK, resultIntent);
|
|
||||||
finish();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -240,6 +267,26 @@ public class LoginActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkFields() {
|
||||||
|
boolean result = true;
|
||||||
|
Editable username = username_input.getText();
|
||||||
|
Editable password = password_input.getText();
|
||||||
|
Editable instance = instance_input.getText();
|
||||||
|
if(instance == null || instance.toString().isEmpty()) {
|
||||||
|
instance_input.setError(getString(R.string.instance_cannot_be_empty));
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
if(username == null || username.toString().isEmpty()) {
|
||||||
|
username_input.setError(getString(R.string.username_cannot_be_empty));
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
if(password == null || password.toString().isEmpty()) {
|
||||||
|
password_input.setError(getString(R.string.password_cannot_be_empty));
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
private static String correctURL(String url) {
|
private static String correctURL(String url) {
|
||||||
if (url == null || url.isEmpty()) {
|
if (url == null || url.isEmpty()) {
|
||||||
throw new IllegalArgumentException("URL cannot be null or empty");
|
throw new IllegalArgumentException("URL cannot be null or empty");
|
||||||
|
|||||||
@@ -107,12 +107,14 @@ import eu.toldi.infinityforlemmy.events.ChangeLockBottomAppBarEvent;
|
|||||||
import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.ChangeRequireAuthToAccountSectionEvent;
|
import eu.toldi.infinityforlemmy.events.ChangeRequireAuthToAccountSectionEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent;
|
import eu.toldi.infinityforlemmy.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent;
|
||||||
|
import eu.toldi.infinityforlemmy.events.ChangeUseCircularFabEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiRedditViewModel;
|
import eu.toldi.infinityforlemmy.multireddit.MultiRedditViewModel;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
@@ -213,6 +215,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
MarkPostAsRead markPostAsRead;
|
||||||
|
|
||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private NavigationDrawerRecyclerViewMergedAdapter adapter;
|
private NavigationDrawerRecyclerViewMergedAdapter adapter;
|
||||||
@@ -225,9 +231,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
private boolean mFetchUserInfoSuccess = false;
|
private boolean mFetchUserInfoSuccess = false;
|
||||||
private boolean mFetchSubscriptionsSuccess = false;
|
private boolean mFetchSubscriptionsSuccess = false;
|
||||||
private boolean mDrawerOnAccountSwitch = false;
|
private boolean mDrawerOnAccountSwitch = false;
|
||||||
private String mMessageFullname;
|
private int mMessageFullname;
|
||||||
private String mNewAccountName;
|
private String mNewAccountName;
|
||||||
private boolean hideFab;
|
private boolean hideFab;
|
||||||
|
|
||||||
|
private boolean useCircularFab;
|
||||||
private boolean showBottomAppBar;
|
private boolean showBottomAppBar;
|
||||||
private int mBackButtonAction;
|
private int mBackButtonAction;
|
||||||
private boolean mLockBottomAppBar;
|
private boolean mLockBottomAppBar;
|
||||||
@@ -254,6 +262,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
||||||
|
useCircularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||||
|
|
||||||
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
|
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
|
||||||
@@ -339,11 +348,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||||
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
||||||
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
|
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
|
||||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||||
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
|
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
|
||||||
} else {
|
} else {
|
||||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
|
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSSAGE_FULLNAME, 0);
|
||||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +389,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
navigationView.setBackgroundColor(backgroundColor);
|
navigationView.setBackgroundColor(backgroundColor);
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeNotificationAndBindView() {
|
private void initializeNotificationAndBindView() {
|
||||||
@@ -472,7 +481,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountName);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -799,17 +807,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences,
|
adapter = new NavigationDrawerRecyclerViewMergedAdapter(this, mSharedPreferences,
|
||||||
mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences,
|
mNsfwAndSpoilerSharedPreferences, mNavigationDrawerSharedPreferences, mSecuritySharedPreferences,
|
||||||
mCustomThemeWrapper, mAccountName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
|
mCustomThemeWrapper, mAccountName, mAccountQualifiedName, new NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMenuClick(int stringId) {
|
public void onMenuClick(int stringId) {
|
||||||
Intent intent = null;
|
Intent intent = null;
|
||||||
if (stringId == R.string.profile) {
|
if (stringId == R.string.profile) {
|
||||||
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
|
intent = new Intent(MainActivity.this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||||
} else if (stringId == R.string.subscriptions) {
|
} else if (stringId == R.string.subscriptions) {
|
||||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||||
} else if (stringId == R.string.multi_reddit) {
|
} else if (stringId == R.string.multi_reddit) {
|
||||||
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
intent = new Intent(MainActivity.this, SubscribedThingListingActivity.class);
|
||||||
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
|
intent.putExtra(SubscribedThingListingActivity.EXTRA_SHOW_MULTIREDDITS, true);
|
||||||
} else if (stringId == R.string.history) {
|
} else if (stringId == R.string.history) {
|
||||||
@@ -874,6 +882,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
});
|
});
|
||||||
} else if (stringId == R.string.anonymous_account_instance) {
|
} else if (stringId == R.string.anonymous_account_instance) {
|
||||||
changeAnonymousAccountInstance();
|
changeAnonymousAccountInstance();
|
||||||
|
} else if (stringId == R.string.blocks) {
|
||||||
|
intent = new Intent(MainActivity.this, BlockedThingListingActivity.class);
|
||||||
}
|
}
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@@ -922,7 +932,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.home)));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_TITLE, getString(R.string.subscribed_feed)));
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
|
Utils.setTitleWithCustomFontToTab(typeface, tab, mMainActivityTabsSharedPreferences.getString((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_TITLE, getString(R.string.local)));
|
||||||
@@ -1020,11 +1030,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
loadUserData();
|
loadUserData();
|
||||||
|
|
||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
if (mMessageFullname != null) {
|
if (mMessageFullname != 0) {
|
||||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void readSuccess() {
|
public void readSuccess() {
|
||||||
mMessageFullname = null;
|
mMessageFullname = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1067,20 +1077,29 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
private void loadUserData() {
|
private void loadUserData() {
|
||||||
if (!mFetchUserInfoSuccess) {
|
if (!mFetchUserInfoSuccess) {
|
||||||
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mRetrofit.getRetrofit(), mAccessToken,
|
FetchUserData.fetchUnreadCount(mRetrofit.getRetrofit(), mAccessToken, new FetchUserData.FetchUserUnreadCountListener() {
|
||||||
mAccountName, new FetchUserData.FetchUserDataListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
public void onFetchUserUnreadCountSuccess(int inboxCount) {
|
||||||
MainActivity.this.inboxCount = inboxCount;
|
MainActivity.this.inboxCount = inboxCount;
|
||||||
mAccountName = userData.getName();
|
|
||||||
mFetchUserInfoSuccess = true;
|
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.setInboxCount(inboxCount);
|
adapter.setInboxCount(inboxCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchUserDataFailed() {
|
public void onFetchUserUnreadCountFailed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mRetrofit.getRetrofit(), mAccessToken,
|
||||||
|
mAccountName, new FetchUserData.FetchUserDataListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||||
|
mAccountName = userData.getName();
|
||||||
|
mFetchUserInfoSuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchUserDataFailed() {
|
||||||
mFetchUserInfoSuccess = false;
|
mFetchUserInfoSuccess = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1172,7 +1191,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||||
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
|
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
|
||||||
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
|
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
|
||||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||||
outState.putInt(INBOX_COUNT_STATE, inboxCount);
|
outState.putInt(INBOX_COUNT_STATE, inboxCount);
|
||||||
}
|
}
|
||||||
@@ -1331,6 +1350,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
|
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChangeUseCircularFab(ChangeUseCircularFabEvent event) {
|
||||||
|
useCircularFab = event.isUseCircularFab();
|
||||||
|
applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLongPress() {
|
public void onLongPress() {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
@@ -1376,10 +1401,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
goToUser();
|
goToUser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
|
||||||
randomThing();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.hideReadPosts();
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
@@ -1608,7 +1629,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadSuccess() {
|
||||||
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadFailed() {
|
||||||
|
Toast.makeText(MainActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doNotShowRedditAPIInfoAgain() {
|
public void doNotShowRedditAPIInfoAgain() {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import eu.toldi.infinityforlemmy.post.Post;
|
|||||||
import eu.toldi.infinityforlemmy.postfilter.DeletePostFilter;
|
import eu.toldi.infinityforlemmy.postfilter.DeletePostFilter;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterViewModel;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterViewModel;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class PostFilterPreferenceActivity extends BaseActivity {
|
public class PostFilterPreferenceActivity extends BaseActivity {
|
||||||
|
|
||||||
@@ -205,7 +206,7 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
|||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsageViewModel;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsageViewModel;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.SavePostFilterUsage;
|
import eu.toldi.infinityforlemmy.postfilter.SavePostFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
public class PostFilterUsageListingActivity extends BaseActivity {
|
public class PostFilterUsageListingActivity extends BaseActivity {
|
||||||
@@ -206,7 +207,7 @@ public class PostFilterUsageListingActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +74,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.events.SubmitGalleryPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitGalleryPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
||||||
@@ -102,6 +105,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_gallery_activity)
|
@BindView(R.id.coordinator_layout_post_gallery_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -123,10 +127,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_gallery_activity)
|
@BindView(R.id.divider_1_post_gallery_activity)
|
||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_gallery_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_gallery_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_gallery_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_gallery_activity)
|
||||||
@@ -168,6 +168,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean loadSubredditIconSuccessful = true;
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
@@ -245,6 +246,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
@@ -279,7 +281,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -290,17 +291,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -314,11 +304,25 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -347,40 +351,12 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -449,8 +425,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@@ -458,8 +433,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
@@ -612,7 +585,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_GALLERY);
|
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_GALLERY);
|
||||||
ArrayList<RedditGalleryPayload.Item> items = new ArrayList<>();
|
ArrayList<RedditGalleryPayload.Item> items = new ArrayList<>();
|
||||||
for (RedditGallerySubmissionRecyclerViewAdapter.RedditGalleryImageInfo i : redditGalleryImageInfoList) {
|
for (RedditGallerySubmissionRecyclerViewAdapter.RedditGalleryImageInfo i : redditGalleryImageInfoList) {
|
||||||
@@ -648,6 +621,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
@@ -666,19 +640,16 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
}
|
}
|
||||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
@@ -709,10 +680,6 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.widget.EditText;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -25,6 +26,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
|||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
@@ -43,6 +46,7 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -55,22 +59,31 @@ import eu.toldi.infinityforlemmy.Infinity;
|
|||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||||
import eu.toldi.infinityforlemmy.account.Account;
|
import eu.toldi.infinityforlemmy.account.Account;
|
||||||
|
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
import eu.toldi.infinityforlemmy.events.SubmitImagePostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitImagePostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class PostImageActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
public class PostImageActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
|
|
||||||
@@ -90,6 +103,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||||
|
|
||||||
|
private static final int PICK_IMAGE_REQUEST_CODE_2 = 100;
|
||||||
|
private static final int CAPTURE_IMAGE_REQUEST_CODE_2 = 200;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_image_activity)
|
@BindView(R.id.coordinator_layout_post_image_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@BindView(R.id.appbar_layout_post_image_activity)
|
@BindView(R.id.appbar_layout_post_image_activity)
|
||||||
@@ -110,10 +127,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_image_activity)
|
@BindView(R.id.divider_1_post_image_activity)
|
||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_image_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_image_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_image_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_image_activity)
|
||||||
@@ -153,6 +166,11 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
@Inject
|
@Inject
|
||||||
@Named("current_account")
|
@Named("current_account")
|
||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
|
|
||||||
|
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||||
|
EditText contentEditText;
|
||||||
|
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||||
|
RecyclerView markdownBottomBarRecyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -162,6 +180,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean loadSubredditIconSuccessful = true;
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
@@ -183,6 +202,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
private Snackbar mPostingSnackbar;
|
private Snackbar mPostingSnackbar;
|
||||||
|
|
||||||
|
private Uri capturedImageUri;
|
||||||
|
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
@@ -217,6 +239,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
@@ -247,7 +270,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -258,17 +280,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -282,11 +293,25 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -320,40 +345,12 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -400,6 +397,30 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
constraintLayout.setVisibility(View.VISIBLE);
|
constraintLayout.setVisibility(View.VISIBLE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||||
|
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(int item) {
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||||
|
PostImageActivity.this, contentEditText, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUploadImage() {
|
||||||
|
Utils.hideKeyboard(PostImageActivity.this);
|
||||||
|
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||||
|
Bundle arguments = new Bundle();
|
||||||
|
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||||
|
uploadedImages);
|
||||||
|
fragment.setArguments(arguments);
|
||||||
|
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||||
|
LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCurrentAccount() {
|
private void loadCurrentAccount() {
|
||||||
@@ -451,20 +472,17 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
applyFABTheme(captureFab);
|
boolean circleFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||||
applyFABTheme(selectFromLibraryFab);
|
applyFABTheme(captureFab, circleFab);
|
||||||
|
applyFABTheme(selectFromLibraryFab, circleFab);
|
||||||
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
selectAgainTextView.setTypeface(typeface);
|
selectAgainTextView.setTypeface(typeface);
|
||||||
@@ -493,7 +511,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
@@ -570,8 +588,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.setData(imageUri);
|
intent.setData(imageUri);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
|
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||||
@@ -608,6 +627,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
@@ -628,19 +648,15 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getExtras().getParcelable(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
}
|
}
|
||||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
@@ -657,6 +673,16 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
loadImage();
|
loadImage();
|
||||||
}
|
}
|
||||||
|
} else if (requestCode == PICK_IMAGE_REQUEST_CODE_2) {
|
||||||
|
if (data == null) {
|
||||||
|
Toast.makeText(PostImageActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||||
|
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE_2) {
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,10 +695,6 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -700,8 +722,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
isPosting = false;
|
isPosting = false;
|
||||||
mPostingSnackbar.dismiss();
|
mPostingSnackbar.dismiss();
|
||||||
if (submitImagePostEvent.postSuccess) {
|
if (submitImagePostEvent.postSuccess) {
|
||||||
Intent intent = new Intent(PostImageActivity.this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(PostImageActivity.this, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, submitImagePostEvent.post);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
@@ -740,4 +762,37 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImage() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setType("image/*");
|
||||||
|
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
|
startActivityForResult(Intent.createChooser(intent,
|
||||||
|
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE_2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void captureImage() {
|
||||||
|
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
try {
|
||||||
|
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||||
|
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||||
|
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||||
|
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE_2);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||||
|
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||||
|
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||||
|
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
|
"",
|
||||||
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package eu.toldi.infinityforlemmy.activities;
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -20,6 +23,9 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
@@ -35,6 +41,9 @@ import com.libRG.CustomTextView;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -47,17 +56,26 @@ import eu.toldi.infinityforlemmy.Infinity;
|
|||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||||
import eu.toldi.infinityforlemmy.account.Account;
|
import eu.toldi.infinityforlemmy.account.Account;
|
||||||
|
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.apis.TitleSuggestion;
|
import eu.toldi.infinityforlemmy.apis.TitleSuggestion;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@@ -67,12 +85,13 @@ import retrofit2.Retrofit;
|
|||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
|
|
||||||
public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_LINK = "EL";
|
static final String EXTRA_LINK = "EL";
|
||||||
|
|
||||||
private static final String SELECTED_ACCOUNT_STATE = "SAS";
|
private static final String SELECTED_ACCOUNT_STATE = "SAS";
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||||
@@ -84,6 +103,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private static final String IS_NSFW_STATE = "INS";
|
private static final String IS_NSFW_STATE = "INS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||||
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||||
|
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_link_activity)
|
@BindView(R.id.coordinator_layout_post_link_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -107,10 +129,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.divider_2_post_link_activity)
|
@BindView(R.id.divider_2_post_link_activity)
|
||||||
MaterialDivider divider2;
|
MaterialDivider divider2;
|
||||||
@BindView(R.id.flair_custom_text_view_post_link_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_link_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_link_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_link_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_link_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_link_activity)
|
||||||
@@ -125,6 +143,11 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
MaterialButton suggestTitleButton;
|
MaterialButton suggestTitleButton;
|
||||||
@BindView(R.id.post_link_edit_text_post_link_activity)
|
@BindView(R.id.post_link_edit_text_post_link_activity)
|
||||||
EditText linkEditText;
|
EditText linkEditText;
|
||||||
|
|
||||||
|
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||||
|
EditText contentEditText;
|
||||||
|
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||||
|
RecyclerView markdownBottomBarRecyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("no_oauth")
|
@Named("no_oauth")
|
||||||
RetrofitHolder mRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
@@ -147,6 +170,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean loadSubredditIconSuccessful = true;
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
@@ -167,6 +191,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||||
private Snackbar mPostingSnackbar;
|
private Snackbar mPostingSnackbar;
|
||||||
|
|
||||||
|
private Uri capturedImageUri;
|
||||||
|
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
@@ -200,6 +227,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
@@ -225,7 +253,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -236,17 +263,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -260,11 +276,25 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -298,40 +328,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -360,21 +362,46 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
.baseUrl("http://localhost/")
|
.baseUrl("http://localhost/")
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback<String>() {
|
.build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||||
|
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(int item) {
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||||
|
PostLinkActivity.this, contentEditText, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUploadImage() {
|
||||||
|
Utils.hideKeyboard(PostLinkActivity.this);
|
||||||
|
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||||
|
Bundle arguments = new Bundle();
|
||||||
|
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||||
|
uploadedImages);
|
||||||
|
fragment.setArguments(arguments);
|
||||||
|
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||||
|
LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCurrentAccount() {
|
private void loadCurrentAccount() {
|
||||||
@@ -426,8 +453,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@@ -439,8 +464,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
suggestTitleButton.setTypeface(typeface);
|
suggestTitleButton.setTypeface(typeface);
|
||||||
@@ -465,12 +488,12 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
|
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
|
||||||
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
loadSubredditIconSuccessful = true;
|
loadSubredditIconSuccessful = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void promptAlertDialog(int titleResId, int messageResId) {
|
private void promptAlertDialog(int titleResId, int messageResId) {
|
||||||
@@ -541,9 +564,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||||
|
intent.putExtra(SubmitPostService.EXTRA_URL, linkEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_LINK);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_LINK);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
@@ -575,6 +599,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
@@ -589,22 +614,29 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getExtras().getParcelable(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
|
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
|
if (data == null) {
|
||||||
|
Toast.makeText(PostLinkActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||||
|
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,10 +650,6 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -664,4 +692,37 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImage() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setType("image/*");
|
||||||
|
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
|
startActivityForResult(Intent.createChooser(intent,
|
||||||
|
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void captureImage() {
|
||||||
|
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
try {
|
||||||
|
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||||
|
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||||
|
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||||
|
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||||
|
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||||
|
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||||
|
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
|
"",
|
||||||
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -64,6 +63,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.events.SubmitPollPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitPollPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@@ -87,6 +89,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private static final String IS_NSFW_STATE = "INS";
|
private static final String IS_NSFW_STATE = "INS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_poll_activity)
|
@BindView(R.id.coordinator_layout_post_poll_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -108,10 +111,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_poll_activity)
|
@BindView(R.id.divider_1_post_poll_activity)
|
||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_poll_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_poll_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_poll_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_poll_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_poll_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_poll_activity)
|
||||||
@@ -173,6 +172,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private Account selectedAccount;
|
private Account selectedAccount;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
@@ -232,6 +232,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
@@ -257,7 +258,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -268,17 +268,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -292,11 +281,25 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -325,40 +328,12 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -431,8 +406,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@@ -481,8 +454,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
option1TextInputEditText.setTypeface(typeface);
|
option1TextInputEditText.setTypeface(typeface);
|
||||||
@@ -631,7 +602,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_POLL);
|
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_POLL);
|
||||||
PollPayload payload = new PollPayload(subredditName, titleEditText.getText().toString(),
|
PollPayload payload = new PollPayload(subredditName, titleEditText.getText().toString(),
|
||||||
optionList.toArray(new String[0]), (int) votingLengthSlider.getValue(), isNSFW, isSpoiler, flair, receivePostReplyNotificationsSwitchMaterial.isChecked(),
|
optionList.toArray(new String[0]), (int) votingLengthSlider.getValue(), isNSFW, isSpoiler, flair, receivePostReplyNotificationsSwitchMaterial.isChecked(),
|
||||||
@@ -669,6 +640,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
@@ -685,19 +657,16 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,10 +675,6 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import android.os.Handler;
|
|||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -69,6 +68,9 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
|||||||
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
@@ -78,7 +80,6 @@ import retrofit2.Retrofit;
|
|||||||
|
|
||||||
public class PostTextActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
public class PostTextActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_CONTENT = "EC";
|
static final String EXTRA_CONTENT = "EC";
|
||||||
|
|
||||||
@@ -98,6 +99,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_text_activity)
|
@BindView(R.id.coordinator_layout_post_text_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -119,10 +121,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_text_activity)
|
@BindView(R.id.divider_1_post_text_activity)
|
||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_text_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_text_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_text_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
||||||
@@ -164,6 +162,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean loadSubredditIconSuccessful = true;
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
@@ -219,6 +218,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
@@ -245,7 +245,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -256,17 +255,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -280,11 +268,25 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -318,44 +320,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
flairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
if (subredditIsUser) {
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
|
||||||
} else {
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
}
|
|
||||||
flairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
flairSelectionBottomSheetFragment.show(getSupportFragmentManager(), flairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -448,8 +418,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@@ -459,8 +427,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
@@ -484,7 +450,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadSubredditIcon() {
|
private void loadSubredditIcon() {
|
||||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
|
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
|
||||||
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||||
iconUrl = iconImageUrl;
|
iconUrl = iconImageUrl;
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
@@ -562,18 +528,12 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
|
|
||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
|
|
||||||
String subredditName;
|
|
||||||
if (subredditIsUser) {
|
|
||||||
subredditName = "u_" + subredditNameTextView.getText().toString();
|
|
||||||
} else {
|
|
||||||
subredditName = subredditNameTextView.getText().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
@@ -599,6 +559,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
@@ -617,19 +578,16 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
|
|
||||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
@@ -658,10 +616,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -719,8 +673,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
"",
|
||||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
@@ -92,6 +95,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
private static final int PICK_VIDEO_REQUEST_CODE = 1;
|
private static final int PICK_VIDEO_REQUEST_CODE = 1;
|
||||||
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
|
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_video_activity)
|
@BindView(R.id.coordinator_layout_post_video_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -113,10 +117,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
MaterialButton rulesButton;
|
MaterialButton rulesButton;
|
||||||
@BindView(R.id.divider_1_post_video_activity)
|
@BindView(R.id.divider_1_post_video_activity)
|
||||||
MaterialDivider divider1;
|
MaterialDivider divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_post_video_activity)
|
|
||||||
CustomTextView flairTextView;
|
|
||||||
@BindView(R.id.spoiler_custom_text_view_post_video_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
|
@BindView(R.id.nsfw_custom_text_view_post_video_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
|
||||||
@@ -168,6 +168,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private Uri videoUri;
|
private Uri videoUri;
|
||||||
@@ -235,6 +236,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
@@ -266,7 +268,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (subredditName != null) {
|
if (subredditName != null) {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
if (!loadSubredditIconSuccessful) {
|
if (!loadSubredditIconSuccessful) {
|
||||||
loadSubredditIcon();
|
loadSubredditIcon();
|
||||||
}
|
}
|
||||||
@@ -277,17 +278,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@@ -301,11 +291,25 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if (getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
loadSubredditIconSuccessful = false;
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
|
||||||
subredditSelected = true;
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), subredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
@Override
|
||||||
subredditNameTextView.setText(subredditName);
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
{
|
||||||
loadSubredditIcon();
|
communityData = new SubscribedSubredditData(subredditData);
|
||||||
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
subredditSelected = true;
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
subredditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@@ -341,40 +345,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (subredditIsUser) {
|
if (subredditIsUser) {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(RulesActivity.EXTRA_SUBREDDIT_NAME, communityData.getQualified_name());
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
flairTextView.setOnClickListener(view -> {
|
|
||||||
if (flair == null) {
|
|
||||||
mFlairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(FlairBottomSheetFragment.EXTRA_SUBREDDIT_NAME, subredditName);
|
|
||||||
mFlairSelectionBottomSheetFragment.setArguments(bundle);
|
|
||||||
mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag());
|
|
||||||
} else {
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@@ -468,20 +444,17 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
|
||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
applyFABTheme(captureFab);
|
boolean circularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||||
applyFABTheme(selectFromLibraryFab);
|
applyFABTheme(captureFab, circularFab);
|
||||||
|
applyFABTheme(selectFromLibraryFab, circularFab);
|
||||||
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
selectAgainTextView.setTypeface(typeface);
|
selectAgainTextView.setTypeface(typeface);
|
||||||
@@ -589,7 +562,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.setData(videoUri);
|
intent.setData(videoUri);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
@@ -637,6 +610,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
@@ -657,19 +631,16 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
displaySubredditIcon();
|
displaySubredditIcon();
|
||||||
|
|
||||||
flairTextView.setVisibility(View.VISIBLE);
|
|
||||||
flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
|
||||||
flairTextView.setText(getString(R.string.flair));
|
|
||||||
flair = null;
|
flair = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,10 +678,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
this.flair = flair;
|
this.flair = flair;
|
||||||
flairTextView.setText(flair.getText());
|
|
||||||
flairTextView.setBackgroundColor(flairBackgroundColor);
|
|
||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
|
||||||
flairTextView.setTextColor(flairTextColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
@@ -31,7 +30,6 @@ import javax.inject.Named;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.toldi.infinityforlemmy.FetchRules;
|
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
@@ -41,6 +39,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.widget.SliderPanel;
|
import eu.toldi.infinityforlemmy.customviews.slidr.widget.SliderPanel;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@@ -134,26 +134,27 @@ public class RulesActivity extends BaseActivity {
|
|||||||
|
|
||||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
FetchRules.fetchRules(mExecutor, new Handler(), mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mAccessToken, mSubredditName, new FetchRules.FetchRulesListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void success(ArrayList<Rule> rules) {
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
if (rules == null || rules.size() == 0) {
|
String description = subredditData.getDescription();
|
||||||
|
if (description == null || description.isEmpty()) {
|
||||||
errorTextView.setVisibility(View.VISIBLE);
|
errorTextView.setVisibility(View.VISIBLE);
|
||||||
errorTextView.setText(R.string.no_rule);
|
errorTextView.setText(R.string.no_rule);
|
||||||
errorTextView.setOnClickListener(view -> {
|
errorTextView.setOnClickListener(view -> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ArrayList<Rule> rules = new ArrayList<>();
|
||||||
|
rules.add(new Rule("Rules", description));
|
||||||
mAdapter.changeDataset(rules);
|
mAdapter.changeDataset(rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
displayError();
|
displayError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -184,21 +185,24 @@ public class RulesActivity extends BaseActivity {
|
|||||||
errorTextView.setOnClickListener(view -> {
|
errorTextView.setOnClickListener(view -> {
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
errorTextView.setVisibility(View.GONE);
|
errorTextView.setVisibility(View.GONE);
|
||||||
FetchRules.fetchRules(mExecutor, new Handler(), mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mAccessToken, mSubredditName, new FetchRules.FetchRulesListener() {
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(ArrayList<Rule> rules) {
|
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
if (rules == null || rules.size() == 0) {
|
String description = subredditData.getDescription();
|
||||||
|
if (description == null || description.isEmpty()) {
|
||||||
errorTextView.setVisibility(View.VISIBLE);
|
errorTextView.setVisibility(View.VISIBLE);
|
||||||
errorTextView.setText(R.string.no_rule);
|
errorTextView.setText(R.string.no_rule);
|
||||||
errorTextView.setOnClickListener(view -> {
|
errorTextView.setOnClickListener(view -> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
ArrayList<Rule> rules = new ArrayList<>();
|
||||||
|
rules.add(new Rule("Rules", description));
|
||||||
mAdapter.changeDataset(rules);
|
mAdapter.changeDataset(rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void onFetchSubredditDataFail(boolean isQuarantined) {
|
||||||
displayError();
|
displayError();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
|
|||||||
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQueryViewModel;
|
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQueryViewModel;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
@@ -128,6 +129,8 @@ public class SearchActivity extends BaseActivity {
|
|||||||
private String query;
|
private String query;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
|
|
||||||
private String communityQualifiedName;
|
private String communityQualifiedName;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean searchOnlySubreddits;
|
private boolean searchOnlySubreddits;
|
||||||
@@ -183,7 +186,7 @@ public class SearchActivity extends BaseActivity {
|
|||||||
subredditNameList.add(subredditData.getName());
|
subredditNameList.add(subredditData.getName());
|
||||||
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
|
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
|
||||||
} else {
|
} else {
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, subredditData.getName());
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
|
||||||
}
|
}
|
||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
@@ -429,8 +432,9 @@ public class SearchActivity extends BaseActivity {
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
if (resultCode == RESULT_OK && data != null) {
|
if (resultCode == RESULT_OK && data != null) {
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
subredditName = communityData.getName();
|
||||||
|
subredditIsUser = false;
|
||||||
|
|
||||||
if (subredditName == null) {
|
if (subredditName == null) {
|
||||||
subredditNameTextView.setText(R.string.all_communities);
|
subredditNameTextView.setText(R.string.all_communities);
|
||||||
@@ -442,9 +446,9 @@ public class SearchActivity extends BaseActivity {
|
|||||||
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
|
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
|
||||||
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getStringArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES));
|
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getStringArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES));
|
||||||
} else {
|
} else {
|
||||||
String name = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
SubscribedSubredditData communityData = data.getParcelableExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||||
String iconUrl = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
String iconUrl = data.getStringExtra(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, communityData);
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||||
}
|
}
|
||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindView(Bundle savedInstanceState) {
|
private void bindView(Bundle savedInstanceState) {
|
||||||
@@ -558,10 +558,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
goToUser();
|
goToUser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
|
||||||
random();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.hideReadPosts();
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
@@ -788,7 +784,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY, mQuery);
|
||||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, false);
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, false);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
return mFragment;
|
return mFragment;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.SubredditListingFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class SearchSubredditsResultActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
@@ -117,7 +119,8 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
|||||||
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY, query);
|
||||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, true);
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_GETTING_SUBREDDIT_INFO, true);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountQualifiedName);
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
|
bundle.putString(SubredditListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountQualifiedName);
|
||||||
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_MULTI_SELECTION, getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false));
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
} else {
|
} else {
|
||||||
@@ -144,10 +147,10 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
|
|||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSelectedSubreddit(String name, String iconUrl) {
|
public void getSelectedSubreddit(SubredditData subredditData) {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, subredditData.getIconUrl());
|
||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package eu.toldi.infinityforlemmy.activities;
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -10,12 +15,20 @@ import android.widget.EditText;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@@ -23,13 +36,24 @@ import butterknife.BindView;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||||
|
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.message.ComposeMessage;
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||||
|
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
public class SendPrivateMessageActivity extends BaseActivity {
|
public class SendPrivateMessageActivity extends BaseActivity implements UploadImageEnabledActivity {
|
||||||
public static final String EXTRA_RECIPIENT_USERNAME = "ERU";
|
public static final String EXTRA_RECIPIENT_USER_INFO = "ERUI";
|
||||||
|
|
||||||
|
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||||
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||||
@BindView(R.id.coordinator_layout_send_private_message_activity)
|
@BindView(R.id.coordinator_layout_send_private_message_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@BindView(R.id.appbar_layout_send_private_message_activity)
|
@BindView(R.id.appbar_layout_send_private_message_activity)
|
||||||
@@ -40,15 +64,20 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
EditText usernameEditText;
|
EditText usernameEditText;
|
||||||
@BindView(R.id.divider_1_send_private_message_activity)
|
@BindView(R.id.divider_1_send_private_message_activity)
|
||||||
View divider1;
|
View divider1;
|
||||||
@BindView(R.id.subjet_edit_text_send_private_message_activity)
|
|
||||||
EditText subjectEditText;
|
|
||||||
@BindView(R.id.divider_2_send_private_message_activity)
|
@BindView(R.id.divider_2_send_private_message_activity)
|
||||||
View divider2;
|
View divider2;
|
||||||
@BindView(R.id.content_edit_text_send_private_message_activity)
|
@BindView(R.id.content_edit_text_send_private_message_activity)
|
||||||
EditText messageEditText;
|
EditText messageEditText;
|
||||||
|
|
||||||
|
@BindView(R.id.markdown_bottom_bar_recycler_view_send_private_message_activity)
|
||||||
|
RecyclerView markdownBottomBarRecyclerView;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("no_oauth")
|
||||||
Retrofit mOauthRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Executor mExecutor;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@@ -57,9 +86,18 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LemmyPrivateMessageAPI mLemmyPrivateMessageAPI;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
|
|
||||||
|
private BasicUserInfo mRecipientBasicUserInfo;
|
||||||
private boolean isSubmitting = false;
|
private boolean isSubmitting = false;
|
||||||
|
|
||||||
|
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||||
|
|
||||||
|
private Uri capturedImageUri;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
@@ -77,14 +115,66 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
addOnOffsetChangedListener(appBarLayout);
|
addOnOffsetChangedListener(appBarLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||||
|
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(int item) {
|
||||||
|
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||||
|
SendPrivateMessageActivity.this, messageEditText, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUploadImage() {
|
||||||
|
Utils.hideKeyboard(SendPrivateMessageActivity.this);
|
||||||
|
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||||
|
Bundle arguments = new Bundle();
|
||||||
|
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||||
|
uploadedImages);
|
||||||
|
fragment.setArguments(arguments);
|
||||||
|
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||||
|
LinearLayoutManagerBugFixed.HORIZONTAL, false));
|
||||||
|
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
if (savedInstanceState != null) {
|
||||||
String username = getIntent().getStringExtra(EXTRA_RECIPIENT_USERNAME);
|
mRecipientBasicUserInfo = savedInstanceState.getParcelable(EXTRA_RECIPIENT_USER_INFO);
|
||||||
if (username != null) {
|
} else {
|
||||||
usernameEditText.setText(username);
|
mRecipientBasicUserInfo = getIntent().getParcelableExtra(EXTRA_RECIPIENT_USER_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mRecipientBasicUserInfo != null) {
|
||||||
|
usernameEditText.setText(mRecipientBasicUserInfo.getQualifiedName());
|
||||||
|
usernameEditText.setEnabled(false);
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
|
if (data == null) {
|
||||||
|
Toast.makeText(SendPrivateMessageActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, messageEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||||
|
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||||
|
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||||
|
mAccessToken, messageEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -108,12 +198,6 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subjectEditText.getText() == null || subjectEditText.getText().toString().equals("")) {
|
|
||||||
isSubmitting = false;
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.message_subject_required, Snackbar.LENGTH_LONG).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messageEditText.getText() == null || messageEditText.getText().toString().equals("")) {
|
if (messageEditText.getText() == null || messageEditText.getText().toString().equals("")) {
|
||||||
isSubmitting = false;
|
isSubmitting = false;
|
||||||
Snackbar.make(coordinatorLayout, R.string.message_content_required, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(coordinatorLayout, R.string.message_content_required, Snackbar.LENGTH_LONG).show();
|
||||||
@@ -125,32 +209,26 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
Snackbar sendingSnackbar = Snackbar.make(coordinatorLayout, R.string.sending_message, Snackbar.LENGTH_INDEFINITE);
|
Snackbar sendingSnackbar = Snackbar.make(coordinatorLayout, R.string.sending_message, Snackbar.LENGTH_INDEFINITE);
|
||||||
sendingSnackbar.show();
|
sendingSnackbar.show();
|
||||||
|
|
||||||
ComposeMessage.composeMessage(mOauthRetrofit, mAccessToken, getResources().getConfiguration().locale,
|
mLemmyPrivateMessageAPI.sendPrivateMessage(mAccessToken, mRecipientBasicUserInfo.getId(), messageEditText.getText().toString(), new LemmyPrivateMessageAPI.PrivateMessageSentListener() {
|
||||||
usernameEditText.getText().toString(), subjectEditText.getText().toString(),
|
@Override
|
||||||
messageEditText.getText().toString(), new ComposeMessage.ComposeMessageListener() {
|
public void onPrivateMessageSentSuccess(@NonNull PrivateMessage privateMessage) {
|
||||||
@Override
|
isSubmitting = false;
|
||||||
public void composeMessageSuccess() {
|
item.setEnabled(true);
|
||||||
isSubmitting = false;
|
item.getIcon().setAlpha(255);
|
||||||
item.setEnabled(true);
|
Toast.makeText(SendPrivateMessageActivity.this, R.string.send_message_success, Toast.LENGTH_SHORT).show();
|
||||||
item.getIcon().setAlpha(255);
|
finish();
|
||||||
Toast.makeText(SendPrivateMessageActivity.this, R.string.send_message_success, Toast.LENGTH_SHORT).show();
|
}
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void composeMessageFailed(String errorMessage) {
|
public void onPrivateMessageSentError() {
|
||||||
isSubmitting = false;
|
isSubmitting = false;
|
||||||
sendingSnackbar.dismiss();
|
sendingSnackbar.dismiss();
|
||||||
item.setEnabled(true);
|
item.setEnabled(true);
|
||||||
item.getIcon().setAlpha(255);
|
item.getIcon().setAlpha(255);
|
||||||
|
|
||||||
if (errorMessage == null || errorMessage.equals("")) {
|
Snackbar.make(coordinatorLayout, R.string.send_message_failed, Snackbar.LENGTH_LONG).show();
|
||||||
Snackbar.make(coordinatorLayout, R.string.send_message_failed, Snackbar.LENGTH_LONG).show();
|
}
|
||||||
} else {
|
});
|
||||||
Snackbar.make(coordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -159,6 +237,7 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelable(EXTRA_RECIPIENT_USER_INFO, mRecipientBasicUserInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,19 +256,49 @@ public class SendPrivateMessageActivity extends BaseActivity {
|
|||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
usernameEditText.setTextColor(primaryTextColor);
|
usernameEditText.setTextColor(primaryTextColor);
|
||||||
subjectEditText.setTextColor(primaryTextColor);
|
|
||||||
messageEditText.setTextColor(primaryTextColor);
|
messageEditText.setTextColor(primaryTextColor);
|
||||||
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
|
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
|
||||||
usernameEditText.setHintTextColor(secondaryTextColor);
|
usernameEditText.setHintTextColor(secondaryTextColor);
|
||||||
subjectEditText.setHintTextColor(secondaryTextColor);
|
|
||||||
messageEditText.setHintTextColor(secondaryTextColor);
|
messageEditText.setHintTextColor(secondaryTextColor);
|
||||||
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
int dividerColor = mCustomThemeWrapper.getDividerColor();
|
||||||
divider1.setBackgroundColor(dividerColor);
|
divider1.setBackgroundColor(dividerColor);
|
||||||
divider2.setBackgroundColor(dividerColor);
|
divider2.setBackgroundColor(dividerColor);
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
usernameEditText.setTypeface(typeface);
|
usernameEditText.setTypeface(typeface);
|
||||||
subjectEditText.setTypeface(typeface);
|
|
||||||
messageEditText.setTypeface(typeface);
|
messageEditText.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImage() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setType("image/*");
|
||||||
|
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||||
|
startActivityForResult(Intent.createChooser(intent,
|
||||||
|
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void captureImage() {
|
||||||
|
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
try {
|
||||||
|
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||||
|
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||||
|
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||||
|
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||||
|
int start = Math.max(messageEditText.getSelectionStart(), 0);
|
||||||
|
int end = Math.max(messageEditText.getSelectionEnd(), 0);
|
||||||
|
messageEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||||
|
"",
|
||||||
|
0, "![]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -64,6 +64,7 @@ import eu.toldi.infinityforlemmy.events.SubmitCrosspostEvent;
|
|||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||||
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@@ -87,6 +88,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
private static final String IS_NSFW_STATE = "INS";
|
private static final String IS_NSFW_STATE = "INS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_submit_crosspost_activity)
|
@BindView(R.id.coordinator_layout_submit_crosspost_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -159,6 +161,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
private Post post;
|
private Post post;
|
||||||
private String iconUrl;
|
private String iconUrl;
|
||||||
private String subredditName;
|
private String subredditName;
|
||||||
|
private SubscribedSubredditData communityData;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private boolean loadSubredditIconSuccessful = true;
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
@@ -212,6 +215,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
|
communityData = savedInstanceState.getParcelable(COMMUNITY_DATA_STATE);
|
||||||
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
selectedAccount = savedInstanceState.getParcelable(SELECTED_ACCOUNT_STATE);
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
@@ -566,12 +570,12 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
if (post.isCrosspost()) {
|
if (post.isCrosspost()) {
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, "t3_" + post.getCrosspostParentId());
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, post.getFullName());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, post.getFullName());
|
||||||
}
|
}
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
@@ -604,6 +608,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
outState.putParcelable(SELECTED_ACCOUNT_STATE, selectedAccount);
|
||||||
|
outState.putParcelable(COMMUNITY_DATA_STATE, communityData);
|
||||||
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
outState.putString(SUBREDDIT_NAME_STATE, subredditName);
|
||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
@@ -620,10 +625,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
subredditName = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||||
iconUrl = data.getExtras().getString(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
subredditName = communityData.getName();
|
||||||
|
iconUrl = communityData.getIconUrl();
|
||||||
subredditSelected = true;
|
subredditSelected = true;
|
||||||
subredditIsUser = data.getExtras().getBoolean(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER);
|
subredditIsUser = false;
|
||||||
|
|
||||||
subredditNameTextView.setTextColor(primaryTextColor);
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import org.greenrobot.eventbus.Subscribe;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@@ -33,7 +32,6 @@ import javax.inject.Named;
|
|||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||||
import eu.toldi.infinityforlemmy.AnyAccountAccessTokenAuthenticator;
|
|
||||||
import eu.toldi.infinityforlemmy.FetchSubscribedThing;
|
import eu.toldi.infinityforlemmy.FetchSubscribedThing;
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
@@ -49,17 +47,12 @@ import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
|||||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.subscribeduser.SubscribedUserData;
|
import eu.toldi.infinityforlemmy.subscribeduser.SubscribedUserData;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import okhttp3.ConnectionPool;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import retrofit2.Retrofit;
|
|
||||||
|
|
||||||
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class SubredditSelectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
public static final String EXTRA_SPECIFIED_ACCOUNT = "ESA";
|
public static final String EXTRA_SPECIFIED_ACCOUNT = "ESA";
|
||||||
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS";
|
||||||
public static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
public static final String EXTRA_RETURN_COMMUNITY_DATA = "ERCD";
|
||||||
public static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
|
||||||
public static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU";
|
|
||||||
|
|
||||||
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 0;
|
||||||
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
private static final String INSERT_SUBSCRIBED_SUBREDDIT_STATE = "ISSS";
|
||||||
@@ -77,9 +70,6 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
|||||||
@Named("no_oauth")
|
@Named("no_oauth")
|
||||||
RetrofitHolder mRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
|
||||||
Retrofit mOauthRetrofit;
|
|
||||||
@Inject
|
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
@@ -142,21 +132,14 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
|||||||
mAccountName = specifiedAccount.getAccountName();
|
mAccountName = specifiedAccount.getAccountName();
|
||||||
mAccountProfileImageUrl = specifiedAccount.getProfileImageUrl();
|
mAccountProfileImageUrl = specifiedAccount.getProfileImageUrl();
|
||||||
|
|
||||||
mOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, specifiedAccount, mCurrentAccountSharedPreferences))
|
|
||||||
.connectTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(30, TimeUnit.SECONDS)
|
|
||||||
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
|
||||||
.build())
|
|
||||||
.build();
|
|
||||||
} else {
|
} else {
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,6 +181,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
|||||||
mFragment = new SubscribedSubredditsListingFragment();
|
mFragment = new SubscribedSubredditsListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
|
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_QUALIFIED_NAME, mAccountName);
|
||||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl);
|
bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl);
|
||||||
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
|
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
|
||||||
@@ -262,11 +246,9 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSelectedSubreddit(String name, String iconUrl, boolean subredditIsUser) {
|
public void getSelectedSubreddit(SubscribedSubredditData communityData) {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
returnIntent.putExtra(EXTRA_RETURN_COMMUNITY_DATA, communityData);
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_IS_USER, subredditIsUser);
|
|
||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -275,13 +257,13 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
|
|||||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
|
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
String name = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
|
||||||
String iconUrl = data.getStringExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
SubscribedSubredditData communityData = data.getParcelableExtra(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||||
|
String iconUrl = communityData.getIconUrl();
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
returnIntent.putExtra(EXTRA_RETURN_COMMUNITY_DATA, communityData);
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
|
||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
|||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
@@ -221,7 +220,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
||||||
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor());
|
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor());
|
||||||
}
|
}
|
||||||
@@ -233,7 +232,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
});
|
});
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(sectionsPagerAdapter);
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(3);
|
viewPager.setOffscreenPageLimit(1);
|
||||||
if (viewPager.getCurrentItem() != 2) {
|
if (viewPager.getCurrentItem() != 2) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
}
|
}
|
||||||
@@ -358,7 +357,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(!forceLoad && mInsertMultiredditSuccess)) {
|
if (!(!forceLoad && mInsertMultiredditSuccess)) {
|
||||||
loadMultiReddits();
|
//loadMultiReddits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +411,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
public void success() {
|
public void success() {
|
||||||
Toast.makeText(SubscribedThingListingActivity.this,
|
Toast.makeText(SubscribedThingListingActivity.this,
|
||||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
||||||
loadMultiReddits();
|
//loadMultiReddits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -439,7 +438,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) {
|
public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) {
|
||||||
loadMultiReddits();
|
//loadMultiReddits();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -477,6 +476,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
default:
|
||||||
case 0: {
|
case 0: {
|
||||||
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
|
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
@@ -487,28 +487,12 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
case 1: {
|
|
||||||
FollowedUsersListingFragment fragment = new FollowedUsersListingFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
|
|
||||||
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 3;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
|||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
@@ -131,8 +132,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
@Inject
|
||||||
|
MarkPostAsRead markPostAsRead;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
|
private String mAccountQualifiedName;
|
||||||
private String multiPath;
|
private String multiPath;
|
||||||
private Fragment mFragment;
|
private Fragment mFragment;
|
||||||
private int fabOption;
|
private int fabOption;
|
||||||
@@ -221,6 +225,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
@@ -848,7 +853,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -868,7 +873,17 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadSuccess() {
|
||||||
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadFailed() {
|
||||||
|
Toast.makeText(ViewMultiRedditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -931,10 +946,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
|||||||
goToUser();
|
goToUser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
|
||||||
random();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
if (mFragment instanceof PostFragment) {
|
if (mFragment instanceof PostFragment) {
|
||||||
((PostFragment) mFragment).hideReadPosts();
|
((PostFragment) mFragment).hideReadPosts();
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
public static final String EXTRA_POST_ID = "EPI";
|
public static final String EXTRA_POST_ID = "EPI";
|
||||||
public static final String EXTRA_POST_LIST_POSITION = "EPLP";
|
public static final String EXTRA_POST_LIST_POSITION = "EPLP";
|
||||||
public static final String EXTRA_SINGLE_COMMENT_ID = "ESCI";
|
public static final String EXTRA_SINGLE_COMMENT_ID = "ESCI";
|
||||||
|
public static final String EXTRA_SINGLE_COMMENT_PARENT_ID = "ESCPI";
|
||||||
public static final String EXTRA_CONTEXT_NUMBER = "ECN";
|
public static final String EXTRA_CONTEXT_NUMBER = "ECN";
|
||||||
public static final String EXTRA_MESSAGE_FULLNAME = "ENI";
|
public static final String EXTRA_MESSAGE_FULLNAME = "ENI";
|
||||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||||
@@ -335,7 +336,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
||||||
applyFABTheme(fab);
|
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
searchPanelMaterialCardView.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimary()));
|
searchPanelMaterialCardView.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimary()));
|
||||||
int searchPanelTextAndIconColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
|
int searchPanelTextAndIconColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
|
||||||
searchTextInputLayout.setBoxStrokeColor(searchPanelTextAndIconColor);
|
searchTextInputLayout.setBoxStrokeColor(searchPanelTextAndIconColor);
|
||||||
@@ -425,11 +426,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void deleteComment(String fullName, int position) {
|
public void deleteComment(int comment_id, int position) {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
|
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
fragment.deleteComment(fullName, position);
|
fragment.deleteComment(comment_id, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -869,7 +870,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
if (postListPosition == position && post != null) {
|
if (postListPosition == position && post != null) {
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||||
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_PARENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_PARENT_ID, 0));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||||
} else {
|
} else {
|
||||||
@@ -885,12 +887,13 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post == null) {
|
if (post == null) {
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getStringExtra(EXTRA_POST_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getIntExtra(EXTRA_POST_ID, 0));
|
||||||
} else {
|
} else {
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
|
||||||
}
|
}
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||||
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_PARENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_PARENT_ID, 0));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -27,6 +28,7 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -46,14 +48,15 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
|||||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
||||||
import eu.toldi.infinityforlemmy.events.RepliedToPrivateMessageEvent;
|
import eu.toldi.infinityforlemmy.events.RepliedToPrivateMessageEvent;
|
||||||
import eu.toldi.infinityforlemmy.message.Message;
|
|
||||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
import eu.toldi.infinityforlemmy.message.ReplyMessage;
|
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
|
public static final String EXTRA_PRIVATE_MESSAGE = "EPM";
|
||||||
public static final String EXTRA_PRIVATE_MESSAGE_INDEX = "EPM";
|
public static final String EXTRA_PRIVATE_MESSAGE_INDEX = "EPM";
|
||||||
public static final String EXTRA_MESSAGE_POSITION = "EMP";
|
public static final String EXTRA_MESSAGE_POSITION = "EMP";
|
||||||
private static final String USER_AVATAR_STATE = "UAS";
|
private static final String USER_AVATAR_STATE = "UAS";
|
||||||
@@ -91,14 +94,19 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LemmyPrivateMessageAPI mLemmyPrivateMessageAPI;
|
||||||
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
private LinearLayoutManagerBugFixed mLinearLayoutManager;
|
||||||
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
private PrivateMessagesDetailRecyclerViewAdapter mAdapter;
|
||||||
@State
|
@State
|
||||||
Message privateMessage;
|
PrivateMessage privateMessage;
|
||||||
@State
|
@State
|
||||||
Message replyTo;
|
PrivateMessage replyTo;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
|
|
||||||
|
private String mAccountQualifiedName;
|
||||||
private String mUserAvatar;
|
private String mUserAvatar;
|
||||||
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
private ArrayList<ProvideUserAvatarCallback> mProvideUserAvatarCallbacks;
|
||||||
private boolean isLoadingUserAvatar = false;
|
private boolean isLoadingUserAvatar = false;
|
||||||
@@ -128,6 +136,11 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
addOnOffsetChangedListener(mAppBarLayout);
|
addOnOffsetChangedListener(mAppBarLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
privateMessage = intent.getParcelableExtra(EXTRA_PRIVATE_MESSAGE);
|
||||||
|
|
||||||
|
Log.i("ViewPrivate", "privateMessage: " + privateMessage);
|
||||||
|
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
setToolbarGoToTop(mToolbar);
|
setToolbarGoToTop(mToolbar);
|
||||||
|
|
||||||
@@ -135,6 +148,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
|
mUserAvatar = savedInstanceState.getString(USER_AVATAR_STATE);
|
||||||
@@ -144,36 +158,37 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (privateMessage != null) {
|
||||||
|
bindView();
|
||||||
|
}
|
||||||
EventBus.getDefault().post(new PassPrivateMessageIndexEvent(getIntent().getIntExtra(EXTRA_PRIVATE_MESSAGE_INDEX, -1)));
|
EventBus.getDefault().post(new PassPrivateMessageIndexEvent(getIntent().getIntExtra(EXTRA_PRIVATE_MESSAGE_INDEX, -1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindView() {
|
private void bindView() {
|
||||||
if (privateMessage != null) {
|
if (privateMessage != null) {
|
||||||
if (privateMessage.getAuthor().equals(mAccountName)) {
|
if (privateMessage.getCreatorQualifiedName().equals(mAccountQualifiedName)) {
|
||||||
setTitle(privateMessage.getDestination());
|
setTitle(privateMessage.getRecipientName());
|
||||||
mToolbar.setOnClickListener(view -> {
|
mToolbar.setOnClickListener(view -> {
|
||||||
if (privateMessage.isDestinationDeleted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getRecipientName());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, privateMessage.getRecipientQualifiedName());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setTitle(privateMessage.getAuthor());
|
setTitle(privateMessage.getCreatorName());
|
||||||
mToolbar.setOnClickListener(view -> {
|
mToolbar.setOnClickListener(view -> {
|
||||||
if (privateMessage.isAuthorDeleted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getCreatorName());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, privateMessage.getCreatorQualifiedName());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
||||||
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
getResources().getConfiguration().locale, privateMessage, mAccountQualifiedName, mCustomThemeWrapper);
|
||||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(this);
|
mLinearLayoutManager = new LinearLayoutManagerBugFixed(this);
|
||||||
mLinearLayoutManager.setStackFromEnd(true);
|
mLinearLayoutManager.setStackFromEnd(true);
|
||||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
@@ -184,58 +199,55 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
if (!mEditText.getText().toString().equals("")) {
|
if (!mEditText.getText().toString().equals("")) {
|
||||||
//Send Message
|
//Send Message
|
||||||
if (privateMessage != null) {
|
if (privateMessage != null) {
|
||||||
ArrayList<Message> replies = privateMessage.getReplies();
|
List<PrivateMessage> replies = privateMessage.getReplies();
|
||||||
if (replyTo == null) {
|
if (replyTo == null) {
|
||||||
replyTo = privateMessage;
|
replyTo = privateMessage;
|
||||||
}
|
}
|
||||||
isSendingMessage = true;
|
isSendingMessage = true;
|
||||||
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mSendImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
ReplyMessage.replyMessage(mEditText.getText().toString(), replyTo.getFullname(),
|
|
||||||
getResources().getConfiguration().locale, mOauthRetrofit, mAccessToken,
|
|
||||||
new ReplyMessage.ReplyMessageListener() {
|
|
||||||
@Override
|
|
||||||
public void replyMessageSuccess(Message message) {
|
|
||||||
if (mAdapter != null) {
|
|
||||||
mAdapter.addReply(message);
|
|
||||||
}
|
|
||||||
goToBottom();
|
|
||||||
mEditText.setText("");
|
|
||||||
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
|
||||||
isSendingMessage = false;
|
|
||||||
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(message, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
mLemmyPrivateMessageAPI.sendPrivateMessage(mAccessToken, replyTo.getCreatorId(), mEditText.getText().toString(), new LemmyPrivateMessageAPI.PrivateMessageSentListener() {
|
||||||
public void replyMessageFailed(String errorMessage) {
|
|
||||||
if (errorMessage != null && !errorMessage.equals("")) {
|
@Override
|
||||||
Snackbar.make(mCoordinatorLayout, errorMessage, Snackbar.LENGTH_LONG).show();
|
public void onPrivateMessageSentSuccess(@NonNull PrivateMessage privateMessage) {
|
||||||
} else {
|
if (mAdapter != null) {
|
||||||
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
mAdapter.addReply(privateMessage);
|
||||||
}
|
}
|
||||||
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
goToBottom();
|
||||||
isSendingMessage = false;
|
mEditText.setText("");
|
||||||
}
|
isSendingMessage = false;
|
||||||
});
|
EventBus.getDefault().post(new RepliedToPrivateMessageEvent(privateMessage, getIntent().getIntExtra(EXTRA_MESSAGE_POSITION, -1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrivateMessageSentError() {
|
||||||
|
Snackbar.make(mCoordinatorLayout, R.string.reply_message_failed, Snackbar.LENGTH_LONG).show();
|
||||||
|
mSendImageView.setColorFilter(mSendMessageIconColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
isSendingMessage = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
StringBuilder fullnames = new StringBuilder();
|
StringBuilder fullnames = new StringBuilder();
|
||||||
if (privateMessage.isNew()) {
|
|
||||||
fullnames.append(privateMessage.getFullname()).append(",");
|
|
||||||
}
|
|
||||||
if (replies != null && !replies.isEmpty()) {
|
if (replies != null && !replies.isEmpty()) {
|
||||||
for (Message m : replies) {
|
for (PrivateMessage m : replies) {
|
||||||
if (m.isNew()) {
|
if (!m.getRead()) {
|
||||||
fullnames.append(m).append(",");
|
fullnames.append(m).append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fullnames.length() > 0) {
|
if (fullnames.length() > 0) {
|
||||||
fullnames.deleteCharAt(fullnames.length() - 1);
|
fullnames.deleteCharAt(fullnames.length() - 1);
|
||||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
|
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, 0,
|
||||||
new ReadMessage.ReadMessageListener() {
|
new ReadMessage.ReadMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void readSuccess() {}
|
public void readSuccess() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFailed() {}
|
public void readFailed() {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,7 +344,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
|
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
|
||||||
privateMessage = passPrivateMessageEvent.message;
|
/* privateMessage = passPrivateMessageEvent.message;
|
||||||
if (privateMessage != null) {
|
if (privateMessage != null) {
|
||||||
if (privateMessage.getAuthor().equals(mAccountName)) {
|
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||||
if (privateMessage.getReplies() != null) {
|
if (privateMessage.getReplies() != null) {
|
||||||
@@ -351,7 +363,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
}
|
}
|
||||||
|
|
||||||
bindView();
|
bindView();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ProvideUserAvatarCallback {
|
public interface ProvideUserAvatarCallback {
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package eu.toldi.infinityforlemmy.activities;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -18,6 +20,7 @@ import android.view.ViewTreeObserver;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -36,6 +39,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
|||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
import com.evernote.android.state.State;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.appbar.MaterialToolbar;
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
@@ -82,6 +86,8 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.RandomBottomSheetFragment;
|
|||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTimeBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTimeBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTypeBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.SortTypeBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.community.BlockCommunity;
|
||||||
|
import eu.toldi.infinityforlemmy.community.CommunityStats;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
|
import eu.toldi.infinityforlemmy.customviews.NavigationWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||||
@@ -93,6 +99,7 @@ import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
|||||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
@@ -161,12 +168,23 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
TextView communityFullNameTextView;
|
TextView communityFullNameTextView;
|
||||||
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity)
|
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity)
|
||||||
TextView nSubscribersTextView;
|
TextView nSubscribersTextView;
|
||||||
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity)
|
@BindView(R.id.active_user_count_text_view_view_subreddit_detail_activity)
|
||||||
TextView nOnlineSubscribersTextView;
|
TextView nActiveUsersTextView;
|
||||||
@BindView(R.id.since_text_view_view_subreddit_detail_activity)
|
@BindView(R.id.post_count_text_view_view_subreddit_detail_activity)
|
||||||
TextView sinceTextView;
|
TextView nPostsTextView;
|
||||||
@BindView(R.id.creation_time_text_view_view_subreddit_detail_activity)
|
@BindView(R.id.comment_count_text_view_view_subreddit_detail_activity)
|
||||||
TextView creationTimeTextView;
|
TextView nCommentsTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.subscriber_count_image_view_view_subreddit_detail_activity)
|
||||||
|
ImageView nSubscribersImageView;
|
||||||
|
@BindView(R.id.active_user_count_image_view_view_subreddit_detail_activity)
|
||||||
|
ImageView nActiveUsersImageView;
|
||||||
|
@BindView(R.id.post_count_image_view_view_subreddit_detail_activity)
|
||||||
|
ImageView nPostsImageView;
|
||||||
|
@BindView(R.id.comment_count_image_view_view_subreddit_detail_activity)
|
||||||
|
ImageView nCommentsImageView;
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
|
@BindView(R.id.description_text_view_view_subreddit_detail_activity)
|
||||||
TextView descriptionTextView;
|
TextView descriptionTextView;
|
||||||
@Inject
|
@Inject
|
||||||
@@ -196,6 +214,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
@Inject
|
||||||
|
MarkPostAsRead markPostAsRead;
|
||||||
|
|
||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
private NavigationWrapper navigationWrapper;
|
private NavigationWrapper navigationWrapper;
|
||||||
@@ -206,6 +227,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
private String communityName;
|
private String communityName;
|
||||||
|
|
||||||
private int communityId;
|
private int communityId;
|
||||||
|
|
||||||
|
@State
|
||||||
|
SubredditData communityData;
|
||||||
|
@State
|
||||||
|
CommunityStats mCommunityStats;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private String qualifiedName;
|
private String qualifiedName;
|
||||||
@@ -217,7 +243,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
private boolean hideFab;
|
private boolean hideFab;
|
||||||
private boolean showBottomAppBar;
|
private boolean showBottomAppBar;
|
||||||
private boolean lockBottomAppBar;
|
private boolean lockBottomAppBar;
|
||||||
private String mMessageFullname;
|
private int mMessageFullname;
|
||||||
private String mNewAccountName;
|
private String mNewAccountName;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private int expandedTabTextColor;
|
private int expandedTabTextColor;
|
||||||
@@ -348,27 +374,41 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||||
} else {
|
} else {
|
||||||
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
||||||
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
|
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
|
||||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||||
|
|
||||||
if (mFetchSubredditInfoSuccess) {
|
|
||||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, mNCurrentOnlineSubscribers));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNewAccountAndBindView();
|
checkNewAccountAndBindView();
|
||||||
|
|
||||||
fetchSubredditData();
|
fetchSubredditData();
|
||||||
if (communityName != null) {
|
if (communityData != null) {
|
||||||
setupVisibleElements();
|
setupVisibleElements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
Log.e("ViewSubredditDetail", "onStart");
|
||||||
|
if (communityData != null) {
|
||||||
|
setupVisibleElements();
|
||||||
|
} else {
|
||||||
|
fetchSubredditData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mFetchSubredditInfoSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
@@ -410,20 +450,24 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
nSubscribersTextView.setTextColor(primaryTextColor);
|
nSubscribersTextView.setTextColor(primaryTextColor);
|
||||||
nOnlineSubscribersTextView.setTextColor(primaryTextColor);
|
nActiveUsersTextView.setTextColor(primaryTextColor);
|
||||||
sinceTextView.setTextColor(primaryTextColor);
|
nPostsTextView.setTextColor(primaryTextColor);
|
||||||
creationTimeTextView.setTextColor(primaryTextColor);
|
nCommentsTextView.setTextColor(primaryTextColor);
|
||||||
|
nSubscribersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
|
nActiveUsersImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
|
nPostsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
|
nCommentsImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
descriptionTextView.setTextColor(primaryTextColor);
|
descriptionTextView.setTextColor(primaryTextColor);
|
||||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
subredditNameTextView.setTypeface(typeface);
|
subredditNameTextView.setTypeface(typeface);
|
||||||
subscribeSubredditChip.setTypeface(typeface);
|
subscribeSubredditChip.setTypeface(typeface);
|
||||||
nSubscribersTextView.setTypeface(typeface);
|
nSubscribersTextView.setTypeface(typeface);
|
||||||
nOnlineSubscribersTextView.setTypeface(typeface);
|
nActiveUsersTextView.setTypeface(typeface);
|
||||||
sinceTextView.setTypeface(typeface);
|
nPostsTextView.setTypeface(typeface);
|
||||||
creationTimeTextView.setTypeface(typeface);
|
nCommentsTextView.setTypeface(typeface);
|
||||||
descriptionTextView.setTypeface(typeface);
|
descriptionTextView.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||||
@@ -547,15 +591,24 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
communityFullNameTextView.setText(qualifiedName);
|
communityFullNameTextView.setText(qualifiedName);
|
||||||
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
|
String nSubscribers = getString(R.string.subscribers_number_detail, subredditData.getNSubscribers());
|
||||||
nSubscribersTextView.setText(nSubscribers);
|
nSubscribersTextView.setText(nSubscribers);
|
||||||
creationTimeTextView.setText(subredditData.getCreatedUTC());
|
|
||||||
|
if (mCommunityStats != null) {
|
||||||
|
nActiveUsersTextView.setText(getString(R.string.active_users_number_detail, mCommunityStats.getActiveUsers()));
|
||||||
|
nPostsTextView.setText(getString(R.string.post_count_detail, mCommunityStats.getPosts()));
|
||||||
|
nCommentsTextView.setText(getString(R.string.comment_count_detail, mCommunityStats.getComments()));
|
||||||
|
} else {
|
||||||
|
nActiveUsersTextView.setVisibility(View.GONE);
|
||||||
|
nPostsTextView.setVisibility(View.GONE);
|
||||||
|
nCommentsTextView.setVisibility(View.GONE);
|
||||||
|
nActiveUsersImageView.setVisibility(View.GONE);
|
||||||
|
nPostsImageView.setVisibility(View.GONE);
|
||||||
|
nCommentsImageView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
description = subredditData.getDescription();
|
description = subredditData.getDescription();
|
||||||
|
|
||||||
if (hideSubredditDescription || description.equals("")) {
|
|
||||||
descriptionTextView.setVisibility(View.GONE);
|
descriptionTextView.setVisibility(View.GONE);
|
||||||
} else {
|
|
||||||
descriptionTextView.setVisibility(View.VISIBLE);
|
|
||||||
markwon.setMarkdown(descriptionTextView, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subredditData.isNSFW()) {
|
if (subredditData.isNSFW()) {
|
||||||
if (nsfwWarningBuilder == null
|
if (nsfwWarningBuilder == null
|
||||||
@@ -689,14 +742,15 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
qualifiedName = LemmyUtils.actorID2FullName(communityData.getActorId());
|
qualifiedName = LemmyUtils.actorID2FullName(communityData.getActorId());
|
||||||
if (communityName == null) {
|
if (communityName == null) {
|
||||||
communityName = communityData.getTitle();
|
communityName = communityData.getTitle();
|
||||||
|
|
||||||
setupVisibleElements();
|
|
||||||
}
|
}
|
||||||
|
mCommunityStats = communityData.getCommunityStats();
|
||||||
|
setupVisibleElements();
|
||||||
communityId = communityData.getId();
|
communityId = communityData.getId();
|
||||||
|
ViewSubredditDetailActivity.this.communityData = communityData;
|
||||||
setupSubscribeChip();
|
setupSubscribeChip();
|
||||||
|
|
||||||
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
|
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
|
||||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, nCurrentOnlineSubscribers));
|
|
||||||
InsertSubredditData.insertSubredditData(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
InsertSubredditData.insertSubredditData(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||||
communityData, () -> mFetchSubredditInfoSuccess = true);
|
communityData, () -> mFetchSubredditInfoSuccess = true);
|
||||||
}
|
}
|
||||||
@@ -729,6 +783,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mAccountQualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -868,11 +923,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindView() {
|
private void bindView() {
|
||||||
if (mMessageFullname != null) {
|
if (mMessageFullname != 0) {
|
||||||
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void readSuccess() {
|
public void readSuccess() {
|
||||||
mMessageFullname = null;
|
mMessageFullname = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1122,6 +1177,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
|
getMenuInflater().inflate(R.menu.view_subreddit_detail_activity, menu);
|
||||||
|
if (communityData != null && communityData.isBlocked()) {
|
||||||
|
menu.findItem(R.id.block_community_view_subreddit_detail_activity).setVisible(false);
|
||||||
|
} else {
|
||||||
|
menu.findItem(R.id.unblock_community_view_subreddit_detail_activity).setVisible(false);
|
||||||
|
}
|
||||||
applyMenuItemTheme(menu);
|
applyMenuItemTheme(menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1150,22 +1210,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
||||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_select_user_flair_view_subreddit_detail_activity) {
|
|
||||||
if (mAccessToken == null) {
|
|
||||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Intent selectUserFlairIntent = new Intent(this, SelectUserFlairActivity.class);
|
|
||||||
selectUserFlairIntent.putExtra(SelectUserFlairActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
|
||||||
startActivity(selectUserFlairIntent);
|
|
||||||
return true;
|
|
||||||
} else if (itemId == R.id.action_add_to_multireddit_view_subreddit_detail_activity) {
|
|
||||||
if (mAccessToken == null) {
|
|
||||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(this, MultiredditSelectionActivity.class);
|
|
||||||
startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE);
|
|
||||||
} else if (itemId == R.id.action_add_to_post_filter_view_subreddit_detail_activity) {
|
} else if (itemId == R.id.action_add_to_post_filter_view_subreddit_detail_activity) {
|
||||||
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
||||||
intent.putExtra(PostFilterPreferenceActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostFilterPreferenceActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
||||||
@@ -1174,23 +1218,60 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
} else if (itemId == R.id.action_share_view_subreddit_detail_activity) {
|
} else if (itemId == R.id.action_share_view_subreddit_detail_activity) {
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, mRetrofit.getBaseURL() + qualifiedName);
|
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "c/" + qualifiedName);
|
||||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_go_to_wiki_view_subreddit_detail_activity) {
|
|
||||||
Intent wikiIntent = new Intent(this, WikiActivity.class);
|
|
||||||
wikiIntent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
|
||||||
wikiIntent.putExtra(WikiActivity.EXTRA_WIKI_PATH, "index");
|
|
||||||
startActivity(wikiIntent);
|
|
||||||
return true;
|
|
||||||
} else if (itemId == R.id.action_contact_mods_view_subreddit_detail_activity) {
|
} else if (itemId == R.id.action_contact_mods_view_subreddit_detail_activity) {
|
||||||
Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
/* Intent intent = new Intent(this, SendPrivateMessageActivity.class);
|
||||||
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, "r/" + communityName);
|
intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, "r/" + communityName);*/
|
||||||
startActivity(intent);
|
//startActivity(intent);
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.block_community_view_subreddit_detail_activity) {
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.block_community)
|
||||||
|
.setMessage(R.string.are_you_sure)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
|
-> BlockCommunity.INSTANCE.blockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
|
||||||
|
@Override
|
||||||
|
public void onBlockCommunitySuccess() {
|
||||||
|
communityData.setBlocked(true);
|
||||||
|
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_success, Toast.LENGTH_SHORT).show();
|
||||||
|
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
|
||||||
|
sectionsPagerAdapter.refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockCommunityError() {
|
||||||
|
Toast.makeText(ViewSubredditDetailActivity.this, R.string.block_community_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
return true;
|
||||||
|
} else if (itemId == R.id.unblock_community_view_subreddit_detail_activity) {
|
||||||
|
BlockCommunity.INSTANCE.unBlockCommunity(mRetrofit.getRetrofit(), communityId, mAccessToken, new BlockCommunity.BlockCommunityListener() {
|
||||||
|
@Override
|
||||||
|
public void onBlockCommunitySuccess() {
|
||||||
|
communityData.setBlocked(false);
|
||||||
|
Toast.makeText(ViewSubredditDetailActivity.this, R.string.unblock_community_success, Toast.LENGTH_SHORT).show();
|
||||||
|
ViewSubredditDetailActivity.this.invalidateOptionsMenu();
|
||||||
|
sectionsPagerAdapter.refresh(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockCommunityError() {
|
||||||
|
Toast.makeText(ViewSubredditDetailActivity.this, R.string.unblock_community_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1229,7 +1310,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
||||||
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
|
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
|
||||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1278,32 +1359,32 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostTypeBottomSheetFragment.TYPE_TEXT:
|
case PostTypeBottomSheetFragment.TYPE_TEXT:
|
||||||
intent = new Intent(this, PostTextActivity.class);
|
intent = new Intent(this, PostTextActivity.class);
|
||||||
intent.putExtra(PostTextActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostTextActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case PostTypeBottomSheetFragment.TYPE_LINK:
|
case PostTypeBottomSheetFragment.TYPE_LINK:
|
||||||
intent = new Intent(this, PostLinkActivity.class);
|
intent = new Intent(this, PostLinkActivity.class);
|
||||||
intent.putExtra(PostLinkActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostLinkActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case PostTypeBottomSheetFragment.TYPE_IMAGE:
|
case PostTypeBottomSheetFragment.TYPE_IMAGE:
|
||||||
intent = new Intent(this, PostImageActivity.class);
|
intent = new Intent(this, PostImageActivity.class);
|
||||||
intent.putExtra(PostImageActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostImageActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case PostTypeBottomSheetFragment.TYPE_VIDEO:
|
case PostTypeBottomSheetFragment.TYPE_VIDEO:
|
||||||
intent = new Intent(this, PostVideoActivity.class);
|
intent = new Intent(this, PostVideoActivity.class);
|
||||||
intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case PostTypeBottomSheetFragment.TYPE_GALLERY:
|
case PostTypeBottomSheetFragment.TYPE_GALLERY:
|
||||||
intent = new Intent(this, PostGalleryActivity.class);
|
intent = new Intent(this, PostGalleryActivity.class);
|
||||||
intent.putExtra(PostGalleryActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostGalleryActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case PostTypeBottomSheetFragment.TYPE_POLL:
|
case PostTypeBottomSheetFragment.TYPE_POLL:
|
||||||
intent = new Intent(this, PostPollActivity.class);
|
intent = new Intent(this, PostPollActivity.class);
|
||||||
intent.putExtra(PostPollActivity.EXTRA_SUBREDDIT_NAME, communityName);
|
intent.putExtra(PostPollActivity.EXTRA_SUBREDDIT_NAME, qualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1397,10 +1478,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
goToUser();
|
goToUser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
|
||||||
random();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.hideReadPosts();
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
@@ -1561,7 +1638,18 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadSuccess() {
|
||||||
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadFailed() {
|
||||||
|
Toast.makeText(ViewSubredditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -20,7 +21,9 @@ import android.view.ViewTreeObserver;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -52,6 +55,7 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@@ -71,11 +75,14 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
|||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
import eu.toldi.infinityforlemmy.SortType;
|
import eu.toldi.infinityforlemmy.SortType;
|
||||||
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
||||||
|
import eu.toldi.infinityforlemmy.account.FetchBlockedThings;
|
||||||
import eu.toldi.infinityforlemmy.adapters.SubredditAutocompleteRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.SubredditAutocompleteRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.AddSubredditOrUserToMultiReddit;
|
import eu.toldi.infinityforlemmy.asynctasks.AddSubredditOrUserToMultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.CheckIsFollowingUser;
|
import eu.toldi.infinityforlemmy.asynctasks.CheckIsFollowingUser;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.CopyTextBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.CopyTextBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.FABMoreOptionsBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
||||||
@@ -95,16 +102,19 @@ import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
|||||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
|
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||||
import eu.toldi.infinityforlemmy.user.BlockUser;
|
import eu.toldi.infinityforlemmy.user.BlockUser;
|
||||||
import eu.toldi.infinityforlemmy.user.FetchUserData;
|
import eu.toldi.infinityforlemmy.user.FetchUserData;
|
||||||
import eu.toldi.infinityforlemmy.user.UserDao;
|
import eu.toldi.infinityforlemmy.user.UserDao;
|
||||||
import eu.toldi.infinityforlemmy.user.UserData;
|
import eu.toldi.infinityforlemmy.user.UserData;
|
||||||
import eu.toldi.infinityforlemmy.user.UserFollowing;
|
import eu.toldi.infinityforlemmy.user.UserFollowing;
|
||||||
|
import eu.toldi.infinityforlemmy.user.UserStats;
|
||||||
import eu.toldi.infinityforlemmy.user.UserViewModel;
|
import eu.toldi.infinityforlemmy.user.UserViewModel;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
@@ -140,6 +150,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
private static final String FETCH_USER_INFO_STATE = "FSIS";
|
private static final String FETCH_USER_INFO_STATE = "FSIS";
|
||||||
private static final String MESSAGE_FULLNAME_STATE = "MFS";
|
private static final String MESSAGE_FULLNAME_STATE = "MFS";
|
||||||
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
|
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
|
||||||
|
private static final String NEW_ACCOUNT_QUALIFIED_NAME_STATE = "NAQNS";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_view_user_detail_activity)
|
@BindView(R.id.coordinator_layout_view_user_detail_activity)
|
||||||
CoordinatorLayout coordinatorLayout;
|
CoordinatorLayout coordinatorLayout;
|
||||||
@@ -164,11 +175,32 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
@BindView(R.id.user_qualified_name_text_view_view_user_detail_activity)
|
@BindView(R.id.user_qualified_name_text_view_view_user_detail_activity)
|
||||||
TextView qualifiedNameTextView;
|
TextView qualifiedNameTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.loading_user_progress_indicator_view_user_detail_activity)
|
||||||
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.subscribe_user_chip_view_user_detail_activity)
|
@BindView(R.id.subscribe_user_chip_view_user_detail_activity)
|
||||||
Chip subscribeUserChip;
|
Chip subscribeUserChip;
|
||||||
@BindView(R.id.karma_text_view_view_user_detail_activity)
|
|
||||||
TextView karmaTextView;
|
@BindView(R.id.post_count_text_view_view_user_detail_activity)
|
||||||
@BindView(R.id.cakeday_text_view_view_user_detail_activity)
|
TextView postCountTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.comment_count_text_view_view_user_detail_activity)
|
||||||
|
TextView commentCountTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.upvote_count_post_text_view_view_user_detail_activity)
|
||||||
|
TextView upvoteCountPostTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.upvote_count_comment_text_view_view_user_detail_activity)
|
||||||
|
TextView upvoteCountCommentTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.posts_count_icon_image_view_view_user_detail_activity)
|
||||||
|
ImageView postsCountIconImageView;
|
||||||
|
@BindView(R.id.comments_count_icon_image_view_view_user_detail_activity)
|
||||||
|
ImageView commentsCountIconImageView;
|
||||||
|
@BindView(R.id.account_created_cake_icon_image_view_view_user_detail_activity)
|
||||||
|
ImageView accountCreatedCakeIconImageView;
|
||||||
|
|
||||||
|
@BindView(R.id.cake_day_text_view_view_user_detail_activity)
|
||||||
TextView cakedayTextView;
|
TextView cakedayTextView;
|
||||||
@BindView(R.id.description_text_view_view_user_detail_activity)
|
@BindView(R.id.description_text_view_view_user_detail_activity)
|
||||||
TextView descriptionTextView;
|
TextView descriptionTextView;
|
||||||
@@ -202,6 +234,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
MarkPostAsRead markPostAsRead;
|
||||||
public UserViewModel userViewModel;
|
public UserViewModel userViewModel;
|
||||||
private FragmentManager fragmentManager;
|
private FragmentManager fragmentManager;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
@@ -210,7 +245,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
private Call<String> subredditAutocompleteCall;
|
private Call<String> subredditAutocompleteCall;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
|
private String mAccountQualifiedName;
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String qualifiedName;
|
private String qualifiedName;
|
||||||
private String description;
|
private String description;
|
||||||
private boolean subscriptionReady = false;
|
private boolean subscriptionReady = false;
|
||||||
@@ -228,11 +265,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
private boolean hideFab;
|
private boolean hideFab;
|
||||||
private boolean showBottomAppBar;
|
private boolean showBottomAppBar;
|
||||||
private boolean lockBottomAppBar;
|
private boolean lockBottomAppBar;
|
||||||
private String mMessageFullname;
|
private int mMessageId;
|
||||||
private String mNewAccountName;
|
private String mNewAccountName;
|
||||||
|
|
||||||
private UserData mUserData;
|
private UserData mUserData;
|
||||||
|
|
||||||
|
private boolean isBlocked;
|
||||||
|
|
||||||
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -272,16 +311,18 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||||
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
mMessageId = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||||
} else {
|
} else {
|
||||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
mMessageId = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||||
|
qualifiedName = savedInstanceState.getString("qualified_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNewAccountAndInitializeViewPager();
|
checkNewAccountAndInitializeViewPager();
|
||||||
@@ -293,9 +334,26 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
if (mUserData != null) {
|
||||||
|
setupVisibleElements();
|
||||||
|
} else {
|
||||||
|
fetchUserInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mFetchUserInfoSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupVisibleElements() {
|
private void setupVisibleElements() {
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
String title = username;
|
String title = username;
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
userNameTextView.setText(title);
|
userNameTextView.setText(title);
|
||||||
qualifiedNameTextView.setText(qualifiedName);
|
qualifiedNameTextView.setText(qualifiedName);
|
||||||
toolbar.setTitle(title);
|
toolbar.setTitle(title);
|
||||||
@@ -553,8 +611,15 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
getSupportActionBar().setTitle(userFullName);
|
getSupportActionBar().setTitle(userFullName);
|
||||||
}
|
}
|
||||||
String karma = "";//getString(R.string.karma_info_user_detail, userData.getTotalKarma(), userData.getLinkKarma(), userData.getCommentKarma());
|
String karma = "";//getString(R.string.karma_info_user_detail, userData.getTotalKarma(), userData.getLinkKarma(), userData.getCommentKarma());
|
||||||
karmaTextView.setText(karma);
|
|
||||||
cakedayTextView.setText(getString(R.string.cakeday_info, userData.getCakeday()));
|
cakedayTextView.setText((String) userData.getCakeday());
|
||||||
|
UserStats userStats = mUserData.getStats();
|
||||||
|
if (userStats != null) {
|
||||||
|
postCountTextView.setText(String.valueOf(userStats.getPostCount()));
|
||||||
|
commentCountTextView.setText(String.valueOf(userStats.getCommentCount()));
|
||||||
|
upvoteCountPostTextView.setText(String.valueOf(userStats.getPostScore()));
|
||||||
|
upvoteCountCommentTextView.setText(String.valueOf(userStats.getCommentScore()));
|
||||||
|
}
|
||||||
|
|
||||||
if (userData.getDescription() == null || userData.getDescription().equals("")) {
|
if (userData.getDescription() == null || userData.getDescription().equals("")) {
|
||||||
descriptionTextView.setVisibility(View.GONE);
|
descriptionTextView.setVisibility(View.GONE);
|
||||||
@@ -622,16 +687,25 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||||
subscribedColor = mCustomThemeWrapper.getSubscribed();
|
subscribedColor = mCustomThemeWrapper.getSubscribed();
|
||||||
userNameTextView.setTextColor(mCustomThemeWrapper.getUsername());
|
userNameTextView.setTextColor(mCustomThemeWrapper.getUsername());
|
||||||
karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
postCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
upvoteCountPostTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
commentCountTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
upvoteCountCommentTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
|
postsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
|
commentsCountIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
|
accountCreatedCakeIconImageView.setColorFilter(mCustomThemeWrapper.getPrimaryTextColor(), PorterDuff.Mode.SRC_IN);
|
||||||
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||||
applyTabLayoutTheme(tabLayout);
|
applyTabLayoutTheme(tabLayout);
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
userNameTextView.setTypeface(typeface);
|
userNameTextView.setTypeface(typeface);
|
||||||
karmaTextView.setTypeface(typeface);
|
postCountTextView.setTypeface(typeface);
|
||||||
|
upvoteCountPostTextView.setTypeface(typeface);
|
||||||
|
commentCountTextView.setTypeface(typeface);
|
||||||
|
upvoteCountCommentTextView.setTypeface(typeface);
|
||||||
cakedayTextView.setTypeface(typeface);
|
cakedayTextView.setTypeface(typeface);
|
||||||
subscribeUserChip.setTypeface(typeface);
|
subscribeUserChip.setTypeface(typeface);
|
||||||
descriptionTextView.setTypeface(typeface);
|
descriptionTextView.setTypeface(typeface);
|
||||||
@@ -700,11 +774,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
fixViewPager2Sensitivity(viewPager2);
|
fixViewPager2Sensitivity(viewPager2);
|
||||||
|
|
||||||
if (mMessageFullname != null) {
|
if (mMessageId != 0) {
|
||||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageId, new ReadMessage.ReadMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void readSuccess() {
|
public void readSuccess() {
|
||||||
mMessageFullname = null;
|
mMessageId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -923,6 +997,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_PROFILE: {
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mAccountName);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY,mAccountQualifiedName);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1077,8 +1152,27 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
@Override
|
@Override
|
||||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||||
mUserData = userData;
|
mUserData = userData;
|
||||||
username = userData.getName();
|
username = userData.getDisplayName();
|
||||||
setupVisibleElements();
|
setupVisibleElements();
|
||||||
|
FetchBlockedThings.fetchBlockedThings(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, new FetchBlockedThings.FetchBlockedThingsListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchBlockedThingsSuccess(List<BlockedUserData> blockedUsers, List<BlockedCommunityData> blockedCommunities) {
|
||||||
|
for (BlockedUserData blockedUserData : blockedUsers) {
|
||||||
|
if (blockedUserData.getQualifiedName().equals(qualifiedName)) {
|
||||||
|
isBlocked = true;
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isBlocked = false;
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchBlockedThingsFailure() {
|
||||||
|
}
|
||||||
|
});
|
||||||
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
|
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
|
||||||
() -> mFetchUserInfoSuccess = true).execute();
|
() -> mFetchUserInfoSuccess = true).execute();
|
||||||
}
|
}
|
||||||
@@ -1092,12 +1186,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteComment(String fullName) {
|
public void deleteComment(int commentId) {
|
||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
.setTitle(R.string.delete_this_comment)
|
.setTitle(R.string.delete_this_comment)
|
||||||
.setMessage(R.string.are_you_sure)
|
.setMessage(R.string.are_you_sure)
|
||||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||||
-> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() {
|
-> DeleteThing.deleteComment(mRetrofit.getRetrofit(), commentId, mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void deleteSuccess() {
|
public void deleteSuccess() {
|
||||||
Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
|
||||||
@@ -1121,6 +1215,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
|
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
|
menu.findItem(R.id.action_edit_profile_view_user_detail_activity).setVisible(false);
|
||||||
|
if (isBlocked) {
|
||||||
|
menu.findItem(R.id.action_block_user_view_user_detail_activity).setVisible(false);
|
||||||
|
menu.findItem(R.id.action_unblock_user_view_user_detail_activity).setVisible(true);
|
||||||
|
} else {
|
||||||
|
menu.findItem(R.id.action_unblock_user_view_user_detail_activity).setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
applyMenuItemTheme(menu);
|
applyMenuItemTheme(menu);
|
||||||
return true;
|
return true;
|
||||||
@@ -1154,7 +1254,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
} else if (itemId == R.id.action_share_view_user_detail_activity) {
|
} else if (itemId == R.id.action_share_view_user_detail_activity) {
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, mRetrofit.getBaseURL() + qualifiedName);
|
String baseURL = mRetrofit.getBaseURL().endsWith("/") ? mRetrofit.getBaseURL() : mRetrofit.getBaseURL() + "/";
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_TEXT, baseURL + "u/" + qualifiedName);
|
||||||
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
if (shareIntent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)));
|
||||||
} else {
|
} else {
|
||||||
@@ -1168,16 +1269,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
Intent pmIntent = new Intent(this, SendPrivateMessageActivity.class);
|
||||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USER_INFO, new BasicUserInfo(mUserData.getId(), username, qualifiedName, mUserData.getAvatar(), mUserData.getDisplayName()));
|
||||||
startActivity(pmIntent);
|
startActivity(pmIntent);
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_add_to_multireddit_view_user_detail_activity) {
|
|
||||||
if (mAccessToken == null) {
|
|
||||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(this, MultiredditSelectionActivity.class);
|
|
||||||
startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE);
|
|
||||||
} else if (itemId == R.id.action_add_to_post_filter_view_user_detail_activity) {
|
} else if (itemId == R.id.action_add_to_post_filter_view_user_detail_activity) {
|
||||||
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
Intent intent = new Intent(this, PostFilterPreferenceActivity.class);
|
||||||
intent.putExtra(PostFilterPreferenceActivity.EXTRA_USER_NAME, username);
|
intent.putExtra(PostFilterPreferenceActivity.EXTRA_USER_NAME, username);
|
||||||
@@ -1198,10 +1292,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
.setTitle(R.string.block_user)
|
.setTitle(R.string.block_user)
|
||||||
.setMessage(R.string.are_you_sure)
|
.setMessage(R.string.are_you_sure)
|
||||||
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
||||||
-> BlockUser.blockUser(mOauthRetrofit, mAccessToken, username, new BlockUser.BlockUserListener() {
|
-> BlockUser.blockUser(mRetrofit.getRetrofit(), mAccessToken, mUserData.getId(), true, new BlockUser.BlockUserListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewUserDetailActivity.this, R.string.block_user_success, Toast.LENGTH_SHORT).show();
|
||||||
|
isBlocked = true;
|
||||||
|
sectionsPagerAdapter.refresh();
|
||||||
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1215,6 +1312,25 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
} else if (itemId == R.id.action_edit_profile_view_user_detail_activity) {
|
} else if (itemId == R.id.action_edit_profile_view_user_detail_activity) {
|
||||||
startActivity(new Intent(this, EditProfileActivity.class));
|
startActivity(new Intent(this, EditProfileActivity.class));
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.action_unblock_user_view_user_detail_activity) {
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
BlockUser.blockUser(mRetrofit.getRetrofit(), mAccessToken, mUserData.getId(), false, new BlockUser.BlockUserListener() {
|
||||||
|
@Override
|
||||||
|
public void success() {
|
||||||
|
isBlocked = false;
|
||||||
|
Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_success, Toast.LENGTH_SHORT).show();
|
||||||
|
sectionsPagerAdapter.refresh();
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
Toast.makeText(ViewUserDetailActivity.this, R.string.unblock_user_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1261,8 +1377,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageId);
|
||||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||||
|
outState.putString(NEW_ACCOUNT_QUALIFIED_NAME_STATE, mAccountQualifiedName);
|
||||||
|
outState.putString("qualified_name", qualifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1334,10 +1452,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
goToUser();
|
goToUser();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
|
||||||
random();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||||
if (sectionsPagerAdapter != null) {
|
if (sectionsPagerAdapter != null) {
|
||||||
sectionsPagerAdapter.hideReadPosts();
|
sectionsPagerAdapter.hideReadPosts();
|
||||||
@@ -1549,7 +1664,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markPostAsRead(Post post) {
|
public void markPostAsRead(Post post) {
|
||||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadSuccess() {
|
||||||
|
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMarkPostAsReadFailed() {
|
||||||
|
Toast.makeText(ViewUserDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,377 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.ViewSubredditDetailActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||||
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||||
|
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER = 0;
|
||||||
|
private static final int VIEW_TYPE_FAVORITE_SUBREDDIT = 1;
|
||||||
|
private static final int VIEW_TYPE_SUBREDDIT_DIVIDER = 2;
|
||||||
|
private static final int VIEW_TYPE_SUBREDDIT = 3;
|
||||||
|
|
||||||
|
private BaseActivity mActivity;
|
||||||
|
private Executor mExecutor;
|
||||||
|
private Retrofit mOauthRetrofit;
|
||||||
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private List<BlockedCommunityData> mBlockedCommunityData;
|
||||||
|
private List<BlockedCommunityData> mFavoriteBlockedCommunityData;
|
||||||
|
private RequestManager glide;
|
||||||
|
private ItemClickListener itemClickListener;
|
||||||
|
|
||||||
|
private String accessToken;
|
||||||
|
private String username;
|
||||||
|
private String userIconUrl;
|
||||||
|
private boolean hasClearSelectionRow;
|
||||||
|
|
||||||
|
private int primaryTextColor;
|
||||||
|
private int secondaryTextColor;
|
||||||
|
|
||||||
|
public BlockedCommunitiesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
CustomThemeWrapper customThemeWrapper,
|
||||||
|
String accessToken) {
|
||||||
|
mActivity = activity;
|
||||||
|
mExecutor = executor;
|
||||||
|
glide = Glide.with(activity);
|
||||||
|
mOauthRetrofit = oauthRetrofit;
|
||||||
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockedCommunitiesRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
CustomThemeWrapper customThemeWrapper,
|
||||||
|
String accessToken, boolean hasClearSelectionRow,
|
||||||
|
ItemClickListener itemClickListener) {
|
||||||
|
this(activity, executor, oauthRetrofit, redditDataRoomDatabase, customThemeWrapper, accessToken);
|
||||||
|
this.hasClearSelectionRow = hasClearSelectionRow;
|
||||||
|
this.itemClickListener = itemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) {
|
||||||
|
if (itemClickListener != null && !hasClearSelectionRow) {
|
||||||
|
if (position == 0) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
} else if (position == 1) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position == mFavoriteBlockedCommunityData.size() + 2) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position <= mFavoriteBlockedCommunityData.size() + 1) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
}
|
||||||
|
} else if (hasClearSelectionRow) {
|
||||||
|
if (position == 0) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
} else if (position == 1) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
} else if (position == 2) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position == mFavoriteBlockedCommunityData.size() + 3) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position <= mFavoriteBlockedCommunityData.size() + 2) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (position == 0) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position == mFavoriteBlockedCommunityData.size() + 1) {
|
||||||
|
return VIEW_TYPE_SUBREDDIT_DIVIDER;
|
||||||
|
} else if (position <= mFavoriteBlockedCommunityData.size()) {
|
||||||
|
return VIEW_TYPE_FAVORITE_SUBREDDIT;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_SUBREDDIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||||
|
switch (i) {
|
||||||
|
case VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER:
|
||||||
|
return new FavoriteSubredditsDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||||
|
case VIEW_TYPE_FAVORITE_SUBREDDIT:
|
||||||
|
return new FavoriteSubredditViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
|
||||||
|
case VIEW_TYPE_SUBREDDIT_DIVIDER:
|
||||||
|
return new AllSubredditsDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||||
|
default:
|
||||||
|
return new SubredditViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
|
if (viewHolder instanceof SubredditViewHolder) {
|
||||||
|
String name;
|
||||||
|
String fullname = "";
|
||||||
|
String iconUrl;
|
||||||
|
|
||||||
|
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||||
|
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
|
||||||
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
int offset = hasClearSelectionRow ? 1 : 0;
|
||||||
|
BlockedCommunityData communityData = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||||
|
name = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||||
|
fullname = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
|
||||||
|
iconUrl = mBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||||
|
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemClickListener == null) {
|
||||||
|
String finalFullname = fullname;
|
||||||
|
viewHolder.itemView.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name);
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY,
|
||||||
|
finalFullname);
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
glide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
|
||||||
|
} else {
|
||||||
|
glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
|
||||||
|
}
|
||||||
|
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
|
||||||
|
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
|
||||||
|
int offset;
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
if (hasClearSelectionRow) {
|
||||||
|
offset = 3;
|
||||||
|
} else {
|
||||||
|
offset = 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offset = 1;
|
||||||
|
}
|
||||||
|
BlockedCommunityData communityData = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||||
|
String name = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||||
|
String iconUrl = mFavoriteBlockedCommunityData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||||
|
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||||
|
} else {
|
||||||
|
viewHolder.itemView.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, name);
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
glide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
|
||||||
|
} else {
|
||||||
|
glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
|
||||||
|
}
|
||||||
|
((FavoriteSubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
if (mBlockedCommunityData != null) {
|
||||||
|
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
return mBlockedCommunityData.size() > 0 ? mBlockedCommunityData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mBlockedCommunityData.size();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
|
if (holder instanceof SubredditViewHolder) {
|
||||||
|
glide.clear(((SubredditViewHolder) holder).iconGifImageView);
|
||||||
|
} else if (holder instanceof FavoriteSubredditViewHolder) {
|
||||||
|
glide.clear(((FavoriteSubredditViewHolder) holder).iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubscribedSubreddits(List<BlockedCommunityData> subscribedSubreddits) {
|
||||||
|
mBlockedCommunityData = subscribedSubreddits;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavoriteSubscribedSubreddits(List<BlockedCommunityData> favoriteBlockedCommunityData) {
|
||||||
|
mFavoriteBlockedCommunityData = favoriteBlockedCommunityData;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUser(String username, String userIconUrl) {
|
||||||
|
this.username = username;
|
||||||
|
this.userIconUrl = userIconUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPopupText(int position) {
|
||||||
|
switch (getItemViewType(position)) {
|
||||||
|
case VIEW_TYPE_SUBREDDIT:
|
||||||
|
if (hasClearSelectionRow && position == 0) {
|
||||||
|
return "";
|
||||||
|
} else if (itemClickListener != null && !hasClearSelectionRow && position == 0) {
|
||||||
|
return "";
|
||||||
|
} else if (hasClearSelectionRow && position == 1) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
int offset;
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
if (hasClearSelectionRow) {
|
||||||
|
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||||
|
mFavoriteBlockedCommunityData.size() + 4 : 0;
|
||||||
|
} else {
|
||||||
|
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||||
|
mFavoriteBlockedCommunityData.size() + 3 : 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offset = (mFavoriteBlockedCommunityData != null && mFavoriteBlockedCommunityData.size() > 0) ?
|
||||||
|
mFavoriteBlockedCommunityData.size() + 2 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mBlockedCommunityData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||||
|
}
|
||||||
|
case VIEW_TYPE_FAVORITE_SUBREDDIT:
|
||||||
|
int offset;
|
||||||
|
if (itemClickListener != null) {
|
||||||
|
if (hasClearSelectionRow) {
|
||||||
|
offset = 3;
|
||||||
|
} else {
|
||||||
|
offset = 2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offset = 1;
|
||||||
|
}
|
||||||
|
return mFavoriteBlockedCommunityData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface ItemClickListener {
|
||||||
|
void onClick(BlockedCommunityData subredditData);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SubredditViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||||
|
GifImageView iconGifImageView;
|
||||||
|
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
|
||||||
|
TextView subredditNameTextView;
|
||||||
|
|
||||||
|
SubredditViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
subredditNameTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FavoriteSubredditViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||||
|
GifImageView iconGifImageView;
|
||||||
|
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
|
||||||
|
TextView subredditNameTextView;
|
||||||
|
|
||||||
|
FavoriteSubredditViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
subredditNameTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
subredditNameTextView.setTextColor(primaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FavoriteSubredditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
|
FavoriteSubredditsDividerViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
dividerTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
dividerTextView.setText(R.string.favorites);
|
||||||
|
dividerTextView.setTextColor(secondaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AllSubredditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
|
AllSubredditsDividerViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
dividerTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
dividerTextView.setText(R.string.all);
|
||||||
|
dividerTextView.setTextColor(secondaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||||
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class BlockedUsersRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||||
|
private static final int VIEW_TYPE_FAVORITE_USER_DIVIDER = 0;
|
||||||
|
private static final int VIEW_TYPE_FAVORITE_USER = 1;
|
||||||
|
private static final int VIEW_TYPE_USER_DIVIDER = 2;
|
||||||
|
private static final int VIEW_TYPE_USER = 3;
|
||||||
|
|
||||||
|
private List<BlockedUserData> mBlockedUserData;
|
||||||
|
private List<BlockedUserData> mFavoriteBlockedUserData;
|
||||||
|
private BaseActivity mActivity;
|
||||||
|
private Executor mExecutor;
|
||||||
|
private Retrofit mOauthRetrofit;
|
||||||
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private String mAccessToken;
|
||||||
|
private RequestManager glide;
|
||||||
|
private int mPrimaryTextColor;
|
||||||
|
private int mSecondaryTextColor;
|
||||||
|
|
||||||
|
public BlockedUsersRecyclerViewAdapter(BaseActivity activity, Executor executor, Retrofit oauthRetrofit,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
CustomThemeWrapper customThemeWrapper,
|
||||||
|
String accessToken) {
|
||||||
|
mActivity = activity;
|
||||||
|
mExecutor = executor;
|
||||||
|
mOauthRetrofit = oauthRetrofit;
|
||||||
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
mAccessToken = accessToken;
|
||||||
|
glide = Glide.with(activity);
|
||||||
|
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
if (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) {
|
||||||
|
if (position == 0) {
|
||||||
|
return VIEW_TYPE_FAVORITE_USER_DIVIDER;
|
||||||
|
} else if (position == mFavoriteBlockedUserData.size() + 1) {
|
||||||
|
return VIEW_TYPE_USER_DIVIDER;
|
||||||
|
} else if (position <= mFavoriteBlockedUserData.size()) {
|
||||||
|
return VIEW_TYPE_FAVORITE_USER;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_USER;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_USER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||||
|
switch (i) {
|
||||||
|
case VIEW_TYPE_FAVORITE_USER_DIVIDER:
|
||||||
|
return new FavoriteUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||||
|
case VIEW_TYPE_USER_DIVIDER:
|
||||||
|
return new AllUsersDividerViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_favorite_thing_divider, viewGroup, false));
|
||||||
|
default:
|
||||||
|
return new UserViewHolder(LayoutInflater.from(viewGroup.getContext())
|
||||||
|
.inflate(R.layout.item_subscribed_thing, viewGroup, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
|
if (viewHolder instanceof UserViewHolder) {
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
if (!mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getAvatar().equals("")) {
|
||||||
|
glide.load(mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getAvatar())
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(((UserViewHolder) viewHolder).iconGifImageView);
|
||||||
|
} else {
|
||||||
|
glide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(((UserViewHolder) viewHolder).iconGifImageView);
|
||||||
|
}
|
||||||
|
((UserViewHolder) viewHolder).userNameTextView.setText(mBlockedUserData.get(viewHolder.getBindingAdapterPosition() - offset).getName());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
if (mBlockedUserData != null && mBlockedUserData.size() > 0) {
|
||||||
|
return mBlockedUserData.size();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
|
if (holder instanceof UserViewHolder) {
|
||||||
|
glide.clear(((UserViewHolder) holder).iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubscribedUsers(List<BlockedUserData> subscribedUsers) {
|
||||||
|
mBlockedUserData = subscribedUsers;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavoriteSubscribedUsers(List<BlockedUserData> favoriteSubscribedUsers) {
|
||||||
|
mFavoriteBlockedUserData = favoriteSubscribedUsers;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getPopupText(int position) {
|
||||||
|
switch (getItemViewType(position)) {
|
||||||
|
case VIEW_TYPE_USER:
|
||||||
|
int offset = (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) ?
|
||||||
|
mFavoriteBlockedUserData.size() + 2 : 0;
|
||||||
|
return mBlockedUserData.get(position - offset).getName().substring(0, 1).toUpperCase();
|
||||||
|
case VIEW_TYPE_FAVORITE_USER:
|
||||||
|
return mFavoriteBlockedUserData.get(position - 1).getName().substring(0, 1).toUpperCase();
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class UserViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.thing_icon_gif_image_view_item_subscribed_thing)
|
||||||
|
GifImageView iconGifImageView;
|
||||||
|
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
|
||||||
|
TextView userNameTextView;
|
||||||
|
|
||||||
|
UserViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
userNameTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
userNameTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
|
||||||
|
itemView.setOnClickListener(view -> {
|
||||||
|
int offset = (mFavoriteBlockedUserData != null && mFavoriteBlockedUserData.size() > 0) ?
|
||||||
|
mFavoriteBlockedUserData.size() + 2 : 0;
|
||||||
|
int position = getBindingAdapterPosition() - offset;
|
||||||
|
if (position >= 0 && mBlockedUserData.size() > position) {
|
||||||
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mBlockedUserData.get(position).getName());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mBlockedUserData.get(position).getQualifiedName());
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FavoriteUsersDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
|
FavoriteUsersDividerViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
dividerTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
dividerTextView.setText(R.string.favorites);
|
||||||
|
dividerTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AllUsersDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
|
AllUsersDividerViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
dividerTextView.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
dividerTextView.setText(R.string.all);
|
||||||
|
dividerTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -190,7 +190,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentViewHolder) {
|
||||||
Comment comment = getItem(holder.getBindingAdapterPosition());
|
Comment comment = getItem(holder.getBindingAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
String name = "r/" + comment.getCommunityName();
|
String name = comment.getCommunityQualifiedName();
|
||||||
((CommentViewHolder) holder).authorTextView.setText(name);
|
((CommentViewHolder) holder).authorTextView.setText(name);
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
((CommentViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
||||||
|
|
||||||
@@ -437,6 +437,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getCommunityName());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getCommunityName());
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, comment.getCommunityQualifiedName());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -469,8 +470,9 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
Comment comment = getItem(getBindingAdapterPosition());
|
Comment comment = getItem(getBindingAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -98,7 +99,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
private Markwon mCommentMarkwon;
|
private Markwon mCommentMarkwon;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountQualifiedName;
|
||||||
|
|
||||||
private Post mPost;
|
private Post mPost;
|
||||||
private ArrayList<Comment> mVisibleComments;
|
private ArrayList<Comment> mVisibleComments;
|
||||||
|
|
||||||
@@ -124,6 +126,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
private boolean mShowAuthorAvatar;
|
private boolean mShowAuthorAvatar;
|
||||||
private boolean mAlwaysShowChildCommentCount;
|
private boolean mAlwaysShowChildCommentCount;
|
||||||
private boolean mHideTheNumberOfVotes;
|
private boolean mHideTheNumberOfVotes;
|
||||||
|
private boolean mSeperateUpandDownvote;
|
||||||
|
private boolean mHideDownvotes;
|
||||||
private int mDepthThreshold;
|
private int mDepthThreshold;
|
||||||
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
||||||
private boolean isInitiallyLoading;
|
private boolean isInitiallyLoading;
|
||||||
@@ -161,17 +165,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
||||||
CustomThemeWrapper customThemeWrapper,
|
CustomThemeWrapper customThemeWrapper,
|
||||||
Executor executor, Retrofit retrofit, Retrofit oauthRetrofit,
|
Executor executor, Retrofit retrofit,
|
||||||
String accessToken, String accountName,
|
String accessToken, String accountName,
|
||||||
Post post, Locale locale, Integer singleCommentId,
|
Post post, Locale locale, Integer singleCommentId,
|
||||||
boolean isSingleCommentThreadMode,
|
boolean isSingleCommentThreadMode,
|
||||||
SharedPreferences sharedPreferences,
|
SharedPreferences sharedPreferences,
|
||||||
|
SharedPreferences currentAccountSharedPreferences,
|
||||||
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
|
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
mExecutor = executor;
|
mExecutor = executor;
|
||||||
mRetrofit = retrofit;
|
mRetrofit = retrofit;
|
||||||
mOauthRetrofit = oauthRetrofit;
|
|
||||||
mGlide = Glide.with(activity);
|
mGlide = Glide.with(activity);
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
mCommentTextColor = customThemeWrapper.getCommentColor();
|
mCommentTextColor = customThemeWrapper.getCommentColor();
|
||||||
@@ -214,7 +218,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
||||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
mAccountName = accountName;
|
mAccountQualifiedName = accountName;
|
||||||
mPost = post;
|
mPost = post;
|
||||||
mVisibleComments = new ArrayList<>();
|
mVisibleComments = new ArrayList<>();
|
||||||
loadedComments = new HashSet<>();
|
loadedComments = new HashSet<>();
|
||||||
@@ -238,6 +242,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
mShowAuthorAvatar = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AUTHOR_AVATAR, false);
|
mShowAuthorAvatar = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AUTHOR_AVATAR, false);
|
||||||
mAlwaysShowChildCommentCount = sharedPreferences.getBoolean(SharedPreferencesUtils.ALWAYS_SHOW_CHILD_COMMENT_COUNT, false);
|
mAlwaysShowChildCommentCount = sharedPreferences.getBoolean(SharedPreferencesUtils.ALWAYS_SHOW_CHILD_COMMENT_COUNT, false);
|
||||||
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS, false);
|
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES_IN_COMMENTS, false);
|
||||||
|
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
|
||||||
|
mSeperateUpandDownvote = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
|
||||||
mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5);
|
mDepthThreshold = sharedPreferences.getInt(SharedPreferencesUtils.SHOW_FEWER_TOOLBAR_OPTIONS_THRESHOLD, 5);
|
||||||
|
|
||||||
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||||
@@ -384,7 +390,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
||||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
moderatorDrawable, null, null, null);
|
moderatorDrawable, null, null, null);
|
||||||
} else if (comment.getAuthor().equals(mAccountName)) {
|
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
|
((CommentViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
|
||||||
Drawable currentUserDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_current_user_14dp, mCurrentUserColor);
|
Drawable currentUserDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_current_user_14dp, mCurrentUserColor);
|
||||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
@@ -393,12 +399,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
if (comment.getAuthorIconUrl() == null) {
|
if (comment.getAuthorIconUrl() == null) {
|
||||||
mFragment.loadIcon(comment.getAuthorQualifiedName(), (authorName, iconUrl) -> {
|
mFragment.loadIcon(comment.getAuthorQualifiedName(), (authorName, iconUrl) -> {
|
||||||
if (authorName.equals(comment.getAuthor())) {
|
if (authorName.equals(comment.getAuthorQualifiedName())) {
|
||||||
comment.setAuthorIconUrl(iconUrl);
|
comment.setAuthorIconUrl(iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Comment currentComment = getCurrentComment(holder);
|
Comment currentComment = getCurrentComment(holder);
|
||||||
if (currentComment != null && authorName.equals(currentComment.getAuthor())) {
|
if (currentComment != null && authorName.equals(currentComment.getAuthorQualifiedName())) {
|
||||||
mGlide.load(iconUrl)
|
mGlide.load(iconUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@@ -435,6 +441,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
((CommentViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
|
((CommentViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
|
||||||
// noinspection NotifyDataSetChanged
|
// noinspection NotifyDataSetChanged
|
||||||
((CommentViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
|
((CommentViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
|
||||||
|
if (mHideDownvotes) {
|
||||||
|
((CommentViewHolder) holder).downvoteButton.setVisibility(View.GONE);
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
String commentText = "";
|
String commentText = "";
|
||||||
@@ -446,7 +456,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
((CommentViewHolder) holder).scoreTextView.setText(commentText);
|
if (mSeperateUpandDownvote) {
|
||||||
|
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
|
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.VISIBLE);
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setGravity(Gravity.START);
|
||||||
|
((CommentViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
||||||
|
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setPadding(0, 0, 6, 0);
|
||||||
|
((CommentViewHolder) holder).downvoteButton.setPadding(24, 0, 12, 0);
|
||||||
|
((CommentViewHolder) holder).upvoteButton.setPadding(24, 0, 12, 0);
|
||||||
|
} else {
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setText(commentText);
|
||||||
|
}
|
||||||
((CommentViewHolder) holder).topScoreTextView.setText(topScoreText);
|
((CommentViewHolder) holder).topScoreTextView.setText(topScoreText);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
((CommentViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
||||||
@@ -486,13 +510,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
break;
|
break;
|
||||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpandDownvote) {
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
} else {
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
@@ -538,12 +570,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
if (comment.getAuthorIconUrl() == null) {
|
if (comment.getAuthorIconUrl() == null) {
|
||||||
mFragment.loadIcon(comment.getAuthorQualifiedName(), (authorName, iconUrl) -> {
|
mFragment.loadIcon(comment.getAuthorQualifiedName(), (authorName, iconUrl) -> {
|
||||||
if (authorName.equals(comment.getAuthor())) {
|
if (authorName.equals(comment.getAuthorQualifiedName())) {
|
||||||
comment.setAuthorIconUrl(iconUrl);
|
comment.setAuthorIconUrl(iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Comment currentComment = getCurrentComment(holder);
|
Comment currentComment = getCurrentComment(holder);
|
||||||
if (currentComment != null && authorName.equals(currentComment.getAuthor())) {
|
if (currentComment != null && authorName.equals(currentComment.getAuthorQualifiedName())) {
|
||||||
mGlide.load(iconUrl)
|
mGlide.load(iconUrl)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@@ -1191,6 +1223,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
ImageView upvoteButton;
|
ImageView upvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_comment)
|
@BindView(R.id.score_text_view_item_post_comment)
|
||||||
TextView scoreTextView;
|
TextView scoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_comment)
|
||||||
|
TextView downvoteTextView;
|
||||||
@BindView(R.id.down_vote_button_item_post_comment)
|
@BindView(R.id.down_vote_button_item_post_comment)
|
||||||
ImageView downvoteButton;
|
ImageView downvoteButton;
|
||||||
@BindView(R.id.placeholder_item_post_comment)
|
@BindView(R.id.placeholder_item_post_comment)
|
||||||
@@ -1222,6 +1257,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
constraintSet.clear(scoreTextView.getId(), ConstraintSet.END);
|
constraintSet.clear(scoreTextView.getId(), ConstraintSet.END);
|
||||||
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
|
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.clear(downvoteButton.getId(), ConstraintSet.END);
|
constraintSet.clear(downvoteButton.getId(), ConstraintSet.END);
|
||||||
|
constraintSet.clear(downvoteTextView.getId(), ConstraintSet.START);
|
||||||
|
constraintSet.clear(downvoteTextView.getId(), ConstraintSet.END);
|
||||||
constraintSet.clear(expandButton.getId(), ConstraintSet.START);
|
constraintSet.clear(expandButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.clear(expandButton.getId(), ConstraintSet.END);
|
constraintSet.clear(expandButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.clear(saveButton.getId(), ConstraintSet.START);
|
constraintSet.clear(saveButton.getId(), ConstraintSet.START);
|
||||||
@@ -1234,8 +1271,15 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
constraintSet.connect(upvoteButton.getId(), ConstraintSet.START, placeholder.getId(), ConstraintSet.END);
|
constraintSet.connect(upvoteButton.getId(), ConstraintSet.START, placeholder.getId(), ConstraintSet.END);
|
||||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
|
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.START, upvoteButton.getId(), ConstraintSet.END);
|
constraintSet.connect(scoreTextView.getId(), ConstraintSet.START, upvoteButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
if (!mSeperateUpandDownvote) {
|
||||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||||
|
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
||||||
|
} else {
|
||||||
|
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, downvoteTextView.getId(), ConstraintSet.START);
|
||||||
|
constraintSet.connect(downvoteButton.getId(), ConstraintSet.START, scoreTextView.getId(), ConstraintSet.END);
|
||||||
|
constraintSet.connect(downvoteTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||||
|
constraintSet.connect(downvoteTextView.getId(), ConstraintSet.START, downvoteButton.getId(), ConstraintSet.END);
|
||||||
|
}
|
||||||
constraintSet.connect(placeholder.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
|
constraintSet.connect(placeholder.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.connect(placeholder.getId(), ConstraintSet.START, moreButton.getId(), ConstraintSet.END);
|
constraintSet.connect(placeholder.getId(), ConstraintSet.START, moreButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
|
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
|
||||||
@@ -1268,6 +1312,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
editedTextView.setTypeface(mActivity.typeface);
|
editedTextView.setTypeface(mActivity.typeface);
|
||||||
awardsTextView.setTypeface(mActivity.typeface);
|
awardsTextView.setTypeface(mActivity.typeface);
|
||||||
scoreTextView.setTypeface(mActivity.typeface);
|
scoreTextView.setTypeface(mActivity.typeface);
|
||||||
|
downvoteTextView.setTypeface(mActivity.typeface);
|
||||||
expandButton.setTypeface(mActivity.typeface);
|
expandButton.setTypeface(mActivity.typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1299,11 +1344,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
authorFlairTextView.setTextColor(mAuthorFlairTextColor);
|
authorFlairTextView.setTextColor(mAuthorFlairTextColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
downvoteTextView.setTextColor(mSecondaryTextColor);
|
||||||
editedTextView.setTextColor(mSecondaryTextColor);
|
editedTextView.setTextColor(mSecondaryTextColor);
|
||||||
awardsTextView.setTextColor(mSecondaryTextColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
expandButton.setTextColor(mCommentIconAndInfoColor);
|
expandButton.setTextColor(mCommentIconAndInfoColor);
|
||||||
@@ -1327,7 +1374,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
Comment comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthor().equals(mAccountName)) {
|
if (!mPost.isArchived() && !mPost.isLocked() && comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
||||||
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
|
bundle.putBoolean(CommentMoreBottomSheetFragment.EXTRA_EDIT_AND_DELETE_AVAILABLE, true);
|
||||||
}
|
}
|
||||||
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
@@ -1410,12 +1457,22 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpandDownvote){
|
||||||
comment.getScore() + comment.getVoteType()));
|
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
|
int downvoteCount = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
upvoteCount));
|
||||||
|
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
downvoteCount));
|
||||||
|
}else {
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
@@ -1431,6 +1488,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
@@ -1438,14 +1496,24 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpandDownvote){
|
||||||
comment.getScore() + comment.getVoteType()));
|
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
upvoteCount));
|
||||||
|
int downvoteCount = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||||
|
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
downvoteCount));
|
||||||
|
} else {
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
@@ -1483,20 +1551,34 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpandDownvote){
|
||||||
|
downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
}else {
|
||||||
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpandDownvote){
|
||||||
comment.getScore() + comment.getVoteType()));
|
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() +1 : comment.getDownvotes();
|
||||||
|
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() +1 : comment.getUpvotes();
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
upvotes));
|
||||||
|
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
@@ -1511,7 +1593,11 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpandDownvote){
|
||||||
|
downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
}else {
|
||||||
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1519,6 +1605,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1526,8 +1613,17 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpandDownvote){
|
||||||
comment.getScore() + comment.getVoteType()));
|
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() +1 : comment.getDownvotes();
|
||||||
|
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() +1 : comment.getUpvotes();
|
||||||
|
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
upvotes));
|
||||||
|
} else {
|
||||||
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
}
|
||||||
|
|
||||||
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
topScoreTextView.setText(mActivity.getString(R.string.top_score,
|
||||||
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType())));
|
comment.getScore() + comment.getVoteType())));
|
||||||
@@ -1549,7 +1645,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
SaveComment saveComment = new SaveComment();
|
SaveComment saveComment = new SaveComment();
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
saveComment.unsaveThing(mOauthRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
saveComment.unsaveThing(mRetrofit, mAccessToken, comment.getId(), new SaveThing.SaveThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
@@ -1925,6 +2021,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (mActivity != null && mActivity instanceof ViewPostDetailActivity) {
|
if (mActivity != null && mActivity instanceof ViewPostDetailActivity) {
|
||||||
mIsSingleCommentThreadMode = false;
|
mIsSingleCommentThreadMode = false;
|
||||||
mSingleCommentId = null;
|
mSingleCommentId = null;
|
||||||
|
loadedComments.clear();
|
||||||
notifyItemRemoved(0);
|
notifyItemRemoved(0);
|
||||||
mFragment.changeToNormalThreadMode();
|
mFragment.changeToNormalThreadMode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -554,9 +554,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
.into(((PostBaseViewHolder) holder).iconGifImageView);
|
.into(((PostBaseViewHolder) holder).iconGifImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder.getBindingAdapterPosition() >= 0) {
|
|
||||||
post.setSubredditIconUrl(iconUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||||
@@ -641,9 +638,12 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) {
|
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isFeaturedInCommunity() || post.isFeaturedOnInstance()) {
|
||||||
((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
((PostBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
||||||
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostBaseViewHolder) holder).stickiedPostImageView);
|
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostBaseViewHolder) holder).stickiedPostImageView);
|
||||||
|
if (post.isFeaturedOnInstance()) {
|
||||||
|
((PostBaseViewHolder) holder).stickiedPostImageView.setColorFilter(mModeratorColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.isArchived()) {
|
if (post.isArchived()) {
|
||||||
@@ -1079,9 +1079,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
|
.into(((PostCompactBaseViewHolder) holder).iconGifImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder.getBindingAdapterPosition() >= 0) {
|
|
||||||
post.setSubredditIconUrl(iconUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!post.getSubredditIconUrl().equals("")) {
|
} else if (!post.getSubredditIconUrl().equals("")) {
|
||||||
@@ -1210,7 +1207,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) {
|
if (mPostType == PostPagingSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isFeaturedInCommunity()) {
|
||||||
((PostCompactBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
((PostCompactBaseViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE);
|
||||||
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostCompactBaseViewHolder) holder).stickiedPostImageView);
|
mGlide.load(R.drawable.ic_thumbtack_24dp).into(((PostCompactBaseViewHolder) holder).stickiedPostImageView);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,24 +19,13 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
|
||||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
|
||||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
|
||||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
|
||||||
import eu.toldi.infinityforlemmy.NetworkState;
|
import eu.toldi.infinityforlemmy.NetworkState;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
@@ -45,28 +34,38 @@ import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
|||||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||||
|
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||||
import eu.toldi.infinityforlemmy.message.Message;
|
|
||||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||||
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
|
import io.noties.markwon.Markwon;
|
||||||
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||||
|
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||||
|
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||||
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteraction, RecyclerView.ViewHolder> {
|
||||||
private static final int VIEW_TYPE_DATA = 0;
|
private static final int VIEW_TYPE_DATA = 0;
|
||||||
private static final int VIEW_TYPE_ERROR = 1;
|
private static final int VIEW_TYPE_ERROR = 1;
|
||||||
private static final int VIEW_TYPE_LOADING = 2;
|
private static final int VIEW_TYPE_LOADING = 2;
|
||||||
private static final DiffUtil.ItemCallback<Message> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
private static final DiffUtil.ItemCallback<CommentInteraction> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(@NonNull Message message, @NonNull Message t1) {
|
public boolean areItemsTheSame(@NonNull CommentInteraction message, @NonNull CommentInteraction t1) {
|
||||||
return message.getId().equals(t1.getId());
|
return message.getComment().getId() == t1.getComment().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(@NonNull Message message, @NonNull Message t1) {
|
public boolean areContentsTheSame(@NonNull CommentInteraction message, @NonNull CommentInteraction t1) {
|
||||||
return message.getBody().equals(t1.getBody());
|
return message.getComment().getCommentMarkdown().equals(t1.getComment().getCommentMarkdown());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private BaseActivity mActivity;
|
private BaseActivity mActivity;
|
||||||
private Retrofit mOauthRetrofit;
|
private Retrofit retrofit;
|
||||||
private Markwon mMarkwon;
|
private Markwon mMarkwon;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private int mMessageType;
|
private int mMessageType;
|
||||||
@@ -88,7 +87,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mOauthRetrofit = oauthRetrofit;
|
retrofit = oauthRetrofit;
|
||||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||||
|
|
||||||
mColorAccent = customThemeWrapper.getColorAccent();
|
mColorAccent = customThemeWrapper.getColorAccent();
|
||||||
@@ -106,7 +105,6 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
mMarkwon = Markwon.builder(mActivity)
|
mMarkwon = Markwon.builder(mActivity)
|
||||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
|
||||||
}))
|
}))
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
@@ -130,6 +128,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()))
|
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
|
.usePlugin(GlideImagesPlugin.create(mActivity))
|
||||||
.build();
|
.build();
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||||
@@ -154,41 +153,38 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof DataViewHolder) {
|
if (holder instanceof DataViewHolder) {
|
||||||
Message message = getItem(holder.getBindingAdapterPosition());
|
CommentInteraction message = getItem(holder.getBindingAdapterPosition());
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
ArrayList<Message> replies = message.getReplies();
|
|
||||||
Message displayedMessage;
|
if (message.isRead()) {
|
||||||
if (replies != null && !replies.isEmpty() && replies.get(replies.size() - 1) != null) {
|
|
||||||
displayedMessage = replies.get(replies.size() - 1);
|
|
||||||
} else {
|
|
||||||
displayedMessage = message;
|
|
||||||
}
|
|
||||||
if (message.isNew()) {
|
|
||||||
if (markAllMessagesAsRead) {
|
if (markAllMessagesAsRead) {
|
||||||
message.setNew(false);
|
message.markAsRead();
|
||||||
} else {
|
} else {
|
||||||
holder.itemView.setBackgroundColor(
|
holder.itemView.setBackgroundColor(
|
||||||
mUnreadMessageBackgroundColor);
|
mUnreadMessageBackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.wasComment()) {
|
|
||||||
((DataViewHolder) holder).titleTextView.setText(message.getTitle());
|
|
||||||
} else {
|
|
||||||
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
((DataViewHolder) holder).authorTextView.setText(displayedMessage.getAuthor());
|
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
||||||
String subject = displayedMessage.getSubject().substring(0, 1).toUpperCase() + displayedMessage.getSubject().substring(1);
|
|
||||||
|
|
||||||
|
((DataViewHolder) holder).authorTextView.setText(message.getComment().getAuthorQualifiedName());
|
||||||
|
String subject = message.getComment().getCommunityQualifiedName();
|
||||||
((DataViewHolder) holder).subjectTextView.setText(subject);
|
((DataViewHolder) holder).subjectTextView.setText(subject);
|
||||||
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, displayedMessage.getBody());
|
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, message.getComment().getCommentMarkdown());
|
||||||
|
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
||||||
&& message.getContext() != null && !message.getContext().equals("")) {
|
&& message.getComment() != null) {
|
||||||
Uri uri = Uri.parse(message.getContext());
|
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||||
intent.setData(uri);
|
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, message.getComment().getPostId());
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, message.getComment().getId());
|
||||||
|
if(message.getComment().getDepth() > 0) {
|
||||||
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, message.getComment().getParentId());
|
||||||
|
}
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) {
|
} else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) {
|
||||||
Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
|
Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
|
||||||
@@ -197,20 +193,21 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayedMessage.isNew()) {
|
if (message.isRead()) {
|
||||||
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||||
message.setNew(false);
|
|
||||||
|
|
||||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, message.getFullname(),
|
|
||||||
|
ReadMessage.readMessage(retrofit, mAccessToken, message.getId(),
|
||||||
new ReadMessage.ReadMessageListener() {
|
new ReadMessage.ReadMessageListener() {
|
||||||
@Override
|
@Override
|
||||||
public void readSuccess() {
|
public void readSuccess() {
|
||||||
|
message.markAsRead();
|
||||||
EventBus.getDefault().post(new ChangeInboxCountEvent(-1));
|
EventBus.getDefault().post(new ChangeInboxCountEvent(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFailed() {
|
public void readFailed() {
|
||||||
message.setNew(true);
|
message.markAsUnRead();
|
||||||
holder.itemView.setBackgroundColor(mUnreadMessageBackgroundColor);
|
holder.itemView.setBackgroundColor(mUnreadMessageBackgroundColor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -218,11 +215,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
});
|
});
|
||||||
|
|
||||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||||
if (message.isAuthorDeleted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthor());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getComment().getAuthorQualifiedName());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -280,9 +276,9 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMessageReply(Message newReply, int position) {
|
public void updateMessageReply(CommentInteraction newReply, int position) {
|
||||||
if (position >= 0 && position < super.getItemCount()) {
|
if (position >= 0 && position < super.getItemCount()) {
|
||||||
Message message = getItem(position);
|
CommentInteraction message = getItem(position);
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
notifyItemChanged(position);
|
notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -42,7 +43,9 @@ import com.bumptech.glide.load.DataSource;
|
|||||||
import com.bumptech.glide.load.engine.GlideException;
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
import com.bumptech.glide.request.target.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.google.android.exoplayer2.Tracks;
|
import com.google.android.exoplayer2.Tracks;
|
||||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||||
import com.google.android.exoplayer2.ui.DefaultTimeBar;
|
import com.google.android.exoplayer2.ui.DefaultTimeBar;
|
||||||
@@ -54,6 +57,7 @@ import com.libRG.CustomTextView;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
@@ -168,9 +172,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
private boolean mHideUpvoteRatio;
|
private boolean mHideUpvoteRatio;
|
||||||
private boolean mHideTheNumberOfAwards;
|
private boolean mHideTheNumberOfAwards;
|
||||||
private boolean mHideSubredditAndUserPrefix;
|
private boolean mHideSubredditAndUserPrefix;
|
||||||
|
|
||||||
|
private boolean mShowDisplayNames;
|
||||||
private boolean mHideTheNumberOfVotes;
|
private boolean mHideTheNumberOfVotes;
|
||||||
|
|
||||||
|
private boolean mSeperateUpvoteAndDownvote;
|
||||||
private boolean mHideTheNumberOfComments;
|
private boolean mHideTheNumberOfComments;
|
||||||
private boolean mSeparatePostAndComments;
|
private boolean mSeparatePostAndComments;
|
||||||
|
private boolean mHideDownvotes;
|
||||||
private boolean mLegacyAutoplayVideoControllerUI;
|
private boolean mLegacyAutoplayVideoControllerUI;
|
||||||
private boolean mEasierToWatchInFullScreen;
|
private boolean mEasierToWatchInFullScreen;
|
||||||
private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback;
|
private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback;
|
||||||
@@ -214,7 +223,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
||||||
Executor executor, CustomThemeWrapper customThemeWrapper,
|
Executor executor, CustomThemeWrapper customThemeWrapper,
|
||||||
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
Retrofit retrofit, Retrofit gfycatRetrofit,
|
||||||
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
|
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
|
||||||
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
||||||
boolean separatePostAndComments, String accessToken,
|
boolean separatePostAndComments, String accessToken,
|
||||||
@@ -229,7 +238,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mFragment = fragment;
|
mFragment = fragment;
|
||||||
mExecutor = executor;
|
mExecutor = executor;
|
||||||
mRetrofit = retrofit;
|
mRetrofit = retrofit;
|
||||||
mOauthRetrofit = oauthRetrofit;
|
|
||||||
mGfycatRetrofit = gfycatRetrofit;
|
mGfycatRetrofit = gfycatRetrofit;
|
||||||
mRedgifsRetrofit = redgifsRetrofit;
|
mRedgifsRetrofit = redgifsRetrofit;
|
||||||
mStreamableApiProvider = streamableApiProvider;
|
mStreamableApiProvider = streamableApiProvider;
|
||||||
@@ -339,7 +347,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mHideUpvoteRatio = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_UPVOTE_RATIO, false);
|
mHideUpvoteRatio = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_UPVOTE_RATIO, false);
|
||||||
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
|
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
|
||||||
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
|
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
|
||||||
|
mShowDisplayNames = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
|
||||||
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
|
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
|
||||||
|
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
|
||||||
|
mSeperateUpvoteAndDownvote = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
|
||||||
mHideTheNumberOfComments = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
|
mHideTheNumberOfComments = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
|
||||||
|
|
||||||
mPostDetailRecyclerViewAdapterCallback = postDetailRecyclerViewAdapterCallback;
|
mPostDetailRecyclerViewAdapterCallback = postDetailRecyclerViewAdapterCallback;
|
||||||
@@ -437,7 +448,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
}
|
}
|
||||||
return new PostDetailVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_detail_video_autoplay_legacy_controller : R.layout.item_post_detail_video_autoplay, parent, false));
|
return new PostDetailVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_detail_video_autoplay_legacy_controller : R.layout.item_post_detail_video_autoplay, parent, false));
|
||||||
case VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW:
|
case VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW:
|
||||||
if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts)) {
|
if (mDataSavingMode && (mDisableImagePreview || mOnlyDisablePreviewInVideoAndGifPosts) || mPost.getPreviews().isEmpty()) {
|
||||||
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
|
return new PostDetailNoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_no_preview, parent, false));
|
||||||
}
|
}
|
||||||
return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false));
|
return new PostDetailVideoAndGifPreviewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_detail_video_and_gif_preview, parent, false));
|
||||||
@@ -474,8 +485,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
|
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
|
||||||
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
|
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
|
||||||
if (mPost.getAuthorIconUrl() == null) {
|
if (mPost.getAuthorIconUrl() == null) {
|
||||||
String authorName = mPost.isAuthorDeleted() ? mPost.getSubredditNamePrefixed().substring(2) : mPost.getAuthor();
|
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase,mPost.getAuthorNamePrefixed(), mOauthRetrofit, iconImageUrl -> {
|
||||||
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase, authorName, mOauthRetrofit, iconImageUrl -> {
|
|
||||||
if (mActivity != null && getItemCount() > 0) {
|
if (mActivity != null && getItemCount() > 0) {
|
||||||
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@@ -508,7 +518,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
} else {
|
} else {
|
||||||
if (mPost.getSubredditIconUrl() == null) {
|
if (mPost.getSubredditIconUrl() == null) {
|
||||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(),
|
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(),
|
||||||
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed().substring(2),
|
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed(),
|
||||||
mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> {
|
mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> {
|
||||||
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@@ -521,8 +531,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
.into(((PostDetailBaseViewHolder) holder).mIconGifImageView);
|
.into(((PostDetailBaseViewHolder) holder).mIconGifImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
mPost.setSubredditIconUrl(iconImageUrl);
|
|
||||||
});
|
});
|
||||||
} else if (!mPost.getSubredditIconUrl().equals("")) {
|
} else if (!mPost.getSubredditIconUrl().equals("")) {
|
||||||
mGlide.load(mPost.getSubredditIconUrl())
|
mGlide.load(mPost.getSubredditIconUrl())
|
||||||
@@ -543,16 +551,23 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
//Upvote
|
//Upvote
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mUpvotedColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mUpvotedColor);
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
//Downvote
|
//Downvote
|
||||||
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpvoteAndDownvote){
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
} else {
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((PostDetailBaseViewHolder) holder).mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
@@ -566,15 +581,20 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailBaseViewHolder) holder).mCrosspostImageView.setVisibility(View.VISIBLE);
|
((PostDetailBaseViewHolder) holder).mCrosspostImageView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideSubredditAndUserPrefix) {
|
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditNamePrefixed());
|
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed());
|
if (mHideSubredditAndUserPrefix) {
|
||||||
|
((PostDetailBaseViewHolder) holder).mUserTextView.setText((mShowDisplayNames) ? mPost.getAuthor() : mPost.getAuthorInfo().getUsername());
|
||||||
} else {
|
} else {
|
||||||
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName());
|
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText((mShowDisplayNames) ? mPost.getSubredditName() : mPost.getCommunityInfo().getName());
|
||||||
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthor());
|
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setText('@' + mPost.getSubredditNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||||
|
|
||||||
|
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setText('@' + mPost.getAuthorNamePrefixed().split(Pattern.quote("@"))[1]);
|
||||||
|
((PostDetailBaseViewHolder) holder).mCommunityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mSubredditColor, 0.7f));
|
||||||
|
((PostDetailBaseViewHolder) holder).mUserInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(mPost.isModerator() || mPost.isAdmin() ? mModeratorColor : mUsernameColor, 0.7f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isModerator()) {
|
if (mPost.isModerator() || mPost.isAdmin()) {
|
||||||
((PostDetailBaseViewHolder) holder).mUserTextView.setTextColor(mModeratorColor);
|
((PostDetailBaseViewHolder) holder).mUserTextView.setTextColor(mModeratorColor);
|
||||||
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
Drawable moderatorDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_verified_user_14dp, mModeratorColor);
|
||||||
((PostDetailBaseViewHolder) holder).mUserTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((PostDetailBaseViewHolder) holder).mUserTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
@@ -610,7 +630,24 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, mPost.getScore() + mPost.getVoteType()));
|
if(mSeperateUpvoteAndDownvote){
|
||||||
|
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes()+1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() +1 : Math.max(mPost.getDownvotes(),0);
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setGravity(Gravity.START);
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setGravity(Gravity.START);
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
||||||
|
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setPadding(0, 0, 6, 0);
|
||||||
|
((PostDetailBaseViewHolder) holder).mDownvoteTextView.setPadding(0, 0, 12, 0);
|
||||||
|
((PostDetailBaseViewHolder) holder).mUpvoteButton.setPadding(24, 0, 12, 0);
|
||||||
|
} else {
|
||||||
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, mPost.getScore() + mPost.getVoteType()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(mActivity.getString(R.string.vote));
|
((PostDetailBaseViewHolder) holder).mScoreTextView.setText(mActivity.getString(R.string.vote));
|
||||||
}
|
}
|
||||||
@@ -635,8 +672,20 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
|
((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
|
||||||
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) width / height);
|
||||||
|
((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||||
}
|
}
|
||||||
@@ -844,9 +893,45 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (blurImage) {
|
if (blurImage) {
|
||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
}
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
}
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
|
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||||
@@ -872,9 +957,45 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
.into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
}
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
}
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (holder instanceof PostDetailLinkViewHolder) {
|
} else if (holder instanceof PostDetailLinkViewHolder) {
|
||||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||||
@@ -900,9 +1021,51 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
||||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||||
.into(((PostDetailLinkViewHolder) holder).mImageView);
|
.into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
} else {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
}
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailLinkViewHolder) holder).mImageView);
|
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||||
|
int width = resource.getIntrinsicWidth();
|
||||||
|
int height = resource.getIntrinsicHeight();
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||||
|
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||||
|
preview.setPreviewHeight(height);
|
||||||
|
preview.setPreviewWidth(width);
|
||||||
|
} else {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1019,7 +1182,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
public class PostDetailBaseViewHolder extends RecyclerView.ViewHolder {
|
public class PostDetailBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
TextView mPostTimeTextView;
|
TextView mPostTimeTextView;
|
||||||
TextView mTitleTextView;
|
TextView mTitleTextView;
|
||||||
@@ -1036,6 +1201,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ConstraintLayout mBottomConstraintLayout;
|
ConstraintLayout mBottomConstraintLayout;
|
||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
TextView mDownvoteTextView;
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
TextView commentsCountTextView;
|
TextView commentsCountTextView;
|
||||||
ImageView mSaveButton;
|
ImageView mSaveButton;
|
||||||
@@ -1047,7 +1213,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
void setBaseView(AspectRatioGifImageView mIconGifImageView,
|
void setBaseView(AspectRatioGifImageView mIconGifImageView,
|
||||||
TextView mSubredditTextView,
|
TextView mSubredditTextView,
|
||||||
|
TextView mCommunityInstanceTextView,
|
||||||
TextView mUserTextView,
|
TextView mUserTextView,
|
||||||
|
TextView mUserInstanceTextView,
|
||||||
TextView mAuthorFlairTextView,
|
TextView mAuthorFlairTextView,
|
||||||
TextView mPostTimeTextView,
|
TextView mPostTimeTextView,
|
||||||
TextView mTitleTextView,
|
TextView mTitleTextView,
|
||||||
@@ -1064,13 +1232,16 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ConstraintLayout mBottomConstraintLayout,
|
ConstraintLayout mBottomConstraintLayout,
|
||||||
ImageView mUpvoteButton,
|
ImageView mUpvoteButton,
|
||||||
TextView mScoreTextView,
|
TextView mScoreTextView,
|
||||||
|
TextView mDownvoteTextView,
|
||||||
ImageView mDownvoteButton,
|
ImageView mDownvoteButton,
|
||||||
TextView commentsCountTextView,
|
TextView commentsCountTextView,
|
||||||
ImageView mSaveButton,
|
ImageView mSaveButton,
|
||||||
ImageView mShareButton) {
|
ImageView mShareButton) {
|
||||||
this.mIconGifImageView = mIconGifImageView;
|
this.mIconGifImageView = mIconGifImageView;
|
||||||
this.mSubredditTextView = mSubredditTextView;
|
this.mSubredditTextView = mSubredditTextView;
|
||||||
|
this.mCommunityInstanceTextView = mCommunityInstanceTextView;
|
||||||
this.mUserTextView = mUserTextView;
|
this.mUserTextView = mUserTextView;
|
||||||
|
this.mUserInstanceTextView = mUserInstanceTextView;
|
||||||
this.mAuthorFlairTextView = mAuthorFlairTextView;
|
this.mAuthorFlairTextView = mAuthorFlairTextView;
|
||||||
this.mPostTimeTextView = mPostTimeTextView;
|
this.mPostTimeTextView = mPostTimeTextView;
|
||||||
this.mTitleTextView = mTitleTextView;
|
this.mTitleTextView = mTitleTextView;
|
||||||
@@ -1087,23 +1258,30 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
this.mBottomConstraintLayout = mBottomConstraintLayout;
|
this.mBottomConstraintLayout = mBottomConstraintLayout;
|
||||||
this.mUpvoteButton = mUpvoteButton;
|
this.mUpvoteButton = mUpvoteButton;
|
||||||
this.mScoreTextView = mScoreTextView;
|
this.mScoreTextView = mScoreTextView;
|
||||||
|
this.mDownvoteTextView = mDownvoteTextView;
|
||||||
this.mDownvoteButton = mDownvoteButton;
|
this.mDownvoteButton = mDownvoteButton;
|
||||||
this.commentsCountTextView = commentsCountTextView;
|
this.commentsCountTextView = commentsCountTextView;
|
||||||
this.mSaveButton = mSaveButton;
|
this.mSaveButton = mSaveButton;
|
||||||
this.mShareButton = mShareButton;
|
this.mShareButton = mShareButton;
|
||||||
|
|
||||||
|
if(!mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE,true)){
|
||||||
|
mDownvoteButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
mIconGifImageView.setOnClickListener(view -> mSubredditTextView.performClick());
|
mIconGifImageView.setOnClickListener(view -> mSubredditTextView.performClick());
|
||||||
|
|
||||||
mSubredditTextView.setOnClickListener(view -> {
|
View.OnClickListener communityClickListener = view -> {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||||
mPost.getSubredditName());
|
mPost.getSubredditName());
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, mPost.getSubredditNamePrefixed());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, mPost.getSubredditNamePrefixed());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
};
|
||||||
|
mSubredditTextView.setOnClickListener(communityClickListener);
|
||||||
|
mCommunityInstanceTextView.setOnClickListener(communityClickListener);
|
||||||
|
|
||||||
mUserTextView.setOnClickListener(view -> {
|
View.OnClickListener onUserClick = view -> {
|
||||||
if (mPost.isAuthorDeleted()) {
|
if (mPost.isAuthorDeleted()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1111,7 +1289,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mPost.getAuthorNamePrefixed());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, mPost.getAuthorNamePrefixed());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
};
|
||||||
|
mUserTextView.setOnClickListener(onUserClick);
|
||||||
|
mUserInstanceTextView.setOnClickListener(onUserClick);
|
||||||
|
|
||||||
mAuthorFlairTextView.setOnClickListener(view -> mUserTextView.performClick());
|
mAuthorFlairTextView.setOnClickListener(view -> mUserTextView.performClick());
|
||||||
|
|
||||||
@@ -1175,6 +1355,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
|
|
||||||
if (previousVoteType != 1) {
|
if (previousVoteType != 1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
@@ -1191,8 +1372,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote){
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||||
@@ -1212,8 +1400,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
|
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote){
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||||
@@ -1224,8 +1419,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
mPost.setVoteType(previousVoteType);
|
mPost.setVoteType(previousVoteType);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote){
|
||||||
mPost.getScore() + previousVoteType));
|
int upvotes = (previousVoteType == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (previousVoteType == -1) ? mPost.getDownvotes() - 1 : Math.max(mPost.getDownvotes(),0);;
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + previousVoteType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
@@ -1255,24 +1457,36 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
if (previousVoteType != -1) {
|
if (previousVoteType != -1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_DOWNVOTE);
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpvoteAndDownvote){
|
||||||
|
mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_UNVOTE);
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
|
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote){
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||||
@@ -1283,17 +1497,29 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
if(mSeperateUpvoteAndDownvote) {
|
||||||
|
mDownvoteTextView.setTextColor(mDownvotedColor);
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
|
mDownvoteTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote){
|
||||||
mPost.getScore() + mPost.getVoteType()));
|
int upvotes = (mPost.getVoteType() == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (mPost.getVoteType() == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);;
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + mPost.getVoteType()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
|
||||||
@@ -1304,8 +1530,15 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
|
||||||
mPost.setVoteType(previousVoteType);
|
mPost.setVoteType(previousVoteType);
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if(mSeperateUpvoteAndDownvote) {
|
||||||
mPost.getScore() + previousVoteType));
|
int upvotes = (previousVoteType == 1) ? mPost.getUpvotes() + 1 : mPost.getUpvotes();
|
||||||
|
int downvotes = (previousVoteType == -1) ? mPost.getDownvotes() + 1 : Math.max(mPost.getDownvotes(),0);
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
|
mDownvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
|
} else {
|
||||||
|
mScoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
|
mPost.getScore() + previousVoteType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
mUpvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
|
||||||
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
mDownvoteButton.setColorFilter(previousDownvoteButtonColorFilter);
|
||||||
@@ -1354,7 +1587,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
SavePost savePost = new SavePost();
|
SavePost savePost = new SavePost();
|
||||||
if (mPost.isSaved()) {
|
if (mPost.isSaved()) {
|
||||||
mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
savePost.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getId(),
|
savePost.unsaveThing(mRetrofit, mAccessToken, mPost.getId(),
|
||||||
new SaveThing.SaveThingListener() {
|
new SaveThing.SaveThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
@@ -1428,11 +1661,18 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
constraintSet.clear(mUpvoteButton.getId(), ConstraintSet.START);
|
constraintSet.clear(mUpvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.clear(mScoreTextView.getId(), ConstraintSet.START);
|
constraintSet.clear(mScoreTextView.getId(), ConstraintSet.START);
|
||||||
constraintSet.clear(mDownvoteButton.getId(), ConstraintSet.START);
|
constraintSet.clear(mDownvoteButton.getId(), ConstraintSet.START);
|
||||||
|
constraintSet.clear(mDownvoteTextView.getId(), ConstraintSet.START);
|
||||||
constraintSet.clear(mSaveButton.getId(), ConstraintSet.END);
|
constraintSet.clear(mSaveButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.clear(mShareButton.getId(), ConstraintSet.END);
|
constraintSet.clear(mShareButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.connect(mUpvoteButton.getId(), ConstraintSet.END, mScoreTextView.getId(), ConstraintSet.START);
|
constraintSet.connect(mUpvoteButton.getId(), ConstraintSet.END, mScoreTextView.getId(), ConstraintSet.START);
|
||||||
constraintSet.connect(mScoreTextView.getId(), ConstraintSet.END, mDownvoteButton.getId(), ConstraintSet.START);
|
constraintSet.connect(mScoreTextView.getId(), ConstraintSet.END, mDownvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
if (!mSeperateUpvoteAndDownvote) {
|
||||||
|
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||||
|
} else {
|
||||||
|
constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, mDownvoteTextView.getId(), ConstraintSet.START);
|
||||||
|
constraintSet.connect(mDownvoteTextView.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||||
|
}
|
||||||
|
|
||||||
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.START, mSaveButton.getId(), ConstraintSet.END);
|
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.START, mSaveButton.getId(), ConstraintSet.END);
|
||||||
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, mUpvoteButton.getId(), ConstraintSet.START);
|
constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, mUpvoteButton.getId(), ConstraintSet.START);
|
||||||
constraintSet.connect(mSaveButton.getId(), ConstraintSet.START, mShareButton.getId(), ConstraintSet.END);
|
constraintSet.connect(mSaveButton.getId(), ConstraintSet.START, mShareButton.getId(), ConstraintSet.END);
|
||||||
@@ -1500,8 +1740,14 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.subreddit_text_view_item_post_detail_video_autoplay)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_video_autoplay)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.user_text_view_item_post_detail_video_autoplay)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_video_autoplay)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
|
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.author_flair_text_view_item_post_detail_video_autoplay)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.post_time_text_view_item_post_detail_video_autoplay)
|
||||||
@@ -1552,6 +1798,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_video_autoplay)
|
@BindView(R.id.score_text_view_item_post_detail_video_autoplay)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_video_autoplay)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_video_autoplay)
|
@BindView(R.id.minus_button_item_post_detail_video_autoplay)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_video_autoplay)
|
@BindView(R.id.comments_count_item_post_detail_video_autoplay)
|
||||||
@@ -1573,7 +1822,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -1590,6 +1841,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -1638,8 +1890,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
} else {
|
} else {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
|
||||||
}
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
if (helper != null) {
|
if (helper != null) {
|
||||||
@@ -1807,8 +2059,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.subreddit_text_view_item_post_detail_video_and_gif_preview)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_video_and_gif_preview)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.user_text_view_item_post_detail_video_and_gif_preview)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_video_and_gif_preview)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.author_flair_text_view_item_post_detail_video_and_gif_preview)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.post_time_text_view_item_post_detail_video_and_gif_preview)
|
||||||
@@ -1851,6 +2107,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.score_text_view_item_post_detail_video_and_gif_preview)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_video_and_gif_preview)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.minus_button_item_post_detail_video_and_gif_preview)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_video_and_gif_preview)
|
@BindView(R.id.comments_count_item_post_detail_video_and_gif_preview)
|
||||||
@@ -1865,7 +2124,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -1882,6 +2143,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -1911,8 +2173,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
||||||
} else {
|
} else {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
@@ -1937,8 +2198,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.subreddit_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.user_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.author_flair_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.post_time_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
@@ -1981,6 +2246,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.score_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_image_and_gif_autoplay)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.minus_button_item_post_detail_image_and_gif_autoplay)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_image_and_gif_autoplay)
|
@BindView(R.id.comments_count_item_post_detail_image_and_gif_autoplay)
|
||||||
@@ -1995,7 +2263,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -2012,6 +2282,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -2050,8 +2321,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_link)
|
@BindView(R.id.subreddit_text_view_item_post_detail_link)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_link)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_link)
|
@BindView(R.id.user_text_view_item_post_detail_link)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_link)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_link)
|
@BindView(R.id.author_flair_text_view_item_post_detail_link)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_link)
|
@BindView(R.id.post_time_text_view_item_post_detail_link)
|
||||||
@@ -2096,6 +2371,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_link)
|
@BindView(R.id.score_text_view_item_post_detail_link)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_link)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_link)
|
@BindView(R.id.minus_button_item_post_detail_link)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_link)
|
@BindView(R.id.comments_count_item_post_detail_link)
|
||||||
@@ -2110,7 +2388,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -2127,6 +2407,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -2154,8 +2435,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_no_preview_link)
|
@BindView(R.id.subreddit_text_view_item_post_detail_no_preview_link)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_no_preview_link)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_no_preview_link)
|
@BindView(R.id.user_text_view_item_post_detail_no_preview_link)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_no_preview_link)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_no_preview_link)
|
@BindView(R.id.author_flair_text_view_item_post_detail_no_preview_link)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_no_preview_link)
|
@BindView(R.id.post_time_text_view_item_post_detail_no_preview_link)
|
||||||
@@ -2192,6 +2477,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_no_preview_link)
|
@BindView(R.id.score_text_view_item_post_detail_no_preview_link)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_no_preview_link)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
|
|
||||||
@BindView(R.id.minus_button_item_post_detail_no_preview_link)
|
@BindView(R.id.minus_button_item_post_detail_no_preview_link)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_no_preview_link)
|
@BindView(R.id.comments_count_item_post_detail_no_preview_link)
|
||||||
@@ -2206,7 +2494,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -2223,6 +2513,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -2250,7 +2541,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
intent.putExtra(ViewVideoActivity.EXTRA_STREAMABLE_SHORT_CODE, mPost.getStreamableShortCode());
|
||||||
} else {
|
} else {
|
||||||
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
intent.setData(Uri.parse(mPost.getVideoUrl()));
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
}
|
}
|
||||||
@@ -2295,8 +2586,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_gallery)
|
@BindView(R.id.subreddit_text_view_item_post_detail_gallery)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_gallery)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_gallery)
|
@BindView(R.id.user_text_view_item_post_detail_gallery)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_gallery)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_gallery)
|
@BindView(R.id.author_flair_text_view_item_post_detail_gallery)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_gallery)
|
@BindView(R.id.post_time_text_view_item_post_detail_gallery)
|
||||||
@@ -2337,6 +2632,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_gallery)
|
@BindView(R.id.score_text_view_item_post_detail_gallery)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_gallery)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_gallery)
|
@BindView(R.id.minus_button_item_post_detail_gallery)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_gallery)
|
@BindView(R.id.comments_count_item_post_detail_gallery)
|
||||||
@@ -2352,7 +2649,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -2369,6 +2668,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
@@ -2490,8 +2790,12 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
AspectRatioGifImageView mIconGifImageView;
|
AspectRatioGifImageView mIconGifImageView;
|
||||||
@BindView(R.id.subreddit_text_view_item_post_detail_text)
|
@BindView(R.id.subreddit_text_view_item_post_detail_text)
|
||||||
TextView mSubredditTextView;
|
TextView mSubredditTextView;
|
||||||
|
@BindView(R.id.community_instance_text_view_item_post_detail_text)
|
||||||
|
TextView mCommunityInstanceTextView;
|
||||||
@BindView(R.id.user_text_view_item_post_detail_text)
|
@BindView(R.id.user_text_view_item_post_detail_text)
|
||||||
TextView mUserTextView;
|
TextView mUserTextView;
|
||||||
|
@BindView(R.id.user_instance_text_view_item_post_detail_text)
|
||||||
|
TextView mUserInstanceTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_detail_text)
|
@BindView(R.id.author_flair_text_view_item_post_detail_text)
|
||||||
TextView mAuthorFlairTextView;
|
TextView mAuthorFlairTextView;
|
||||||
@BindView(R.id.post_time_text_view_item_post_detail_text)
|
@BindView(R.id.post_time_text_view_item_post_detail_text)
|
||||||
@@ -2524,6 +2828,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ImageView mUpvoteButton;
|
ImageView mUpvoteButton;
|
||||||
@BindView(R.id.score_text_view_item_post_detail_text)
|
@BindView(R.id.score_text_view_item_post_detail_text)
|
||||||
TextView mScoreTextView;
|
TextView mScoreTextView;
|
||||||
|
|
||||||
|
@BindView(R.id.downvote_text_view_item_post_detail_text)
|
||||||
|
TextView mDownvoteTextView;
|
||||||
@BindView(R.id.minus_button_item_post_detail_text)
|
@BindView(R.id.minus_button_item_post_detail_text)
|
||||||
ImageView mDownvoteButton;
|
ImageView mDownvoteButton;
|
||||||
@BindView(R.id.comments_count_item_post_detail_text)
|
@BindView(R.id.comments_count_item_post_detail_text)
|
||||||
@@ -2538,7 +2845,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
setBaseView(mIconGifImageView,
|
setBaseView(mIconGifImageView,
|
||||||
mSubredditTextView,
|
mSubredditTextView,
|
||||||
|
mCommunityInstanceTextView,
|
||||||
mUserTextView,
|
mUserTextView,
|
||||||
|
mUserInstanceTextView,
|
||||||
mAuthorFlairTextView,
|
mAuthorFlairTextView,
|
||||||
mPostTimeTextView,
|
mPostTimeTextView,
|
||||||
mTitleTextView,
|
mTitleTextView,
|
||||||
@@ -2555,6 +2864,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
mBottomConstraintLayout,
|
mBottomConstraintLayout,
|
||||||
mUpvoteButton,
|
mUpvoteButton,
|
||||||
mScoreTextView,
|
mScoreTextView,
|
||||||
|
mDownvoteTextView,
|
||||||
mDownvoteButton,
|
mDownvoteButton,
|
||||||
commentsCountTextView,
|
commentsCountTextView,
|
||||||
mSaveButton,
|
mSaveButton,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,343 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.text.util.Linkify;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.paging.PagedListAdapter;
|
||||||
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.NetworkState;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||||
|
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||||
|
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||||
|
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||||
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
|
import io.noties.markwon.Markwon;
|
||||||
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||||
|
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||||
|
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||||
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class PrivateMessageRecycleViewAdapter extends PagedListAdapter<PrivateMessage, RecyclerView.ViewHolder> {
|
||||||
|
private static final int VIEW_TYPE_DATA = 0;
|
||||||
|
private static final int VIEW_TYPE_ERROR = 1;
|
||||||
|
private static final int VIEW_TYPE_LOADING = 2;
|
||||||
|
private static final DiffUtil.ItemCallback<PrivateMessage> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
||||||
|
@Override
|
||||||
|
public boolean areItemsTheSame(@NonNull PrivateMessage message, @NonNull PrivateMessage t1) {
|
||||||
|
return message.getId() == t1.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areContentsTheSame(@NonNull PrivateMessage message, @NonNull PrivateMessage t1) {
|
||||||
|
return message.getContent().equals(t1.getContent());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private BaseActivity mActivity;
|
||||||
|
private Retrofit retrofit;
|
||||||
|
private Markwon mMarkwon;
|
||||||
|
private String mAccessToken;
|
||||||
|
|
||||||
|
private final LemmyPrivateMessageAPI lemmyPrivateMessageAPI;
|
||||||
|
private int mMessageType;
|
||||||
|
private NetworkState networkState;
|
||||||
|
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
|
||||||
|
private int mColorAccent;
|
||||||
|
private int mMessageBackgroundColor;
|
||||||
|
private int mUsernameColor;
|
||||||
|
private int mPrimaryTextColor;
|
||||||
|
private int mSecondaryTextColor;
|
||||||
|
private int mUnreadMessageBackgroundColor;
|
||||||
|
private int mColorPrimaryLightTheme;
|
||||||
|
private int mButtonTextColor;
|
||||||
|
private boolean markAllMessagesAsRead = false;
|
||||||
|
|
||||||
|
public PrivateMessageRecycleViewAdapter(BaseActivity activity, Retrofit oauthRetrofit,
|
||||||
|
CustomThemeWrapper customThemeWrapper,
|
||||||
|
String accessToken,
|
||||||
|
LemmyPrivateMessageAPI lemmyPrivateMessageAPI, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||||
|
super(DIFF_CALLBACK);
|
||||||
|
mActivity = activity;
|
||||||
|
retrofit = oauthRetrofit;
|
||||||
|
this.lemmyPrivateMessageAPI = lemmyPrivateMessageAPI;
|
||||||
|
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||||
|
|
||||||
|
mColorAccent = customThemeWrapper.getColorAccent();
|
||||||
|
mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor();
|
||||||
|
mUsernameColor = customThemeWrapper.getUsername();
|
||||||
|
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
|
int spoilerBackgroundColor = mSecondaryTextColor | 0xFF000000;
|
||||||
|
mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor();
|
||||||
|
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||||
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
|
|
||||||
|
// todo:https://github.com/Docile-Alligator/Infinity-For-Reddit/issues/1027
|
||||||
|
// add tables support and replace with MarkdownUtils#commonPostMarkwonBuilder
|
||||||
|
mMarkwon = Markwon.builder(mActivity)
|
||||||
|
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||||
|
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||||
|
}))
|
||||||
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
|
@Override
|
||||||
|
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
|
||||||
|
builder.linkResolver((view, link) -> {
|
||||||
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
|
Uri uri = Uri.parse(link);
|
||||||
|
intent.setData(uri);
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
|
||||||
|
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.usePlugin(SuperscriptPlugin.create())
|
||||||
|
.usePlugin(SpoilerParserPlugin.create(mSecondaryTextColor, spoilerBackgroundColor))
|
||||||
|
.usePlugin(RedditHeadingPlugin.create())
|
||||||
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
|
.usePlugin(MovementMethodPlugin.create(new SpoilerAwareMovementMethod()))
|
||||||
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
|
.usePlugin(GlideImagesPlugin.create(mActivity))
|
||||||
|
.build();
|
||||||
|
mAccessToken = accessToken;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
if (viewType == VIEW_TYPE_DATA) {
|
||||||
|
return new DataViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_message, parent, false));
|
||||||
|
} else if (viewType == VIEW_TYPE_ERROR) {
|
||||||
|
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
||||||
|
} else {
|
||||||
|
return new LoadingViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_loading, parent, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
if (holder instanceof DataViewHolder) {
|
||||||
|
PrivateMessage message = getItem(holder.getBindingAdapterPosition());
|
||||||
|
if (message != null) {
|
||||||
|
|
||||||
|
if (!message.getRead()) {
|
||||||
|
if (markAllMessagesAsRead) {
|
||||||
|
message.setRead(true);
|
||||||
|
} else {
|
||||||
|
holder.itemView.setBackgroundColor(
|
||||||
|
mUnreadMessageBackgroundColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
||||||
|
((DataViewHolder) holder).authorTextView.setText(message.getCreatorQualifiedName());
|
||||||
|
String subject = message.getRecipientQualifiedName();
|
||||||
|
((DataViewHolder) holder).subjectTextView.setText(subject);
|
||||||
|
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, message.getContent());
|
||||||
|
|
||||||
|
holder.itemView.setOnClickListener(view -> {
|
||||||
|
|
||||||
|
Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
|
||||||
|
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGE, message);
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
|
||||||
|
|
||||||
|
if (message.getRead()) {
|
||||||
|
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||||
|
|
||||||
|
|
||||||
|
lemmyPrivateMessageAPI.markPrivateMessageAsRead(mAccessToken, message.getId(), new LemmyPrivateMessageAPI.PrivateMessageMarkedAsReadListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrivateMessageMarkedAsReadError() {
|
||||||
|
message.setRead(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPrivateMessageMarkedAsReadSuccess() {
|
||||||
|
message.setRead(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||||
|
|
||||||
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getCreatorName());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getCreatorQualifiedName());
|
||||||
|
mActivity.startActivity(intent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemViewType(int position) {
|
||||||
|
// Reached at the end
|
||||||
|
if (hasExtraRow() && position == getItemCount() - 1) {
|
||||||
|
if (networkState.getStatus() == NetworkState.Status.LOADING) {
|
||||||
|
return VIEW_TYPE_LOADING;
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_ERROR;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return VIEW_TYPE_DATA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
if (hasExtraRow()) {
|
||||||
|
return super.getItemCount() + 1;
|
||||||
|
}
|
||||||
|
return super.getItemCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
|
super.onViewRecycled(holder);
|
||||||
|
if (holder instanceof DataViewHolder) {
|
||||||
|
((DataViewHolder) holder).itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||||
|
((DataViewHolder) holder).titleTextView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasExtraRow() {
|
||||||
|
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNetworkState(NetworkState newNetworkState) {
|
||||||
|
NetworkState previousState = this.networkState;
|
||||||
|
boolean previousExtraRow = hasExtraRow();
|
||||||
|
this.networkState = newNetworkState;
|
||||||
|
boolean newExtraRow = hasExtraRow();
|
||||||
|
if (previousExtraRow != newExtraRow) {
|
||||||
|
if (previousExtraRow) {
|
||||||
|
notifyItemRemoved(super.getItemCount());
|
||||||
|
} else {
|
||||||
|
notifyItemInserted(super.getItemCount());
|
||||||
|
}
|
||||||
|
} else if (newExtraRow && !previousState.equals(newNetworkState)) {
|
||||||
|
notifyItemChanged(getItemCount() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMessageReply(PrivateMessage newReply, int position) {
|
||||||
|
if (position >= 0 && position < super.getItemCount()) {
|
||||||
|
PrivateMessage message = getItem(position);
|
||||||
|
if (message != null) {
|
||||||
|
notifyItemChanged(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkAllMessagesAsRead(boolean markAllMessagesAsRead) {
|
||||||
|
this.markAllMessagesAsRead = markAllMessagesAsRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface RetryLoadingMoreCallback {
|
||||||
|
void retryLoadingMore();
|
||||||
|
}
|
||||||
|
|
||||||
|
class DataViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.author_text_view_item_message)
|
||||||
|
TextView authorTextView;
|
||||||
|
@BindView(R.id.subject_text_view_item_message)
|
||||||
|
TextView subjectTextView;
|
||||||
|
@BindView(R.id.title_text_view_item_message)
|
||||||
|
TextView titleTextView;
|
||||||
|
@BindView(R.id.content_custom_markwon_view_item_message)
|
||||||
|
TextView contentCustomMarkwonView;
|
||||||
|
|
||||||
|
DataViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
authorTextView.setTypeface(mActivity.typeface);
|
||||||
|
subjectTextView.setTypeface(mActivity.typeface);
|
||||||
|
titleTextView.setTypeface(mActivity.titleTypeface);
|
||||||
|
contentCustomMarkwonView.setTypeface(mActivity.contentTypeface);
|
||||||
|
}
|
||||||
|
itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||||
|
authorTextView.setTextColor(mUsernameColor);
|
||||||
|
subjectTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
titleTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
contentCustomMarkwonView.setTextColor(mSecondaryTextColor);
|
||||||
|
|
||||||
|
contentCustomMarkwonView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
|
contentCustomMarkwonView.setOnClickListener(view -> {
|
||||||
|
if (contentCustomMarkwonView.getSelectionStart() == -1 && contentCustomMarkwonView.getSelectionEnd() == -1) {
|
||||||
|
itemView.performClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.error_text_view_item_footer_error)
|
||||||
|
TextView errorTextView;
|
||||||
|
@BindView(R.id.retry_button_item_footer_error)
|
||||||
|
Button retryButton;
|
||||||
|
|
||||||
|
ErrorViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
if (mActivity.typeface != null) {
|
||||||
|
errorTextView.setTypeface(mActivity.typeface);
|
||||||
|
retryButton.setTypeface(mActivity.typeface);
|
||||||
|
}
|
||||||
|
errorTextView.setText(R.string.load_comments_failed);
|
||||||
|
errorTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
retryButton.setOnClickListener(view -> mRetryLoadingMoreCallback.retryLoadingMore());
|
||||||
|
retryButton.setBackgroundTintList(ColorStateList.valueOf(mColorPrimaryLightTheme));
|
||||||
|
retryButton.setTextColor(mButtonTextColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadingViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
@BindView(R.id.progress_bar_item_footer_loading)
|
||||||
|
ProgressBar progressBar;
|
||||||
|
|
||||||
|
LoadingViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
ButterKnife.bind(this, itemView);
|
||||||
|
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -27,34 +27,35 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
|
||||||
import io.noties.markwon.Markwon;
|
|
||||||
import io.noties.markwon.MarkwonConfiguration;
|
|
||||||
import io.noties.markwon.core.MarkwonTheme;
|
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
|
||||||
import io.noties.markwon.inlineparser.BangInlineProcessor;
|
|
||||||
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
|
||||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
|
||||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.markdown.ClickableGlideImagesPlugin;
|
||||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||||
import eu.toldi.infinityforlemmy.message.Message;
|
import eu.toldi.infinityforlemmy.privatemessage.PrivateMessage;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
|
import io.noties.markwon.Markwon;
|
||||||
|
import io.noties.markwon.MarkwonConfiguration;
|
||||||
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
|
import io.noties.markwon.image.glide.GlideImagesPlugin;
|
||||||
|
import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||||
|
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||||
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
|
||||||
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private static final int VIEW_TYPE_MESSAGE_SENT = 0;
|
private static final int VIEW_TYPE_MESSAGE_SENT = 0;
|
||||||
private static final int VIEW_TYPE_MESSAGE_RECEIVED = 1;
|
private static final int VIEW_TYPE_MESSAGE_RECEIVED = 1;
|
||||||
private Message mMessage;
|
private PrivateMessage mMessage;
|
||||||
private ViewPrivateMessagesActivity mViewPrivateMessagesActivity;
|
private ViewPrivateMessagesActivity mViewPrivateMessagesActivity;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@@ -70,7 +71,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
|
|
||||||
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity,
|
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity,
|
||||||
SharedPreferences sharedPreferences, Locale locale,
|
SharedPreferences sharedPreferences, Locale locale,
|
||||||
Message message, String accountName,
|
PrivateMessage message, String accountName,
|
||||||
CustomThemeWrapper customThemeWrapper) {
|
CustomThemeWrapper customThemeWrapper) {
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
mViewPrivateMessagesActivity = viewPrivateMessagesActivity;
|
mViewPrivateMessagesActivity = viewPrivateMessagesActivity;
|
||||||
@@ -83,7 +84,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
||||||
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
.usePlugin(MarkwonInlineParserPlugin.create(plugin -> {
|
||||||
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
plugin.excludeInlineProcessor(HtmlInlineProcessor.class);
|
||||||
plugin.excludeInlineProcessor(BangInlineProcessor.class);
|
|
||||||
}))
|
}))
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
@@ -108,6 +108,8 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
builder.linkColor(customThemeWrapper.getLinkColor());
|
builder.linkColor(customThemeWrapper.getLinkColor());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.usePlugin(GlideImagesPlugin.create(viewPrivateMessagesActivity))
|
||||||
|
.usePlugin(ClickableGlideImagesPlugin.create(viewPrivateMessagesActivity))
|
||||||
.usePlugin(SuperscriptPlugin.create())
|
.usePlugin(SuperscriptPlugin.create())
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
.usePlugin(SpoilerParserPlugin.create(commentColor, commentColor | 0xFF000000))
|
.usePlugin(SpoilerParserPlugin.create(commentColor, commentColor | 0xFF000000))
|
||||||
@@ -127,9 +129,9 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
@Override
|
@Override
|
||||||
public int getItemViewType(int position) {
|
public int getItemViewType(int position) {
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
return mMessage.getAuthor().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
return mMessage.getCreatorQualifiedName().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||||
} else {
|
} else {
|
||||||
return mMessage.getReplies().get(position - 1).getAuthor().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
return mMessage.getReplies().get(position - 1).getCreatorQualifiedName().equals(mAccountName) ? VIEW_TYPE_MESSAGE_SENT : VIEW_TYPE_MESSAGE_RECEIVED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +147,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
Message message;
|
PrivateMessage message;
|
||||||
if (holder.getBindingAdapterPosition() == 0) {
|
if (holder.getBindingAdapterPosition() == 0) {
|
||||||
message = mMessage;
|
message = mMessage;
|
||||||
} else {
|
} else {
|
||||||
@@ -153,12 +155,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
}
|
}
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
if (holder instanceof MessageViewHolder) {
|
if (holder instanceof MessageViewHolder) {
|
||||||
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getBody());
|
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getContent());
|
||||||
|
|
||||||
if (mShowElapsedTime) {
|
if (mShowElapsedTime) {
|
||||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
|
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getPublished()));
|
||||||
} else {
|
} else {
|
||||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getFormattedTime(mLocale, message.getTimeUTC(), mTimeFormatPattern));
|
((MessageViewHolder) holder).timeTextView.setText(Utils.getFormattedTime(mLocale, message.getPublished(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,26 +168,33 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
((SentMessageViewHolder) holder).messageTextView.setBackground(Utils.getTintedDrawable(mViewPrivateMessagesActivity,
|
((SentMessageViewHolder) holder).messageTextView.setBackground(Utils.getTintedDrawable(mViewPrivateMessagesActivity,
|
||||||
R.drawable.private_message_ballon, mSentMessageBackgroundColor));
|
R.drawable.private_message_ballon, mSentMessageBackgroundColor));
|
||||||
} else if (holder instanceof ReceivedMessageViewHolder) {
|
} else if (holder instanceof ReceivedMessageViewHolder) {
|
||||||
mViewPrivateMessagesActivity.fetchUserAvatar(message.getAuthor(), userAvatarUrl -> {
|
if (!message.getCreatorAvatar().equals("")) {
|
||||||
if (userAvatarUrl == null || userAvatarUrl.equals("")) {
|
mGlide.load(message.getCreatorAvatar())
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
} else {
|
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||||
mGlide.load(userAvatarUrl)
|
} else {
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
mViewPrivateMessagesActivity.fetchUserAvatar(message.getCreatorQualifiedName(), userAvatarUrl -> {
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
if (userAvatarUrl == null || userAvatarUrl.equals("")) {
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
}
|
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||||
});
|
} else {
|
||||||
|
mGlide.load(userAvatarUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(((ReceivedMessageViewHolder) holder).userAvatarImageView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> {
|
((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> {
|
||||||
if (message.isAuthorDeleted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getCreatorName());
|
||||||
|
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getCreatorQualifiedName());
|
||||||
mViewPrivateMessagesActivity.startActivity(intent);
|
mViewPrivateMessagesActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,12 +216,12 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(Message message) {
|
public void setMessage(PrivateMessage message) {
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addReply(Message reply) {
|
public void addReply(PrivateMessage reply) {
|
||||||
int currentSize = getItemCount();
|
int currentSize = getItemCount();
|
||||||
|
|
||||||
if (mMessage != null) {
|
if (mMessage != null) {
|
||||||
@@ -273,7 +282,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
copyImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
copyImageView.setColorFilter(mSecondaryTextColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
copyImageView.setOnClickListener(view -> {
|
copyImageView.setOnClickListener(view -> {
|
||||||
Message message;
|
PrivateMessage message;
|
||||||
if (getBindingAdapterPosition() == 0) {
|
if (getBindingAdapterPosition() == 0) {
|
||||||
message = mMessage;
|
message = mMessage;
|
||||||
} else {
|
} else {
|
||||||
@@ -282,7 +291,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
ClipboardManager clipboard = (ClipboardManager) mViewPrivateMessagesActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) mViewPrivateMessagesActivity.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
if (clipboard != null) {
|
if (clipboard != null) {
|
||||||
ClipData clip = ClipData.newPlainText("simple text", message.getBody());
|
ClipData clip = ClipData.newPlainText("simple text", message.getContent());
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
if (android.os.Build.VERSION.SDK_INT < 33) {
|
if (android.os.Build.VERSION.SDK_INT < 33) {
|
||||||
Toast.makeText(mViewPrivateMessagesActivity, R.string.copy_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mViewPrivateMessagesActivity, R.string.copy_success, Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
|||||||
if (isMultiSelection) {
|
if (isMultiSelection) {
|
||||||
((DataViewHolder) holder).checkBox.performClick();
|
((DataViewHolder) holder).checkBox.performClick();
|
||||||
} else {
|
} else {
|
||||||
callback.subredditSelected(subredditData.getName(), LemmyUtils.actorID2FullName(subredditData.getActorId()), subredditData.getIconUrl());
|
callback.subredditSelected(subredditData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
|||||||
public interface Callback {
|
public interface Callback {
|
||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
|
|
||||||
void subredditSelected(String subredditName, String communityFullName,String iconUrl);
|
void subredditSelected(SubredditData communityData);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataViewHolder extends RecyclerView.ViewHolder {
|
class DataViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|||||||
@@ -149,39 +149,17 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
|
|
||||||
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
||||||
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
|
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(R.string.all_communities);
|
||||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null, null, false));
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
|
||||||
return;
|
return;
|
||||||
} else if (itemClickListener != null && !hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 0) {
|
|
||||||
name = username;
|
|
||||||
iconUrl = userIconUrl;
|
|
||||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true));
|
|
||||||
} else if (hasClearSelectionRow && viewHolder.getBindingAdapterPosition() == 1) {
|
|
||||||
name = username;
|
|
||||||
iconUrl = userIconUrl;
|
|
||||||
if (itemClickListener != null) {
|
|
||||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, true));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int offset;
|
int offset = hasClearSelectionRow ? 1 : 0;
|
||||||
if (itemClickListener != null) {
|
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||||
if (hasClearSelectionRow) {
|
|
||||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + 4 : 2;
|
|
||||||
} else {
|
|
||||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + 3 : 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + 2 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||||
fullname = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
|
fullname = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
|
||||||
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||||
|
|
||||||
if (itemClickListener != null) {
|
if (itemClickListener != null) {
|
||||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false));
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,11 +197,12 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
} else {
|
} else {
|
||||||
offset = 1;
|
offset = 1;
|
||||||
}
|
}
|
||||||
|
SubscribedSubredditData communityData = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
|
||||||
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
|
||||||
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
|
||||||
|
|
||||||
if (itemClickListener != null) {
|
if (itemClickListener != null) {
|
||||||
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(name, iconUrl, false));
|
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.itemView.setOnClickListener(view -> {
|
viewHolder.itemView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
@@ -250,26 +229,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (mSubscribedSubredditData != null) {
|
if (mSubscribedSubredditData != null) {
|
||||||
if(mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) {
|
|
||||||
if (itemClickListener != null) {
|
|
||||||
if (hasClearSelectionRow) {
|
|
||||||
return mSubscribedSubredditData.size() > 0 ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 4 : 0;
|
|
||||||
} else {
|
|
||||||
return mSubscribedSubredditData.size() > 0 ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 3 : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mSubscribedSubredditData.size() > 0 ?
|
|
||||||
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 2 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemClickListener != null) {
|
if (itemClickListener != null) {
|
||||||
if (hasClearSelectionRow) {
|
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
|
||||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 2 : 0;
|
|
||||||
} else {
|
|
||||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 1 : 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mSubscribedSubredditData.size();
|
return mSubscribedSubredditData.size();
|
||||||
@@ -347,7 +309,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface ItemClickListener {
|
public interface ItemClickListener {
|
||||||
void onClick(String name, String iconUrl, boolean subredditIsUser);
|
void onClick(SubscribedSubredditData subredditData);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SubredditViewHolder extends RecyclerView.ViewHolder {
|
class SubredditViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void isNotSubscribed() {
|
public void isNotSubscribed() {
|
||||||
((DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE);
|
|
||||||
((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
|
((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> {
|
||||||
UserFollowing.followUser(oauthRetrofit, retrofit,
|
UserFollowing.followUser(oauthRetrofit, retrofit,
|
||||||
accessToken, userData.getName(), accountName, redditDataRoomDatabase,
|
accessToken, userData.getName(), accountName, redditDataRoomDatabase,
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
||||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||||
private static final int ACCOUNT_SECTION_ITEMS = 5;
|
private static final int ACCOUNT_SECTION_ITEMS = 4;
|
||||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 3;
|
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 1;
|
||||||
|
|
||||||
private BaseActivity baseActivity;
|
private BaseActivity baseActivity;
|
||||||
private int inboxCount;
|
private int inboxCount;
|
||||||
@@ -101,10 +101,6 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
stringId = R.string.multi_reddit;
|
|
||||||
drawableId = R.drawable.ic_multi_reddit_24dp;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
setOnClickListener = false;
|
setOnClickListener = false;
|
||||||
if (inboxCount > 0) {
|
if (inboxCount > 0) {
|
||||||
((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
|
((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
|
||||||
@@ -118,23 +114,21 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
stringId = R.string.history;
|
stringId = R.string.account_saved_thing_activity_label;
|
||||||
drawableId = R.drawable.ic_history_24dp;
|
drawableId = R.drawable.ic_outline_bookmarks_24dp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
stringId = R.string.subscriptions;
|
stringId = R.string.subscriptions;
|
||||||
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
stringId = R.string.multi_reddit;
|
|
||||||
drawableId = R.drawable.ic_multi_reddit_24dp;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
stringId = R.string.history;
|
stringId = R.string.anonymous_account_instance;
|
||||||
drawableId = R.drawable.ic_history_24dp;
|
drawableId = R.drawable.ic_account_circle_24dp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
private Resources resources;
|
private Resources resources;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
private String accountName;
|
private String accountName;
|
||||||
|
private String accountQualifiedName;
|
||||||
private String profileImageUrl;
|
private String profileImageUrl;
|
||||||
private String bannerImageUrl;
|
private String bannerImageUrl;
|
||||||
private int karma;
|
private int karma;
|
||||||
@@ -50,7 +51,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
private boolean hideKarma;
|
private boolean hideKarma;
|
||||||
|
|
||||||
public HeaderSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
public HeaderSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||||
RequestManager glide, String accountName,
|
RequestManager glide, String accountName, String accountQualifiedName,
|
||||||
SharedPreferences sharedPreferences,
|
SharedPreferences sharedPreferences,
|
||||||
SharedPreferences navigationDrawerSharedPreferences,
|
SharedPreferences navigationDrawerSharedPreferences,
|
||||||
SharedPreferences securitySharedPreferences,
|
SharedPreferences securitySharedPreferences,
|
||||||
@@ -62,6 +63,7 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
this.accountName = accountName;
|
this.accountName = accountName;
|
||||||
isLoggedIn = accountName != null;
|
isLoggedIn = accountName != null;
|
||||||
this.pageToggle = pageToggle;
|
this.pageToggle = pageToggle;
|
||||||
|
this.accountQualifiedName = accountQualifiedName;
|
||||||
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
|
requireAuthToAccountSection = securitySharedPreferences.getBoolean(SharedPreferencesUtils.REQUIRE_AUTHENTICATION_TO_GO_TO_ACCOUNT_SECTION_IN_NAVIGATION_DRAWER, false);
|
||||||
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
showAvatarOnTheRightInTheNavigationDrawer = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
||||||
showAvatarOnTheRightInTheNavigationDrawer = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
showAvatarOnTheRightInTheNavigationDrawer = navigationDrawerSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_AVATAR_ON_THE_RIGHT, false);
|
||||||
@@ -86,15 +88,11 @@ public class HeaderSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
}
|
}
|
||||||
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
|
((NavHeaderViewHolder) holder).profileImageView.setLayoutParams(params);
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
if (hideKarma) {
|
|
||||||
int karmaTextHeight = ((NavHeaderViewHolder) holder).karmaTextView.getHeight();
|
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
|
||||||
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.GONE);
|
((NavHeaderViewHolder) holder).karmaTextView.setText(accountQualifiedName);
|
||||||
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(karmaTextHeight / 2);
|
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
|
||||||
} else {
|
|
||||||
((NavHeaderViewHolder) holder).karmaTextView.setVisibility(View.VISIBLE);
|
|
||||||
((NavHeaderViewHolder) holder).karmaTextView.setText(baseActivity.getString(R.string.karma_info, karma));
|
|
||||||
((NavHeaderViewHolder) holder).accountNameTextView.setTranslationY(0);
|
|
||||||
}
|
|
||||||
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
|
((NavHeaderViewHolder) holder).accountNameTextView.setText(accountName);
|
||||||
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
if (profileImageUrl != null && !profileImageUrl.equals("")) {
|
||||||
glide.load(profileImageUrl)
|
glide.load(profileImageUrl)
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
|||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class LemmySectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
||||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||||
private static final int REDDIT_SECTION_ITEMS = 2;
|
private static final int LEMMY_SECTION_ITEMS = 2;
|
||||||
|
|
||||||
|
private static final int LEMMY_SECTION_ANONYMOUS_ITEMS = 1;
|
||||||
private final boolean isLoggedIn;
|
private final boolean isLoggedIn;
|
||||||
|
|
||||||
private BaseActivity baseActivity;
|
private BaseActivity baseActivity;
|
||||||
@@ -32,9 +34,9 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
private boolean collapseRedditSection;
|
private boolean collapseRedditSection;
|
||||||
private NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener;
|
private NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener;
|
||||||
|
|
||||||
public RedditSectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
public LemmySectionRecyclerViewAdapter(BaseActivity baseActivity, CustomThemeWrapper customThemeWrapper,
|
||||||
SharedPreferences navigationDrawerSharedPreferences,
|
SharedPreferences navigationDrawerSharedPreferences,
|
||||||
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener, boolean isLoggedIn) {
|
NavigationDrawerRecyclerViewMergedAdapter.ItemClickListener itemClickListener, boolean isLoggedIn) {
|
||||||
this.baseActivity = baseActivity;
|
this.baseActivity = baseActivity;
|
||||||
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
@@ -74,10 +76,10 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
if (collapseRedditSection) {
|
if (collapseRedditSection) {
|
||||||
collapseRedditSection = !collapseRedditSection;
|
collapseRedditSection = !collapseRedditSection;
|
||||||
notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS);
|
notifyItemRangeInserted(holder.getBindingAdapterPosition() + 1, isLoggedIn ? LEMMY_SECTION_ITEMS : LEMMY_SECTION_ANONYMOUS_ITEMS);
|
||||||
} else {
|
} else {
|
||||||
collapseRedditSection = !collapseRedditSection;
|
collapseRedditSection = !collapseRedditSection;
|
||||||
notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, REDDIT_SECTION_ITEMS);
|
notifyItemRangeRemoved(holder.getBindingAdapterPosition() + 1, isLoggedIn ? LEMMY_SECTION_ITEMS : LEMMY_SECTION_ANONYMOUS_ITEMS);
|
||||||
}
|
}
|
||||||
notifyItemChanged(holder.getBindingAdapterPosition());
|
notifyItemChanged(holder.getBindingAdapterPosition());
|
||||||
});
|
});
|
||||||
@@ -87,12 +89,13 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 1:
|
case 1:
|
||||||
stringId = R.string.trending;
|
stringId = R.string.instance_info;
|
||||||
drawableId = R.drawable.ic_trending_24dp;
|
drawableId = R.drawable.ic_baseline_info_24;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
stringId = R.string.anonymous_account_instance;
|
stringId = R.string.blocks;
|
||||||
drawableId = R.drawable.ic_account_circle_24dp;
|
drawableId = R.drawable.ic_outline_lock_24dp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
|
((MenuItemViewHolder) holder).menuTextView.setText(stringId);
|
||||||
@@ -104,7 +107,7 @@ public class RedditSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recyc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return isLoggedIn ? (REDDIT_SECTION_ITEMS + 1) - 1 : collapseRedditSection ? 1 : REDDIT_SECTION_ITEMS + 1;
|
return !collapseRedditSection ? (isLoggedIn ? LEMMY_SECTION_ITEMS + 1 : LEMMY_SECTION_ANONYMOUS_ITEMS + 1) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
|
class MenuGroupTitleViewHolder extends RecyclerView.ViewHolder {
|
||||||
@@ -17,12 +17,11 @@ import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
|||||||
public class NavigationDrawerRecyclerViewMergedAdapter {
|
public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||||
private HeaderSectionRecyclerViewAdapter headerSectionRecyclerViewAdapter;
|
private HeaderSectionRecyclerViewAdapter headerSectionRecyclerViewAdapter;
|
||||||
private AccountSectionRecyclerViewAdapter accountSectionRecyclerViewAdapter;
|
private AccountSectionRecyclerViewAdapter accountSectionRecyclerViewAdapter;
|
||||||
private RedditSectionRecyclerViewAdapter redditSectionRecyclerViewAdapter;
|
|
||||||
private PostSectionRecyclerViewAdapter postSectionRecyclerViewAdapter;
|
|
||||||
private PreferenceSectionRecyclerViewAdapter preferenceSectionRecyclerViewAdapter;
|
private PreferenceSectionRecyclerViewAdapter preferenceSectionRecyclerViewAdapter;
|
||||||
private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter;
|
private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter;
|
||||||
private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter;
|
private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter;
|
||||||
private AccountManagementSectionRecyclerViewAdapter accountManagementSectionRecyclerViewAdapter;
|
private AccountManagementSectionRecyclerViewAdapter accountManagementSectionRecyclerViewAdapter;
|
||||||
|
private LemmySectionRecyclerViewAdapter lemmySectionRecyclerViewAdapter;
|
||||||
private ConcatAdapter mainPageConcatAdapter;
|
private ConcatAdapter mainPageConcatAdapter;
|
||||||
|
|
||||||
public NavigationDrawerRecyclerViewMergedAdapter(BaseActivity baseActivity, SharedPreferences sharedPreferences,
|
public NavigationDrawerRecyclerViewMergedAdapter(BaseActivity baseActivity, SharedPreferences sharedPreferences,
|
||||||
@@ -30,12 +29,12 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
|||||||
SharedPreferences navigationDrawerSharedPreferences,
|
SharedPreferences navigationDrawerSharedPreferences,
|
||||||
SharedPreferences securitySharedPreferences,
|
SharedPreferences securitySharedPreferences,
|
||||||
CustomThemeWrapper customThemeWrapper,
|
CustomThemeWrapper customThemeWrapper,
|
||||||
String accountName,
|
String accountName, String accountQualifiedName,
|
||||||
ItemClickListener itemClickListener) {
|
ItemClickListener itemClickListener) {
|
||||||
RequestManager glide = Glide.with(baseActivity);
|
RequestManager glide = Glide.with(baseActivity);
|
||||||
|
|
||||||
headerSectionRecyclerViewAdapter = new HeaderSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
headerSectionRecyclerViewAdapter = new HeaderSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||||
glide, accountName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
|
glide, accountName, accountQualifiedName, sharedPreferences, navigationDrawerSharedPreferences, securitySharedPreferences,
|
||||||
new HeaderSectionRecyclerViewAdapter.PageToggle() {
|
new HeaderSectionRecyclerViewAdapter.PageToggle() {
|
||||||
@Override
|
@Override
|
||||||
public void openAccountSection() {
|
public void openAccountSection() {
|
||||||
@@ -49,10 +48,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
|||||||
});
|
});
|
||||||
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
||||||
redditSectionRecyclerViewAdapter = new RedditSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
|
||||||
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
|
|
||||||
postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
|
||||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
|
||||||
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||||
accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener);
|
accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener);
|
||||||
favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter(
|
favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter(
|
||||||
@@ -61,12 +56,13 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
|||||||
customThemeWrapper, navigationDrawerSharedPreferences, itemClickListener);
|
customThemeWrapper, navigationDrawerSharedPreferences, itemClickListener);
|
||||||
accountManagementSectionRecyclerViewAdapter = new AccountManagementSectionRecyclerViewAdapter(baseActivity,
|
accountManagementSectionRecyclerViewAdapter = new AccountManagementSectionRecyclerViewAdapter(baseActivity,
|
||||||
customThemeWrapper, glide, accountName != null, itemClickListener);
|
customThemeWrapper, glide, accountName != null, itemClickListener);
|
||||||
|
lemmySectionRecyclerViewAdapter = new LemmySectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||||
|
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
|
||||||
|
|
||||||
mainPageConcatAdapter = new ConcatAdapter(
|
mainPageConcatAdapter = new ConcatAdapter(
|
||||||
headerSectionRecyclerViewAdapter,
|
headerSectionRecyclerViewAdapter,
|
||||||
accountSectionRecyclerViewAdapter,
|
accountSectionRecyclerViewAdapter,
|
||||||
redditSectionRecyclerViewAdapter,
|
lemmySectionRecyclerViewAdapter,
|
||||||
postSectionRecyclerViewAdapter,
|
|
||||||
preferenceSectionRecyclerViewAdapter,
|
preferenceSectionRecyclerViewAdapter,
|
||||||
favoriteSubscribedSubredditsSectionRecyclerViewAdapter,
|
favoriteSubscribedSubredditsSectionRecyclerViewAdapter,
|
||||||
subscribedSubredditsRecyclerViewAdapter);
|
subscribedSubredditsRecyclerViewAdapter);
|
||||||
@@ -78,8 +74,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
|||||||
|
|
||||||
private void openAccountSection() {
|
private void openAccountSection() {
|
||||||
mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.removeAdapter(redditSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(lemmySectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.removeAdapter(postSectionRecyclerViewAdapter);
|
|
||||||
mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||||
@@ -91,8 +86,7 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
|||||||
mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter);
|
||||||
|
|
||||||
mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.addAdapter(redditSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.addAdapter(lemmySectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.addAdapter(postSectionRecyclerViewAdapter);
|
|
||||||
mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||||
mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter);
|
mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||||
|
|||||||
@@ -1,15 +1,34 @@
|
|||||||
package eu.toldi.infinityforlemmy.apis;
|
package eu.toldi.infinityforlemmy.apis;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
||||||
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.AuthDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.BlockCommunityDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.CommentDTO;
|
import eu.toldi.infinityforlemmy.dto.CommentDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
|
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.DeletePostDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.PrivateMessageDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.PrivateMessageReadDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.PrivateMessageReportDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.PrivateMessageUpdateDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.ReadMessageDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.ReportCommentDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.ReportPostDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.dto.UserBlockDTO;
|
||||||
|
import eu.toldi.infinityforlemmy.message.MessageCount;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@@ -31,12 +50,56 @@ public interface LemmyAPI {
|
|||||||
@GET("api/v3/user")
|
@GET("api/v3/user")
|
||||||
Call<String> userInfo(@Query("username") String username, @Query("auth") String access_token);
|
Call<String> userInfo(@Query("username") String username, @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/user/block")
|
||||||
|
Call<String> userBlock(@Body UserBlockDTO params);
|
||||||
|
|
||||||
|
@GET("api/v3/user/mention")
|
||||||
|
Call<String> userMentions(@Query("sort") String sort, @Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@GET("api/v3/user/replies")
|
||||||
|
Call<String> userReplies(@Query("sort") String sort, @Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@GET("api/v3/private_message/list")
|
||||||
|
Call<String> privateMessageList(@Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@GET("api/v3/user/unread_count")
|
||||||
|
Call<MessageCount> userUnreadCount(@NonNull @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/user/mention/mark_as_read")
|
||||||
|
Call<String> userMentionMarkAsRead(@Body ReadMessageDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/comment/mark_as_read")
|
||||||
|
Call<String> commentMarkAsRead(@Body ReadCommentDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/user/mark_all_as_read")
|
||||||
|
Call<String> userMarkAllAsRead(@Body AuthDTO params);
|
||||||
|
|
||||||
@GET("api/v3/community")
|
@GET("api/v3/community")
|
||||||
Call<String> communityInfo(@Query("name") String name, @Query("auth") String access_token);
|
Call<String> communityInfo(@Query("name") String name, @Query("auth") String access_token);
|
||||||
|
|
||||||
@GET("api/v3/post")
|
@GET("api/v3/post")
|
||||||
Call<String> postInfo(@Query("id") Integer postID, @Query("comment_id") Integer comment_id, @Query("auth") String access_token);
|
Call<String> postInfo(@Query("id") Integer postID, @Query("comment_id") Integer comment_id, @Query("auth") String access_token);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/post")
|
||||||
|
Call<String> postCreate(@Body SubmitPostDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/post/report")
|
||||||
|
Call<String> postReport(@Body ReportPostDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@PUT("api/v3/post")
|
||||||
|
Call<String> postUpdate(@Body EditPostDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/post/delete")
|
||||||
|
Call<String> postDelete(@Body DeletePostDTO params);
|
||||||
|
|
||||||
@GET("api/v3/user")
|
@GET("api/v3/user")
|
||||||
ListenableFuture<Response<String>> getUserPosts(
|
ListenableFuture<Response<String>> getUserPosts(
|
||||||
@Query("username") String username,
|
@Query("username") String username,
|
||||||
@@ -85,14 +148,26 @@ public interface LemmyAPI {
|
|||||||
@POST("api/v3/comment/like")
|
@POST("api/v3/comment/like")
|
||||||
Call<String> commentLike(@Body CommentVoteDTO params);
|
Call<String> commentLike(@Body CommentVoteDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/comment/report")
|
||||||
|
Call<String> commentReport(@Body ReportCommentDTO params);
|
||||||
|
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@POST("api/v3/community/follow")
|
@POST("api/v3/community/follow")
|
||||||
Call<String> communityFollow(@Body FollowCommunityDTO params);
|
Call<String> communityFollow(@Body FollowCommunityDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/community/block")
|
||||||
|
Call<String> communityBlock(@Body BlockCommunityDTO params);
|
||||||
|
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@PUT("api/v3/post/save")
|
@PUT("api/v3/post/save")
|
||||||
Call<String> postSave(@Body SavePostDTO params);
|
Call<String> postSave(@Body SavePostDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/post/mark_as_read")
|
||||||
|
Call<String> postRead(@Body ReadPostDTO params);
|
||||||
|
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@PUT("api/v3/comment/save")
|
@PUT("api/v3/comment/save")
|
||||||
Call<String> commentSave(@Body SaveCommentDTO params);
|
Call<String> commentSave(@Body SaveCommentDTO params);
|
||||||
@@ -144,6 +219,10 @@ public interface LemmyAPI {
|
|||||||
@POST("api/v3/comment")
|
@POST("api/v3/comment")
|
||||||
Call<String> postComment(@Body CommentDTO params);
|
Call<String> postComment(@Body CommentDTO params);
|
||||||
|
|
||||||
|
@Headers("Content-Type: application/json")
|
||||||
|
@POST("api/v3/comment/delete")
|
||||||
|
Call<String> commentDelete(@Body DeleteCommentDTO params);
|
||||||
|
|
||||||
@Headers("Content-Type: application/json")
|
@Headers("Content-Type: application/json")
|
||||||
@PUT("api/v3/comment")
|
@PUT("api/v3/comment")
|
||||||
Call<String> commentEdit(@Body EditCommentDTO params);
|
Call<String> commentEdit(@Body EditCommentDTO params);
|
||||||
@@ -154,4 +233,54 @@ public interface LemmyAPI {
|
|||||||
@Header("Cookie") String token,
|
@Header("Cookie") String token,
|
||||||
@Part MultipartBody.Part filePart
|
@Part MultipartBody.Part filePart
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@GET("api/v3/resolve_object")
|
||||||
|
Call<String> resolveObject(
|
||||||
|
@Query("q") String query,
|
||||||
|
@Query("auth") String auth
|
||||||
|
);
|
||||||
|
|
||||||
|
@GET("api/v3/comment")
|
||||||
|
Call<String> getComment(
|
||||||
|
@Query("id") int commentId,
|
||||||
|
@Query("auth") String auth
|
||||||
|
);
|
||||||
|
|
||||||
|
@GET("api/v3/site")
|
||||||
|
Call<String> getSiteInfo(
|
||||||
|
@Query("auth") String auth
|
||||||
|
);
|
||||||
|
|
||||||
|
@GET("api/v3/private_message/list")
|
||||||
|
Call<String> privateMessagesList(
|
||||||
|
@Query("page") Integer page,
|
||||||
|
@Query("limit") Integer limit,
|
||||||
|
@Query("unread_only") Boolean unread_only,
|
||||||
|
@NonNull @Query("auth") String auth
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("api/v3/private_message")
|
||||||
|
Call<String> privateMessageSend(
|
||||||
|
@Body PrivateMessageDTO params
|
||||||
|
);
|
||||||
|
|
||||||
|
@PUT("api/v3/private_message")
|
||||||
|
Call<String> privateMessageEdit(
|
||||||
|
@Body PrivateMessageUpdateDTO params
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("api/v3/private_message/delete")
|
||||||
|
Call<String> privateMessageDelete(
|
||||||
|
@Body PrivateMessageUpdateDTO params
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("api/v3/private_message/mark_as_read")
|
||||||
|
Call<String> privateMessageMarkAsRead(
|
||||||
|
@Body PrivateMessageReadDTO params
|
||||||
|
);
|
||||||
|
|
||||||
|
@POST("api/v3/private_message/report")
|
||||||
|
Call<String> privateMessageReport(
|
||||||
|
@Body PrivateMessageReportDTO params
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.asynctasks;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
|
||||||
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
||||||
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
|
|
||||||
|
|
||||||
|
public class InsertBlockedThings {
|
||||||
|
|
||||||
|
public static void insertBlockedThings(Executor executor, Handler handler,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase, @Nullable String accountName,
|
||||||
|
List<BlockedCommunityData> blockedCommunityDataList,
|
||||||
|
List<BlockedUserData> blockedUserDataDataList,
|
||||||
|
|
||||||
|
InsertBlockedThingListener insertSubscribedThingListener) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
if (accountName != null && redditDataRoomDatabase.accountDao().getAccountData(accountName) == null) {
|
||||||
|
handler.post(insertSubscribedThingListener::insertSuccess);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedUserDao blockedUserDao = redditDataRoomDatabase.blockedUserDao();
|
||||||
|
BlockedCommunityDao blockedCommunityDao = redditDataRoomDatabase.blockedCommunityDao();
|
||||||
|
|
||||||
|
|
||||||
|
if (blockedCommunityDataList != null) {
|
||||||
|
List<BlockedCommunityData> existingBlockedCommunityDaoList =
|
||||||
|
blockedCommunityDao.getAllBlockedCommunitiesList(accountName);
|
||||||
|
Collections.sort(blockedCommunityDataList, (subscribedSubredditData, t1) -> subscribedSubredditData.getName().compareToIgnoreCase(t1.getName()));
|
||||||
|
List<String> unsubscribedSubreddits = new ArrayList<>();
|
||||||
|
compareTwoSubscribedSubredditList(blockedCommunityDataList, existingBlockedCommunityDaoList,
|
||||||
|
unsubscribedSubreddits);
|
||||||
|
|
||||||
|
for (String unsubscribed : unsubscribedSubreddits) {
|
||||||
|
blockedCommunityDao.deleteBlockedCommunity(unsubscribed, accountName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockedCommunityData s : blockedCommunityDataList) {
|
||||||
|
blockedCommunityDao.insert(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockedUserDataDataList != null) {
|
||||||
|
List<BlockedUserData> existingBlockedUserDataList =
|
||||||
|
blockedUserDao.getAllBlockedUsersList(accountName);
|
||||||
|
Collections.sort(blockedUserDataDataList, (subscribedUserData, t1) -> subscribedUserData.getName().compareToIgnoreCase(t1.getName()));
|
||||||
|
List<String> unsubscribedUsers = new ArrayList<>();
|
||||||
|
compareTwoSubscribedUserList(blockedUserDataDataList, existingBlockedUserDataList,
|
||||||
|
unsubscribedUsers);
|
||||||
|
|
||||||
|
for (String unsubscribed : unsubscribedUsers) {
|
||||||
|
blockedUserDao.deleteBlockedUser(unsubscribed, accountName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BlockedUserData s : blockedUserDataDataList) {
|
||||||
|
blockedUserDao.insert(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.post(insertSubscribedThingListener::insertSuccess);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void compareTwoSubscribedSubredditList(List<BlockedCommunityData> newSubscribedSubreddits,
|
||||||
|
List<BlockedCommunityData> oldSubscribedSubreddits,
|
||||||
|
List<String> unsubscribedSubredditNames) {
|
||||||
|
int newIndex = 0;
|
||||||
|
for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
|
||||||
|
if (newIndex >= newSubscribedSubreddits.size()) {
|
||||||
|
for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
|
||||||
|
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getQualified_name());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedCommunityData old = oldSubscribedSubreddits.get(oldIndex);
|
||||||
|
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
|
||||||
|
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) == 0) {
|
||||||
|
newIndex++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) > 0) {
|
||||||
|
unsubscribedSubredditNames.add(old.getQualified_name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void compareTwoSubscribedUserList(List<BlockedUserData> newSubscribedUsers,
|
||||||
|
List<BlockedUserData> oldSubscribedUsers,
|
||||||
|
List<String> unsubscribedUserNames) {
|
||||||
|
int newIndex = 0;
|
||||||
|
for (int oldIndex = 0; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||||
|
if (newIndex >= newSubscribedUsers.size()) {
|
||||||
|
for (; oldIndex < oldSubscribedUsers.size(); oldIndex++) {
|
||||||
|
unsubscribedUserNames.add(oldSubscribedUsers.get(oldIndex).getQualifiedName());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedUserData old = oldSubscribedUsers.get(oldIndex);
|
||||||
|
for (; newIndex < newSubscribedUsers.size(); newIndex++) {
|
||||||
|
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) == 0) {
|
||||||
|
newIndex++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (newSubscribedUsers.get(newIndex).getName().compareToIgnoreCase(old.getName()) > 0) {
|
||||||
|
unsubscribedUserNames.add(old.getQualifiedName());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface InsertBlockedThingListener {
|
||||||
|
void insertSuccess();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
|||||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditDao;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditDao;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class LoadSubredditIcon {
|
public class LoadSubredditIcon {
|
||||||
@@ -18,9 +19,9 @@ public class LoadSubredditIcon {
|
|||||||
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
|
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
SubredditDao subredditDao = redditDataRoomDatabase.subredditDao();
|
SubredditDao subredditDao = redditDataRoomDatabase.subredditDao();
|
||||||
SubredditData subredditData = subredditDao.getSubredditData(subredditName);
|
SubredditData subredditData = subredditDao.getSubredditDataByActorId(LemmyUtils.qualifiedCommunityName2ActorId(subredditName));
|
||||||
if (subredditData != null) {
|
if (subredditData != null) {
|
||||||
String iconImageUrl = subredditDao.getSubredditData(subredditName).getIconUrl();
|
String iconImageUrl = subredditDao.getSubredditDataByActorId(LemmyUtils.qualifiedCommunityName2ActorId(subredditName)).getIconUrl();
|
||||||
handler.post(() -> loadSubredditIconAsyncTaskListener.loadIconSuccess(iconImageUrl));
|
handler.post(() -> loadSubredditIconAsyncTaskListener.loadIconSuccess(iconImageUrl));
|
||||||
} else {
|
} else {
|
||||||
handler.post(() -> FetchSubredditData.fetchSubredditData(retrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
handler.post(() -> FetchSubredditData.fetchSubredditData(retrofit, subredditName, accessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
|||||||
import eu.toldi.infinityforlemmy.user.FetchUserData;
|
import eu.toldi.infinityforlemmy.user.FetchUserData;
|
||||||
import eu.toldi.infinityforlemmy.user.UserDao;
|
import eu.toldi.infinityforlemmy.user.UserDao;
|
||||||
import eu.toldi.infinityforlemmy.user.UserData;
|
import eu.toldi.infinityforlemmy.user.UserData;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class LoadUserData {
|
public class LoadUserData {
|
||||||
@@ -16,8 +17,9 @@ public class LoadUserData {
|
|||||||
Retrofit retrofit, LoadUserDataAsyncTaskListener loadUserDataAsyncTaskListener) {
|
Retrofit retrofit, LoadUserDataAsyncTaskListener loadUserDataAsyncTaskListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
UserDao userDao = redditDataRoomDatabase.userDao();
|
UserDao userDao = redditDataRoomDatabase.userDao();
|
||||||
if (userDao.getUserData(userName) != null) {
|
UserData userData= userDao.getUserDataByActorId(LemmyUtils.qualifiedUserName2ActorId(userName));
|
||||||
String iconImageUrl = userDao.getUserData(userName).getIconUrl();
|
if (userData != null) {
|
||||||
|
String iconImageUrl = userData.getIconUrl();
|
||||||
handler.post(() -> loadUserDataAsyncTaskListener.loadUserDataSuccess(iconImageUrl));
|
handler.post(() -> loadUserDataAsyncTaskListener.loadUserDataSuccess(iconImageUrl));
|
||||||
} else {
|
} else {
|
||||||
handler.post(() -> FetchUserData.fetchUserData(retrofit, userName, new FetchUserData.FetchUserDataListener() {
|
handler.post(() -> FetchUserData.fetchUserData(retrofit, userName, new FetchUserData.FetchUserDataListener() {
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ public class ParseAndInsertNewAccount {
|
|||||||
|
|
||||||
public static void parseAndInsertNewAccount(Executor executor, Handler handler, String username,
|
public static void parseAndInsertNewAccount(Executor executor, Handler handler, String username,
|
||||||
String display_name,String accessToken, String profileImageUrl,
|
String display_name,String accessToken, String profileImageUrl,
|
||||||
String bannerImageUrl, String code,String instance, AccountDao accountDao,
|
String bannerImageUrl, String code,String instance,boolean can_downvote, AccountDao accountDao,
|
||||||
ParseAndInsertAccountListener parseAndInsertAccountListener) {
|
ParseAndInsertAccountListener parseAndInsertAccountListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
Account account = new Account(username,display_name, accessToken, code, profileImageUrl,
|
Account account = new Account(username,display_name, accessToken, code, profileImageUrl,
|
||||||
bannerImageUrl, true,instance);
|
bannerImageUrl, true,instance,true);
|
||||||
accountDao.markAllAccountsNonCurrent();
|
accountDao.markAllAccountsNonCurrent();
|
||||||
accountDao.insert(account);
|
accountDao.insert(account);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.concurrent.Executor;
|
|||||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
import eu.toldi.infinityforlemmy.account.Account;
|
import eu.toldi.infinityforlemmy.account.Account;
|
||||||
|
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
||||||
|
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class SwitchAccount {
|
public class SwitchAccount {
|
||||||
@@ -26,6 +28,18 @@ public class SwitchAccount {
|
|||||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,account.getInstance_url())
|
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,account.getInstance_url())
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, account.getProfileImageUrl()).apply();
|
.putString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, account.getProfileImageUrl()).apply();
|
||||||
retrofitHolder.setBaseURL(account.getInstance_url());
|
retrofitHolder.setBaseURL(account.getInstance_url());
|
||||||
|
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
|
||||||
|
@Override
|
||||||
|
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||||
|
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||||
|
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchSiteInfoFailed() {
|
||||||
|
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
handler.post(() -> switchAccountListener.switched(account));
|
handler.post(() -> switchAccountListener.switched(account));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.OnConflictStrategy;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface BlockedCommunityDao {
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insert(BlockedCommunityData communityData);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insertAll(List<BlockedCommunityData> blockedCommunityDataList);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_communities WHERE account_name = :accountName AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||||
|
LiveData<List<BlockedCommunityData>> getAllBlockedCommunitiesWithSearchQuery(String accountName, String searchQuery);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_communities WHERE account_name = :accountName COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||||
|
List<BlockedCommunityData> getAllBlockedCommunitiesList(String accountName);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_communities WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
|
||||||
|
BlockedCommunityData getBlockedCommunity(String name, String accountName);
|
||||||
|
|
||||||
|
@Query("DELETE FROM blocked_communities WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
|
||||||
|
void deleteBlockedCommunity(String name, String accountName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
|
|
||||||
|
@Entity(tableName = "blocked_communities", primaryKeys = {"id", "account_name"})
|
||||||
|
public class BlockedCommunityData {
|
||||||
|
|
||||||
|
@ColumnInfo(name = "id")
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "qualified_name")
|
||||||
|
private String qualified_name;
|
||||||
|
@ColumnInfo(name = "icon")
|
||||||
|
private String iconUrl;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "account_name")
|
||||||
|
private String accountName;
|
||||||
|
|
||||||
|
public BlockedCommunityData(int id, String name, String qualified_name, String iconUrl, @NonNull String accountName) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.qualified_name = qualified_name;
|
||||||
|
this.iconUrl = iconUrl;
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQualified_name() {
|
||||||
|
return qualified_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIconUrl() {
|
||||||
|
return iconUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String getAccountName() {
|
||||||
|
return accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQualified_name(String qualified_name) {
|
||||||
|
this.qualified_name = qualified_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconUrl(String iconUrl) {
|
||||||
|
this.iconUrl = iconUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountName(@NonNull String accountName) {
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockedCommunityData(SubredditData subredditData, @NonNull String accountName) {
|
||||||
|
this.id = subredditData.getId();
|
||||||
|
this.name = subredditData.getName();
|
||||||
|
this.qualified_name = LemmyUtils.actorID2FullName(subredditData.getActorId());
|
||||||
|
this.iconUrl = subredditData.getIconUrl();
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class BlockedCommunityRepository {
|
||||||
|
private BlockedCommunityDao blockedCommunityDao;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
BlockedCommunityRepository(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
mAccountName = accountName;
|
||||||
|
blockedCommunityDao = redditDataRoomDatabase.blockedCommunityDao();
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<List<BlockedCommunityData>> getAllSubscribedSubredditsWithSearchQuery(String searchQuery) {
|
||||||
|
return blockedCommunityDao.getAllBlockedCommunitiesWithSearchQuery(mAccountName, searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insert(BlockedCommunityData subscribedSubredditData) {
|
||||||
|
new insertAsyncTask(blockedCommunityDao).execute(subscribedSubredditData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class insertAsyncTask extends AsyncTask<BlockedCommunityData, Void, Void> {
|
||||||
|
|
||||||
|
private BlockedCommunityDao mAsyncTaskDao;
|
||||||
|
|
||||||
|
insertAsyncTask(BlockedCommunityDao dao) {
|
||||||
|
mAsyncTaskDao = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(final BlockedCommunityData... params) {
|
||||||
|
mAsyncTaskDao.insert(params[0]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockedcommunity;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.Transformations;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class BlockedCommunityViewModel extends AndroidViewModel {
|
||||||
|
private BlockedCommunityRepository blockedCommunityRepository;
|
||||||
|
private LiveData<List<BlockedCommunityData>> mAllBlockedCommunities;
|
||||||
|
private MutableLiveData<String> searchQueryLiveData;
|
||||||
|
|
||||||
|
public BlockedCommunityViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
super(application);
|
||||||
|
blockedCommunityRepository = new BlockedCommunityRepository(redditDataRoomDatabase, accountName);
|
||||||
|
searchQueryLiveData = new MutableLiveData<>();
|
||||||
|
searchQueryLiveData.postValue("");
|
||||||
|
|
||||||
|
mAllBlockedCommunities = Transformations.switchMap(searchQueryLiveData, searchQuery -> blockedCommunityRepository.getAllSubscribedSubredditsWithSearchQuery(searchQuery));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<BlockedCommunityData>> getAllBlockedCommunities() {
|
||||||
|
return mAllBlockedCommunities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insert(BlockedCommunityData subscribedSubredditData) {
|
||||||
|
blockedCommunityRepository.insert(subscribedSubredditData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchQuery(String searchQuery) {
|
||||||
|
searchQueryLiveData.postValue(searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||||
|
private Application mApplication;
|
||||||
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
this.mApplication = application;
|
||||||
|
this.mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
this.mAccountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
|
return (T) new BlockedCommunityViewModel(mApplication, mRedditDataRoomDatabase, mAccountName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockeduser;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.OnConflictStrategy;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface BlockedUserDao {
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insert(BlockedUserData userData);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insertAll(List<BlockedUserData> blockedUserDataDataList);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_users WHERE account_name = :accountName AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||||
|
LiveData<List<BlockedUserData>> getAllBlockedUsersWithSearchQuery(String accountName, String searchQuery);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_users WHERE account_name = :accountName COLLATE NOCASE ORDER BY name COLLATE NOCASE ASC")
|
||||||
|
List<BlockedUserData> getAllBlockedUsersList(String accountName);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM blocked_users WHERE name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE LIMIT 1")
|
||||||
|
BlockedUserData getBlockedUser(String name, String accountName);
|
||||||
|
|
||||||
|
@Query("DELETE FROM blocked_users WHERE qualified_name = :name COLLATE NOCASE AND account_name = :accountName COLLATE NOCASE")
|
||||||
|
void deleteBlockedUser(String name, String accountName);
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockeduser;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.user.UserData;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
|
|
||||||
|
@Entity(tableName = "blocked_users", primaryKeys = {"id", "account_name"})
|
||||||
|
public class BlockedUserData {
|
||||||
|
|
||||||
|
@ColumnInfo(name = "id")
|
||||||
|
private final int id;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "avatar")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "qualified_name")
|
||||||
|
private String qualifiedName;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "account_name")
|
||||||
|
private String accountName;
|
||||||
|
|
||||||
|
public BlockedUserData(int id, String name, String avatar, String qualifiedName, String accountName) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.avatar = avatar;
|
||||||
|
this.qualifiedName = qualifiedName;
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvatar() {
|
||||||
|
return avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvatar(String avatar) {
|
||||||
|
this.avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQualifiedName() {
|
||||||
|
return qualifiedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQualifiedName(String qualifiedName) {
|
||||||
|
this.qualifiedName = qualifiedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccountName() {
|
||||||
|
return accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountName(String accountName) {
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockedUserData(UserData userData, @NonNull String accountName) {
|
||||||
|
this.id = userData.getId();
|
||||||
|
this.name = userData.getName();
|
||||||
|
this.avatar = userData.getAvatar();
|
||||||
|
this.qualifiedName = LemmyUtils.actorID2FullName(userData.getActorId());
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockeduser;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class BlockedUserRepository {
|
||||||
|
|
||||||
|
private BlockedUserDao mBlockedUserDao;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
BlockedUserRepository(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
mBlockedUserDao = redditDataRoomDatabase.blockedUserDao();
|
||||||
|
mAccountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<List<BlockedUserData>> getAllBlockedUsersWithSearchQuery(String searchQuery) {
|
||||||
|
return mBlockedUserDao.getAllBlockedUsersWithSearchQuery(mAccountName, searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<List<BlockedUserData>> getAllFavoriteSubscribedUsersWithSearchQuery(String searchQuery) {
|
||||||
|
return mBlockedUserDao.getAllBlockedUsersWithSearchQuery(mAccountName, searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insert(BlockedUserData BlockedUserData) {
|
||||||
|
new BlockedUserRepository.insertAsyncTask(mBlockedUserDao).execute(BlockedUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class insertAsyncTask extends AsyncTask<BlockedUserData, Void, Void> {
|
||||||
|
|
||||||
|
private BlockedUserDao mAsyncTaskDao;
|
||||||
|
|
||||||
|
insertAsyncTask(BlockedUserDao dao) {
|
||||||
|
mAsyncTaskDao = dao;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(final BlockedUserData... params) {
|
||||||
|
mAsyncTaskDao.insert(params[0]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.blockeduser;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.Transformations;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class BlockedUserViewModel extends AndroidViewModel {
|
||||||
|
private BlockedUserRepository blockedUserRepository;
|
||||||
|
private LiveData<List<BlockedUserData>> mAllSubscribedUsers;
|
||||||
|
private MutableLiveData<String> searchQueryLiveData;
|
||||||
|
|
||||||
|
public BlockedUserViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
super(application);
|
||||||
|
blockedUserRepository = new BlockedUserRepository(redditDataRoomDatabase, accountName);
|
||||||
|
searchQueryLiveData = new MutableLiveData<>();
|
||||||
|
searchQueryLiveData.postValue("");
|
||||||
|
|
||||||
|
mAllSubscribedUsers = Transformations.switchMap(searchQueryLiveData, searchQuery -> blockedUserRepository.getAllFavoriteSubscribedUsersWithSearchQuery(searchQuery));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<BlockedUserData>> getAllSubscribedUsers() {
|
||||||
|
return mAllSubscribedUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void insert(BlockedUserData BlockedUserData) {
|
||||||
|
blockedUserRepository.insert(BlockedUserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSearchQuery(String searchQuery) {
|
||||||
|
searchQueryLiveData.postValue(searchQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||||
|
private Application mApplication;
|
||||||
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private String mAccountName;
|
||||||
|
|
||||||
|
public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) {
|
||||||
|
mApplication = application;
|
||||||
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
mAccountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
|
return (T) new BlockedUserViewModel(mApplication, mRedditDataRoomDatabase, mAccountName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,24 +10,32 @@ import android.os.Bundle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.ReportActivity;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
|
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
@@ -55,12 +63,15 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
|||||||
TextView shareTextView;
|
TextView shareTextView;
|
||||||
@BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment)
|
@BindView(R.id.copy_text_view_comment_more_bottom_sheet_fragment)
|
||||||
TextView copyTextView;
|
TextView copyTextView;
|
||||||
@BindView(R.id.give_award_text_view_comment_more_bottom_sheet_fragment)
|
|
||||||
TextView giveAwardTextView;
|
|
||||||
@BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
|
@BindView(R.id.report_view_comment_more_bottom_sheet_fragment)
|
||||||
TextView reportTextView;
|
TextView reportTextView;
|
||||||
@BindView(R.id.see_removed_view_comment_more_bottom_sheet_fragment)
|
|
||||||
TextView seeRemovedTextView;
|
@Inject
|
||||||
|
LemmyCommentAPI lemmyCommentAPI;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
|
|
||||||
public CommentMoreBottomSheetFragment() {
|
public CommentMoreBottomSheetFragment() {
|
||||||
@@ -70,6 +81,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||||
View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_comment_more_bottom_sheet, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
@@ -93,18 +105,6 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
|||||||
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
|
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
|
||||||
|
|
||||||
if (accessToken != null && !accessToken.equals("")) {
|
if (accessToken != null && !accessToken.equals("")) {
|
||||||
giveAwardTextView.setVisibility(View.VISIBLE);
|
|
||||||
giveAwardTextView.setOnClickListener(view -> {
|
|
||||||
Intent intent = new Intent(activity, GiveAwardActivity.class);
|
|
||||||
intent.putExtra(GiveAwardActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
|
||||||
intent.putExtra(GiveAwardActivity.EXTRA_ITEM_POSITION, bundle.getInt(EXTRA_POSITION));
|
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
|
||||||
activity.startActivityForResult(intent, ViewPostDetailActivity.GIVE_AWARD_REQUEST_CODE);
|
|
||||||
} else if (activity instanceof ViewUserDetailActivity) {
|
|
||||||
activity.startActivityForResult(intent, ViewUserDetailActivity.GIVE_AWARD_REQUEST_CODE);
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (editAndDeleteAvailable) {
|
if (editAndDeleteAvailable) {
|
||||||
editTextView.setVisibility(View.VISIBLE);
|
editTextView.setVisibility(View.VISIBLE);
|
||||||
@@ -127,9 +127,9 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
|||||||
deleteTextView.setOnClickListener(view -> {
|
deleteTextView.setOnClickListener(view -> {
|
||||||
dismiss();
|
dismiss();
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
if (activity instanceof ViewPostDetailActivity) {
|
||||||
((ViewPostDetailActivity) activity).deleteComment(comment.getFullName(), bundle.getInt(EXTRA_POSITION));
|
((ViewPostDetailActivity) activity).deleteComment(comment.getId(), bundle.getInt(EXTRA_POSITION));
|
||||||
} else if (activity instanceof ViewUserDetailActivity) {
|
} else if (activity instanceof ViewUserDetailActivity) {
|
||||||
((ViewUserDetailActivity) activity).deleteComment(comment.getFullName());
|
((ViewUserDetailActivity) activity).deleteComment(comment.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -193,27 +193,47 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
|||||||
});
|
});
|
||||||
|
|
||||||
reportTextView.setOnClickListener(view -> {
|
reportTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(activity, ReportActivity.class);
|
if (accessToken == null) {
|
||||||
intent.putExtra(ReportActivity.EXTRA_SUBREDDIT_NAME, comment.getCommunityName());
|
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
intent.putExtra(ReportActivity.EXTRA_THING_FULLNAME, comment.getFullName());
|
dismiss();
|
||||||
activity.startActivity(intent);
|
return;
|
||||||
|
}
|
||||||
|
LayoutInflater dialog_inflater = LayoutInflater.from(activity);
|
||||||
|
View dialog_view = dialog_inflater.inflate(R.layout.dialog_report, null);
|
||||||
|
EditText reasonEditText = dialog_view.findViewById(R.id.reasonEditText);
|
||||||
|
|
||||||
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
|
||||||
|
.setTitle(R.string.report_post)
|
||||||
|
.setView(dialog_view)
|
||||||
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.dismiss())
|
||||||
|
.setPositiveButton(R.string.send_report, (dialogInterface, i) -> {
|
||||||
|
String reason = reasonEditText.getText().toString();
|
||||||
|
if (reason.isEmpty()) {
|
||||||
|
Toast.makeText(activity, "A report reason must be provided", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lemmyCommentAPI.reportComment(comment.getId(), reason, accessToken, new LemmyCommentAPI.ReportCommentCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess() {
|
||||||
|
Toast.makeText(activity, R.string.report_successful, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure() {
|
||||||
|
Toast.makeText(activity, R.string.report_failed, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
Button negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||||
|
positiveButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||||
|
negativeButton.setTextColor(mCustomThemeWrapper.getSecondaryTextColor());
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
if ("[deleted]".equals(comment.getAuthor()) ||
|
|
||||||
"[deleted]".equals(comment.getCommentRawText()) ||
|
|
||||||
"[removed]".equals(comment.getCommentRawText())
|
|
||||||
) {
|
|
||||||
seeRemovedTextView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
seeRemovedTextView.setOnClickListener(view -> {
|
|
||||||
dismiss();
|
|
||||||
if (activity instanceof ViewPostDetailActivity) {
|
|
||||||
((ViewPostDetailActivity) activity).showRemovedComment(comment, bundle.getInt(EXTRA_POSITION));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
|
|||||||
public static final int FAB_OPTION_SEARCH = 4;
|
public static final int FAB_OPTION_SEARCH = 4;
|
||||||
public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5;
|
public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5;
|
||||||
public static final int FAB_OPTION_GO_TO_USER = 6;
|
public static final int FAB_OPTION_GO_TO_USER = 6;
|
||||||
public static final int FAB_RANDOM = 7;
|
|
||||||
public static final int FAB_HIDE_READ_POSTS = 8;
|
public static final int FAB_HIDE_READ_POSTS = 8;
|
||||||
public static final int FAB_FILTER_POSTS = 9;
|
public static final int FAB_FILTER_POSTS = 9;
|
||||||
public static final int FAB_GO_TO_TOP = 10;
|
public static final int FAB_GO_TO_TOP = 10;
|
||||||
@@ -86,10 +85,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.randomTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
|
|
||||||
activity.fabOptionSelected(FAB_RANDOM);
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
|
binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
activity.fabOptionSelected(FAB_FILTER_POSTS);
|
activity.fabOptionSelected(FAB_FILTER_POSTS);
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
TextView linkTypeTextView;
|
TextView linkTypeTextView;
|
||||||
@BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment)
|
@BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment)
|
||||||
TextView imageTypeTextView;
|
TextView imageTypeTextView;
|
||||||
@BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment)
|
|
||||||
TextView videoTypeTextView;
|
|
||||||
@BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment)
|
|
||||||
TextView galleryTypeTextView;
|
|
||||||
@BindView(R.id.poll_type_linear_layout_post_type_bottom_sheet_fragment)
|
|
||||||
TextView pollTypeTextView;
|
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
|
|
||||||
public PostTypeBottomSheetFragment() {
|
public PostTypeBottomSheetFragment() {
|
||||||
@@ -76,20 +70,6 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
|
|||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
videoTypeTextView.setOnClickListener(view -> {
|
|
||||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO);
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
galleryTypeTextView.setOnClickListener(view -> {
|
|
||||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_GALLERY);
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
pollTypeTextView.setOnClickListener(view -> {
|
|
||||||
((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_POLL);
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
||||||
|
|||||||
@@ -31,16 +31,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
|||||||
|
|
||||||
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
|
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
|
||||||
|
|
||||||
@BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment)
|
|
||||||
TextView relevanceTypeTextView;
|
|
||||||
@BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment)
|
|
||||||
TextView hotTypeTextView;
|
|
||||||
@BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||||
TextView topTypeTextView;
|
TextView topTypeTextView;
|
||||||
@BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||||
TextView newTypeTextView;
|
TextView newTypeTextView;
|
||||||
@BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment)
|
@BindView(R.id.old_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||||
TextView commentsTypeTextView;
|
TextView oldTypeTextView;
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
public SearchPostSortTypeBottomSheetFragment() {
|
public SearchPostSortTypeBottomSheetFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@@ -61,14 +57,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
|||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
|
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
|
||||||
if (currentSortType.equals(SortType.Type.HOT.fullName)) {
|
if (currentSortType.equals(SortType.Type.TOP.fullName)) {
|
||||||
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
|
||||||
} else if (currentSortType.equals(SortType.Type.TOP.fullName)) {
|
|
||||||
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||||
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
|
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
|
||||||
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||||
} else if (currentSortType.equals(SortType.Type.OLD.fullName)) {
|
} else if (currentSortType.equals(SortType.Type.OLD.fullName)) {
|
||||||
commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
@@ -76,15 +70,6 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
|||||||
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*relevanceTypeTextView.setOnClickListener(view -> {
|
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name());
|
|
||||||
dismiss();
|
|
||||||
});*/
|
|
||||||
|
|
||||||
hotTypeTextView.setOnClickListener(view -> {
|
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name());
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
topTypeTextView.setOnClickListener(view -> {
|
topTypeTextView.setOnClickListener(view -> {
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
|
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
|
||||||
@@ -92,12 +77,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
|||||||
});
|
});
|
||||||
|
|
||||||
newTypeTextView.setOnClickListener(view -> {
|
newTypeTextView.setOnClickListener(view -> {
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW));
|
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW,null));
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
commentsTypeTextView.setOnClickListener(view -> {
|
oldTypeTextView.setOnClickListener(view -> {
|
||||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.MOST_COMMENTS.name());
|
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD,null));
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ public class Comment implements Parcelable {
|
|||||||
|
|
||||||
private String communityQualifiedName;
|
private String communityQualifiedName;
|
||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
private int score;
|
private int downvotes;
|
||||||
|
private int upvotes;
|
||||||
private int voteType;
|
private int voteType;
|
||||||
private boolean isSubmitter;
|
private boolean isSubmitter;
|
||||||
private String distinguished;
|
private String distinguished;
|
||||||
@@ -49,6 +50,8 @@ public class Comment implements Parcelable {
|
|||||||
private int depth;
|
private int depth;
|
||||||
private int childCount;
|
private int childCount;
|
||||||
private boolean collapsed;
|
private boolean collapsed;
|
||||||
|
|
||||||
|
private boolean isDeleted;
|
||||||
private boolean hasReply;
|
private boolean hasReply;
|
||||||
private boolean saved;
|
private boolean saved;
|
||||||
private boolean isExpanded;
|
private boolean isExpanded;
|
||||||
@@ -65,9 +68,9 @@ public class Comment implements Parcelable {
|
|||||||
|
|
||||||
public Comment(int id, int postId, String fullName, String author, String authorQualifiedName, String linkAuthor,
|
public Comment(int id, int postId, String fullName, String author, String authorQualifiedName, String linkAuthor,
|
||||||
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
||||||
String linkId, String communityName, String communityQualifiedName, Integer parentId, int score,
|
String linkId, String communityName, String communityQualifiedName, Integer parentId, int downvotes,int upvotes,
|
||||||
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
||||||
int depth, boolean collapsed, boolean hasReply, boolean saved, long edited, String[] path) {
|
int depth, boolean collapsed, boolean hasReply, boolean saved, boolean deleted, long edited, String[] path) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.postId = postId;
|
this.postId = postId;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
@@ -81,7 +84,8 @@ public class Comment implements Parcelable {
|
|||||||
this.communityName = communityName;
|
this.communityName = communityName;
|
||||||
this.communityQualifiedName = communityQualifiedName;
|
this.communityQualifiedName = communityQualifiedName;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
this.score = score;
|
this.downvotes = downvotes;
|
||||||
|
this.upvotes = upvotes;
|
||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
this.isSubmitter = isSubmitter;
|
this.isSubmitter = isSubmitter;
|
||||||
this.distinguished = distinguished;
|
this.distinguished = distinguished;
|
||||||
@@ -90,6 +94,7 @@ public class Comment implements Parcelable {
|
|||||||
this.collapsed = collapsed;
|
this.collapsed = collapsed;
|
||||||
this.hasReply = hasReply;
|
this.hasReply = hasReply;
|
||||||
this.saved = saved;
|
this.saved = saved;
|
||||||
|
this.isDeleted = deleted;
|
||||||
this.isExpanded = false;
|
this.isExpanded = false;
|
||||||
this.hasExpandedBefore = false;
|
this.hasExpandedBefore = false;
|
||||||
this.editedTimeMillis = edited;
|
this.editedTimeMillis = edited;
|
||||||
@@ -129,7 +134,8 @@ public class Comment implements Parcelable {
|
|||||||
communityName = in.readString();
|
communityName = in.readString();
|
||||||
communityQualifiedName = in.readString();
|
communityQualifiedName = in.readString();
|
||||||
parentId = in.readInt();
|
parentId = in.readInt();
|
||||||
score = in.readInt();
|
downvotes = in.readInt();
|
||||||
|
upvotes = in.readInt();
|
||||||
voteType = in.readInt();
|
voteType = in.readInt();
|
||||||
isSubmitter = in.readByte() != 0;
|
isSubmitter = in.readByte() != 0;
|
||||||
distinguished = in.readString();
|
distinguished = in.readString();
|
||||||
@@ -225,11 +231,23 @@ public class Comment implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getScore() {
|
public int getScore() {
|
||||||
return score;
|
return upvotes-downvotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScore(int score) {
|
public int getDownvotes() {
|
||||||
this.score = score;
|
return downvotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownvotes(int downvotes) {
|
||||||
|
this.downvotes = downvotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUpvotes() {
|
||||||
|
return upvotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpvotes(int upvotes) {
|
||||||
|
this.upvotes = upvotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSubmitter() {
|
public boolean isSubmitter() {
|
||||||
@@ -429,7 +447,8 @@ public class Comment implements Parcelable {
|
|||||||
parcel.writeString(communityName);
|
parcel.writeString(communityName);
|
||||||
parcel.writeString(communityQualifiedName);
|
parcel.writeString(communityQualifiedName);
|
||||||
parcel.writeInt(parentId == null ? 0 : parentId);
|
parcel.writeInt(parentId == null ? 0 : parentId);
|
||||||
parcel.writeInt(score);
|
parcel.writeInt(downvotes);
|
||||||
|
parcel.writeInt(upvotes);
|
||||||
parcel.writeInt(voteType);
|
parcel.writeInt(voteType);
|
||||||
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
|
parcel.writeByte((byte) (isSubmitter ? 1 : 0));
|
||||||
parcel.writeString(distinguished);
|
parcel.writeString(distinguished);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user