mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-06 22:54:47 +01:00
Compare commits
126 Commits
54fdca4fb6
...
726eac70a9
Author | SHA1 | Date | |
---|---|---|---|
|
726eac70a9 | ||
|
421342734c | ||
|
ee7f2e271c | ||
|
c387e4abbc | ||
|
ff3ccca3eb | ||
|
0b1171c5b2 | ||
|
48776d28bb | ||
|
25495b737a | ||
|
e5ffaf3d97 | ||
|
48d41103b6 | ||
|
04a60211c6 | ||
|
55f4689984 | ||
|
9f02969dd2 | ||
|
fd833a65c5 | ||
|
16dfc65c64 | ||
|
67115e0dd6 | ||
|
5f6b966160 | ||
|
4a200d7343 | ||
|
aa75fb5592 | ||
|
5618e2e88b | ||
|
03ee3899d7 | ||
|
6b09f0379c | ||
|
fe565d2ef3 | ||
|
14e568e642 | ||
|
ec3b89a056 | ||
|
343484aff2 | ||
|
ec7ef689c9 | ||
|
312a768351 | ||
|
c4992aac74 | ||
|
df37db5fed | ||
|
d699e3a434 | ||
|
c111ee35b4 | ||
|
766c2dc2c5 | ||
|
ec484cd51d | ||
|
494545500f | ||
|
db9c7a77e5 | ||
|
5a2954b432 | ||
|
751c2bd421 | ||
|
3940f9b402 | ||
|
dd72afc115 | ||
|
7c87bf19d2 | ||
|
3d5d26f6ec | ||
|
12eec8cc6b | ||
|
1d17b4be9e | ||
|
4896aad901 | ||
|
46b6ab82d5 | ||
|
523db3c659 | ||
|
4614ee0ae2 | ||
|
a874b9b455 | ||
|
998e4dd802 | ||
|
cca17e0e81 | ||
|
f9deaccb5a | ||
|
04a9679429 | ||
|
caffec6b2a | ||
|
17c98e85ac | ||
|
2c46ac079c | ||
|
95b4325f3e | ||
|
673d717ef1 | ||
|
8c9460c6c0 | ||
|
b1d1f7ec72 | ||
|
7d394d5a13 | ||
|
e07ffc69ed | ||
|
80f7d1e331 | ||
|
f06775de4b | ||
|
2184d73e3e | ||
|
0ff2e70867 | ||
|
e7e83946eb | ||
|
2de2614d6f | ||
|
67349a134d | ||
|
25caea0b72 | ||
|
5522884bb2 | ||
|
9de9ba19e7 | ||
|
05f1f929e1 | ||
|
ab6573b3cf | ||
|
7ba12262ca | ||
|
82f5be2568 | ||
|
e33b4a3ec6 | ||
|
40f28071d6 | ||
|
2783bcd1e4 | ||
|
3e9db084b0 | ||
|
a648993f78 | ||
|
75416b8b1b | ||
|
6f273d5e58 | ||
|
8654512584 | ||
|
46b2e0b816 | ||
|
d708ef5300 | ||
|
9c8c667c41 | ||
|
ff270e6895 | ||
|
7869bd3b2b | ||
|
36d932e9fe | ||
|
5b2f3eb9b4 | ||
|
ddb1d6746b | ||
|
f2440e0e2e | ||
|
af6245eed7 | ||
|
4397e09016 | ||
|
262d9f02ba | ||
|
45b0399766 | ||
|
3bee0deb11 | ||
|
27a7b96ffb | ||
|
11a845e21c | ||
|
6d6a79bcb6 | ||
|
6ff46f928a | ||
|
81e1c73c65 | ||
|
554dfff4ad | ||
|
741ec08386 | ||
|
f8a21fa3ba | ||
|
fd6bc82214 | ||
|
0ae8826732 | ||
|
5311edc404 | ||
|
d8dc8c39b2 | ||
|
c43ced8b00 | ||
|
908f294130 | ||
|
95408f8125 | ||
|
6d5ba059f8 | ||
|
ecdd9da9c8 | ||
|
1c17e6b7d2 | ||
|
9f60eca225 | ||
|
9deba8b10e | ||
|
05948d74f4 | ||
|
1007be50f8 | ||
|
28617cf9a8 | ||
|
5d2d43eebc | ||
|
f2b2525823 | ||
|
caf4f177d2 | ||
|
1e67b34440 | ||
|
67afcd7e88 |
BIN
.assets/fdroid-badge.png
Normal file
BIN
.assets/fdroid-badge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
28
.gitea/issue_template/feature_request.md
Normal file
28
.gitea/issue_template/feature_request.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
name: "Feature request"
|
||||||
|
about: "Request a feature!"
|
||||||
|
title: "[Feature] "
|
||||||
|
ref: "master"
|
||||||
|
labels:
|
||||||
|
|
||||||
|
- Kind/Feature
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Description
|
||||||
|
<!-- A clear and concise description of what the feature is and what problem it solves. -->
|
||||||
|
|
||||||
|
### Background
|
||||||
|
<!-- Any background information or context that would be helpful. -->
|
||||||
|
|
||||||
|
### Proposed Solution
|
||||||
|
<!--
|
||||||
|
- Describe the solution you'd like.
|
||||||
|
- A clear and concise description of what you want to happen.
|
||||||
|
- Include any alternative solutions or features you've considered.
|
||||||
|
- Add any technical details, mockups, or examples if available.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Additional Context
|
||||||
|
<!-- Add any other context, screenshots, or links to existing issues/discussions about the feature here. -->
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -56,6 +56,8 @@ gen-external-apklibs
|
|||||||
|
|
||||||
# NDK
|
# NDK
|
||||||
obj/
|
obj/
|
||||||
|
**/ndkHelperBin
|
||||||
|
**/.cxx
|
||||||
|
|
||||||
# IntelliJ IDEA
|
# IntelliJ IDEA
|
||||||
*.iml
|
*.iml
|
||||||
|
@ -2,6 +2,7 @@ steps:
|
|||||||
build:
|
build:
|
||||||
image: alvrme/alpine-android:android-33-jdk11
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
commands:
|
commands:
|
||||||
|
- apk add --no-cache python3
|
||||||
- ./gradlew :app:assembleRelease
|
- ./gradlew :app:assembleRelease
|
||||||
when:
|
when:
|
||||||
path: [ app/**, build.gradle ]
|
path: [ app/**, build.gradle ]
|
||||||
|
@ -8,6 +8,7 @@ steps:
|
|||||||
build:
|
build:
|
||||||
image: alvrme/alpine-android:android-33-jdk11
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
commands:
|
commands:
|
||||||
|
- apk add --no-cache python3
|
||||||
- ./gradlew :app:assembleNightly
|
- ./gradlew :app:assembleNightly
|
||||||
sign:
|
sign:
|
||||||
image: alvrme/alpine-android:android-33-jdk11
|
image: alvrme/alpine-android:android-33-jdk11
|
||||||
|
78
README.md
78
README.md
@ -1,5 +1,5 @@
|
|||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
Eternity (formerly Infinity for Lemmy)
|
Eternity for Lemmy
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
@ -20,9 +20,13 @@ A Lemmy client for Android written in Java. It's a fork of the [Infinity for Red
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
<a href="https://f-droid.org/packages/eu.toldi.infinityforlemmy/">
|
||||||
|
<img src="./.assets/fdroid-badge.png" height="80">
|
||||||
|
</a>
|
||||||
<a href="https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy">
|
<a href="https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy">
|
||||||
<img src="./.assets/google-play-badge.png" height="80">
|
<img src="./.assets/google-play-badge.png" height="80">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="https://apt.izzysoft.de/fdroid/index/apk/eu.toldi.infinityforlemmy">
|
<a href="https://apt.izzysoft.de/fdroid/index/apk/eu.toldi.infinityforlemmy">
|
||||||
<img src="./.assets/IzzyOnDroid.png" height="80">
|
<img src="./.assets/IzzyOnDroid.png" height="80">
|
||||||
</a>
|
</a>
|
||||||
@ -36,24 +40,62 @@ A Lemmy client for Android written in Java. It's a fork of the [Infinity for Red
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Action Items for Eternity
|
## Features
|
||||||
|
|
||||||
Eternity is currently in the early stages of development. Expect many unfinished features and bugs!
|
Eternity is currently in the early stages of development. Expect many unfinished features and bugs!
|
||||||
|
|
||||||
- [x] Implementation of basic post browsing feature
|
### Browsing Lemmy
|
||||||
- [x] Support for multiple account handling
|
|
||||||
- [x] Functionality for post upvotes/downvotes
|
- Explore various feeds (Subscribed/Local/All) and communities
|
||||||
- [x] Functionality to browse comments
|
- Subscribe or unsubscribe from specific communities, with the option to block
|
||||||
- [x] Capability for creating a new post
|
- Discover communities federated with the current instance
|
||||||
- [x] Ability to create comments
|
- Favorite a community for quick access
|
||||||
- [x] Edit/Delete posts and comments
|
- Manage your subscriptions and blocked communities
|
||||||
- [x] Basic inbox
|
|
||||||
- [ ] Elimination of code/string references specific to Reddit
|
### Content Engagement
|
||||||
- [x] Incorporation of private messaging feature
|
|
||||||
- [x] Feature for saving posts/comments
|
- Engage with content by voting, saving, sharing, and creating posts or comments
|
||||||
- [x] Resolving links
|
- Enjoy endless scrolling through feeds and posts
|
||||||
- [ ] Account editing function
|
- Tailor the view settings for posts (card,compact, gallery)
|
||||||
- [ ] Multi community view?
|
- Set default preferences for post and comment sorting
|
||||||
|
- Stay updated with notifications for replies
|
||||||
|
|
||||||
|
### Account Management
|
||||||
|
|
||||||
|
- Sign in to multiple accounts or instances, and effortlessly switch between them
|
||||||
|
- Use the inbox features to view replies, mentions, and private messages
|
||||||
|
- Access your profile to view your posts, comments, and saved content
|
||||||
|
|
||||||
|
### Customization
|
||||||
|
|
||||||
|
- Choose between various theme options including Light, Dark, OLED
|
||||||
|
- Support Material You theming
|
||||||
|
- Explore user-created themes
|
||||||
|
- Customize font settings
|
||||||
|
- Optional bottom navigation bar
|
||||||
|
- Discover a plethora of other customization features
|
||||||
|
|
||||||
|
<img
|
||||||
|
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png"
|
||||||
|
alt="Screenshot 1"
|
||||||
|
height="200" >
|
||||||
|
<img
|
||||||
|
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png"
|
||||||
|
alt="Screenshot 2"
|
||||||
|
height="200" >
|
||||||
|
<img
|
||||||
|
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png"
|
||||||
|
alt="Screenshot 3"
|
||||||
|
height="200" >
|
||||||
|
<img
|
||||||
|
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png"
|
||||||
|
alt="Screenshot 4"
|
||||||
|
height="200" >
|
||||||
|
<img
|
||||||
|
src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/phoneScreenshots/5.png"
|
||||||
|
alt="Screenshot 5"
|
||||||
|
height="200" >
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
@ -72,9 +114,9 @@ Don't forget to give the project a star! Thanks again!
|
|||||||
|
|
||||||
### Translation
|
### Translation
|
||||||
|
|
||||||
You can alos help Eternity by translating it to your native langugage! Translations are done via [Weblate](https://translate.codeberg.org/projects/Eternity/app/)!
|
You can also help Eternity by translating it to your native langugage! Translations are done via [Weblate](https://translate.codeberg.org/projects/infinity-for-lemmy/app/)!
|
||||||
|
|
||||||
[![Translation](https://translate.codeberg.org/widgets/Eternity/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/Eternity/)
|
[![Translation](https://translate.codeberg.org/widgets/infinity-for-lemmy/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/Eternity/)
|
||||||
|
|
||||||
### Reporting bugs
|
### Reporting bugs
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "eu.toldi.infinityforlemmy"
|
applicationId "eu.toldi.infinityforlemmy"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 33
|
targetSdk 33
|
||||||
versionCode 130
|
versionCode 131
|
||||||
versionName "0.1.1"
|
versionName "0.1.2"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
annotationProcessorOptions {
|
annotationProcessorOptions {
|
||||||
@ -33,7 +33,8 @@ android {
|
|||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled true
|
||||||
|
shrinkResources true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +98,37 @@ android {
|
|||||||
packagingOptions {
|
packagingOptions {
|
||||||
doNotStrip '**/*.so'
|
doNotStrip '**/*.so'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Kotlin jvm target
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '11'
|
||||||
|
}
|
||||||
|
|
||||||
namespace 'eu.toldi.infinityforlemmy'
|
namespace 'eu.toldi.infinityforlemmy'
|
||||||
|
|
||||||
|
|
||||||
|
task rearrangeClass(type: Exec) {
|
||||||
|
commandLine 'python3', '../scripts/fixEventBus.py'
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationVariants.all { variant ->
|
||||||
|
if (variant.name == 'release') {
|
||||||
|
task("compileSingleFile${variant.name.capitalize()}", type: JavaCompile, dependsOn: rearrangeClass) {
|
||||||
|
def filePath = project.rootDir.absolutePath + '/app/build/generated/ap_generated_sources/release/out/eu/toldi/infinityforlemmy/'
|
||||||
|
source = files(filePath)
|
||||||
|
includes = ["**/EventBusIndex.java"]
|
||||||
|
classpath = variant.getCompileClasspath() + files(project.rootDir.absolutePath + '/app/build/intermediates/javac/release/classes')
|
||||||
|
destinationDir = file("$buildDir/intermediates/javac/release/classes")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).all { task ->
|
||||||
|
if (task.name == 'compileReleaseJavaWithJavac') {
|
||||||
|
task.finalizedBy "compileSingleFile${variant.name.capitalize()}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -196,11 +227,12 @@ dependencies {
|
|||||||
def glideVersion = "4.12.0"
|
def glideVersion = "4.12.0"
|
||||||
implementation "com.github.bumptech.glide:glide:$glideVersion"
|
implementation "com.github.bumptech.glide:glide:$glideVersion"
|
||||||
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
|
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
|
||||||
|
implementation "com.github.bumptech.glide:okhttp-integration:$glideVersion"
|
||||||
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
implementation 'jp.wasabeef:glide-transformations:4.3.0'
|
||||||
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
|
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
|
||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
|
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
|
||||||
def bivVersion = "1.8.1"
|
def bivVersion = "1.8.1"
|
||||||
implementation "com.github.piasy:BigImageViewer:bivVersion"
|
implementation "com.github.piasy:BigImageViewer:$bivVersion"
|
||||||
implementation "com.github.piasy:GlideImageLoader:$bivVersion"
|
implementation "com.github.piasy:GlideImageLoader:$bivVersion"
|
||||||
implementation "com.github.piasy:GlideImageViewFactory:$bivVersion"
|
implementation "com.github.piasy:GlideImageViewFactory:$bivVersion"
|
||||||
|
|
||||||
@ -239,9 +271,42 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.otaliastudios:zoomlayout:1.9.0'
|
implementation 'com.otaliastudios:zoomlayout:1.9.0'
|
||||||
|
|
||||||
|
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||||
|
|
||||||
|
|
||||||
/**** Builds and flavors ****/
|
/**** Builds and flavors ****/
|
||||||
// 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'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NB: Android Studio can't find the imports; this does not affect the
|
||||||
|
// actual build since Gradle can find them just fine.
|
||||||
|
|
||||||
|
import com.android.tools.profgen.ArtProfileKt
|
||||||
|
import com.android.tools.profgen.ArtProfileSerializer
|
||||||
|
import com.android.tools.profgen.DexFile
|
||||||
|
|
||||||
|
project.afterEvaluate {
|
||||||
|
tasks.each { task ->
|
||||||
|
if (task.name.startsWith("compile") && task.name.endsWith("ReleaseArtProfile")) {
|
||||||
|
task.doLast {
|
||||||
|
outputs.files.each { file ->
|
||||||
|
if (file.name.endsWith(".profm")) {
|
||||||
|
println("Sorting ${file} ...")
|
||||||
|
def version = ArtProfileSerializer.valueOf("METADATA_0_0_2")
|
||||||
|
def profile = ArtProfileKt.ArtProfile(file)
|
||||||
|
def keys = new ArrayList(profile.profileData.keySet())
|
||||||
|
def sortedData = new LinkedHashMap()
|
||||||
|
Collections.sort keys, new DexFile.Companion()
|
||||||
|
keys.each { key -> sortedData[key] = profile.profileData[key] }
|
||||||
|
new FileOutputStream(file).with {
|
||||||
|
write(version.magicBytes$profgen)
|
||||||
|
write(version.versionBytes$profgen)
|
||||||
|
version.write$profgen(it, sortedData, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -5,6 +5,8 @@
|
|||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
-dontobfuscate
|
||||||
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
## Preferences reflection
|
## Preferences reflection
|
||||||
-keep class * extends androidx.preference.PreferenceFragmentCompat
|
-keep class * extends androidx.preference.PreferenceFragmentCompat
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
package="eu.toldi.infinityforlemmy">
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<intent>
|
<intent>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
android:maxSdkVersion="28" />
|
android:maxSdkVersion="28" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
@ -40,6 +42,23 @@
|
|||||||
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
android:theme="@style/AppTheme.Slidable" />
|
android:theme="@style/AppTheme.Slidable" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.CommentFilterUsageListingActivity"
|
||||||
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.CustomizeCommentFilterActivity"
|
||||||
|
android:label="@string/customize_comment_filter_activity_label"
|
||||||
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".activities.CommentFilterPreferenceActivity"
|
||||||
|
android:label="@string/comment_filter_preference_activity_label"
|
||||||
|
android:parentActivityName=".activities.SettingsActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.HistoryActivity"
|
android:name=".activities.HistoryActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@ -407,11 +426,6 @@
|
|||||||
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"
|
||||||
@ -440,12 +454,38 @@
|
|||||||
android:label="@string/application_name"
|
android:label="@string/application_name"
|
||||||
android:theme="@style/AppTheme.Launcher"
|
android:theme="@style/AppTheme.Launcher"
|
||||||
android:windowSoftInputMode="adjustPan">
|
android:windowSoftInputMode="adjustPan">
|
||||||
|
<intent-filter>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity-alias
|
||||||
|
android:name=".DefaultIcon"
|
||||||
|
android:targetActivity=".activities.MainActivity"
|
||||||
|
android:label="@string/application_name"
|
||||||
|
android:enabled="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity-alias>
|
||||||
|
|
||||||
|
<activity-alias
|
||||||
|
android:name=".OriginalIcon"
|
||||||
|
android:targetActivity=".activities.MainActivity"
|
||||||
|
android:label="@string/application_name"
|
||||||
|
android:enabled="false"
|
||||||
|
android:icon="@mipmap/original_ic_launcher"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity-alias>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activities.LoginActivity"
|
android:name=".activities.LoginActivity"
|
||||||
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
android:configChanges="orientation|screenLayout|screenSize|layoutDirection"
|
||||||
@ -474,6 +514,7 @@
|
|||||||
android:name=".activities.ViewUserDetailActivity"
|
android:name=".activities.ViewUserDetailActivity"
|
||||||
android:parentActivityName=".activities.MainActivity"
|
android:parentActivityName=".activities.MainActivity"
|
||||||
android:theme="@style/AppTheme.Slidable" />
|
android:theme="@style/AppTheme.Slidable" />
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.provider"
|
android:authorities="${applicationId}.provider"
|
||||||
|
BIN
app/src/main/ic_launcher-playstore.png
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
@ -12,9 +12,12 @@ 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.BlockedThingListingActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
import eu.toldi.infinityforlemmy.activities.CommentActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CommentFilterPreferenceActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CommentFilterUsageListingActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CreateMultiRedditActivity;
|
import eu.toldi.infinityforlemmy.activities.CreateMultiRedditActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CustomThemeListingActivity;
|
import eu.toldi.infinityforlemmy.activities.CustomThemeListingActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CustomThemePreviewActivity;
|
import eu.toldi.infinityforlemmy.activities.CustomThemePreviewActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CustomizeCommentFilterActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CustomizePostFilterActivity;
|
import eu.toldi.infinityforlemmy.activities.CustomizePostFilterActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.CustomizeThemeActivity;
|
import eu.toldi.infinityforlemmy.activities.CustomizeThemeActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
import eu.toldi.infinityforlemmy.activities.EditCommentActivity;
|
||||||
@ -25,7 +28,6 @@ import eu.toldi.infinityforlemmy.activities.FetchRandomSubredditOrPostActivity;
|
|||||||
import eu.toldi.infinityforlemmy.activities.FilteredPostsActivity;
|
import eu.toldi.infinityforlemmy.activities.FilteredPostsActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.FullMarkdownActivity;
|
import eu.toldi.infinityforlemmy.activities.FullMarkdownActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
import eu.toldi.infinityforlemmy.activities.GiveAwardActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.HistoryActivity;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.InboxActivity;
|
import eu.toldi.infinityforlemmy.activities.InboxActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.InstanceInfoActivity;
|
import eu.toldi.infinityforlemmy.activities.InstanceInfoActivity;
|
||||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||||
@ -75,7 +77,6 @@ import eu.toldi.infinityforlemmy.fragments.BlockedCommunitiesListingFragment;
|
|||||||
import eu.toldi.infinityforlemmy.fragments.BlockedUsersListingFragment;
|
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.InboxFragment;
|
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;
|
||||||
@ -113,7 +114,7 @@ import eu.toldi.infinityforlemmy.settings.TranslationFragment;
|
|||||||
import eu.toldi.infinityforlemmy.settings.VideoPreferenceFragment;
|
import eu.toldi.infinityforlemmy.settings.VideoPreferenceFragment;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Component(modules = {AppModule.class, NetworkModule.class})
|
@Component(modules = {AppModule.class, NetworkModule.class, PostEnricherModule.class})
|
||||||
public interface AppComponent {
|
public interface AppComponent {
|
||||||
void inject(MainActivity mainActivity);
|
void inject(MainActivity mainActivity);
|
||||||
|
|
||||||
@ -309,10 +310,6 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(MaterialYouWorker materialYouWorker);
|
void inject(MaterialYouWorker materialYouWorker);
|
||||||
|
|
||||||
void inject(HistoryPostFragment historyPostFragment);
|
|
||||||
|
|
||||||
void inject(HistoryActivity historyActivity);
|
|
||||||
|
|
||||||
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
||||||
|
|
||||||
void inject(BlockedThingListingActivity blockedThingListingActivity);
|
void inject(BlockedThingListingActivity blockedThingListingActivity);
|
||||||
@ -327,6 +324,12 @@ public interface AppComponent {
|
|||||||
|
|
||||||
void inject(@NotNull InstanceInfoActivity instanceInfoActivity);
|
void inject(@NotNull InstanceInfoActivity instanceInfoActivity);
|
||||||
|
|
||||||
|
void inject(CommentFilterPreferenceActivity commentFilterPreferenceActivity);
|
||||||
|
|
||||||
|
void inject(CustomizeCommentFilterActivity customizeCommentFilterActivity);
|
||||||
|
|
||||||
|
void inject(CommentFilterUsageListingActivity commentFilterUsageListingActivity);
|
||||||
|
|
||||||
@Component.Factory
|
@Component.Factory
|
||||||
interface Factory {
|
interface Factory {
|
||||||
AppComponent create(@BindsInstance Application application);
|
AppComponent create(@BindsInstance Application application);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package eu.toldi.infinityforlemmy;
|
package eu.toldi.infinityforlemmy;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -12,9 +10,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
|
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -44,14 +40,12 @@ public class FetchGfycatOrRedgifsVideoLinks {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fetchRedgifsVideoLinks(Context context, Executor executor, Handler handler, Retrofit redgifsRetrofit,
|
public static void fetchRedgifsVideoLinks(Executor executor, Handler handler, Retrofit redgifsRetrofit,
|
||||||
SharedPreferences currentAccountSharedPreferences,
|
|
||||||
String gfycatId,
|
String gfycatId,
|
||||||
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")),
|
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(gfycatId).execute();
|
||||||
gfycatId, APIUtils.USER_AGENT).execute();
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,6 +11,16 @@ import android.os.Bundle;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.lifecycle.Lifecycle;
|
||||||
|
import androidx.lifecycle.LifecycleObserver;
|
||||||
|
import androidx.lifecycle.OnLifecycleEvent;
|
||||||
|
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
|
||||||
|
import com.bumptech.glide.load.model.GlideUrl;
|
||||||
import com.evernote.android.state.StateSaver;
|
import com.evernote.android.state.StateSaver;
|
||||||
import com.livefront.bridge.Bridge;
|
import com.livefront.bridge.Bridge;
|
||||||
import com.livefront.bridge.SavedStateHandler;
|
import com.livefront.bridge.SavedStateHandler;
|
||||||
@ -18,15 +28,11 @@ import com.livefront.bridge.SavedStateHandler;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.lifecycle.Lifecycle;
|
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
|
||||||
import androidx.lifecycle.OnLifecycleEvent;
|
|
||||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.LockScreenActivity;
|
import eu.toldi.infinityforlemmy.activities.LockScreenActivity;
|
||||||
import eu.toldi.infinityforlemmy.broadcastreceivers.NetworkWifiStatusReceiver;
|
import eu.toldi.infinityforlemmy.broadcastreceivers.NetworkWifiStatusReceiver;
|
||||||
import eu.toldi.infinityforlemmy.broadcastreceivers.WallpaperChangeReceiver;
|
import eu.toldi.infinityforlemmy.broadcastreceivers.WallpaperChangeReceiver;
|
||||||
@ -38,6 +44,8 @@ import eu.toldi.infinityforlemmy.font.FontFamily;
|
|||||||
import eu.toldi.infinityforlemmy.font.TitleFontFamily;
|
import eu.toldi.infinityforlemmy.font.TitleFontFamily;
|
||||||
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 okhttp3.Call;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
public class Infinity extends Application implements LifecycleObserver {
|
public class Infinity extends Application implements LifecycleObserver {
|
||||||
public Typeface typeface;
|
public Typeface typeface;
|
||||||
@ -55,6 +63,9 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
@Inject
|
@Inject
|
||||||
@Named("security")
|
@Named("security")
|
||||||
SharedPreferences mSecuritySharedPreferences;
|
SharedPreferences mSecuritySharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("glide")
|
||||||
|
OkHttpClient glideOkHttpClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@ -159,6 +170,9 @@ public class Infinity extends Application implements LifecycleObserver {
|
|||||||
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
||||||
|
|
||||||
registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
|
registerReceiver(new WallpaperChangeReceiver(mSharedPreferences), new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
|
||||||
|
|
||||||
|
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory((Call.Factory) glideOkHttpClient);
|
||||||
|
Glide.get(this).getRegistry().replace(GlideUrl.class, InputStream.class, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||||
|
@ -9,6 +9,7 @@ import javax.inject.Singleton;
|
|||||||
|
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
|
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
||||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||||
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
|
||||||
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
|
||||||
@ -37,7 +38,8 @@ abstract class NetworkModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Named("glide")
|
@Named("glide")
|
||||||
@Singleton
|
@Singleton
|
||||||
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp) {
|
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp,
|
||||||
|
@Named("RedgifsAccessTokenAuthenticator") Interceptor redGifsAuthenticator) {
|
||||||
return baseOkHttp.newBuilder()
|
return baseOkHttp.newBuilder()
|
||||||
.addInterceptor(chain -> chain.proceed(
|
.addInterceptor(chain -> chain.proceed(
|
||||||
chain.request()
|
chain.request()
|
||||||
@ -45,6 +47,7 @@ abstract class NetworkModule {
|
|||||||
.header("User-Agent", APIUtils.USER_AGENT)
|
.header("User-Agent", APIUtils.USER_AGENT)
|
||||||
.build()
|
.build()
|
||||||
))
|
))
|
||||||
|
.addInterceptor(redGifsAuthenticator)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,6 +181,12 @@ abstract class NetworkModule {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
static RedgifsAPI provideRedgifsAPI(@Named("redgifs") Retrofit redgifsRetrofit) {
|
||||||
|
return redgifsRetrofit.create(RedgifsAPI.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Named("imgur")
|
@Named("imgur")
|
||||||
@Singleton
|
@Singleton
|
||||||
@ -246,4 +255,13 @@ abstract class NetworkModule {
|
|||||||
static LemmyPrivateMessageAPI provideLemmyPrivateMessageAPI(@Named("base") RetrofitHolder retrofit) {
|
static LemmyPrivateMessageAPI provideLemmyPrivateMessageAPI(@Named("base") RetrofitHolder retrofit) {
|
||||||
return new LemmyPrivateMessageAPI(retrofit);
|
return new LemmyPrivateMessageAPI(retrofit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("lemmyVerse")
|
||||||
|
@Singleton
|
||||||
|
static Retrofit provideLemmyVerseRetrofit(@Named("base") RetrofitHolder retrofit) {
|
||||||
|
return retrofit.getRetrofit().newBuilder()
|
||||||
|
.baseUrl(APIUtils.LEMMYVERSE_API_BASE_URI)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package eu.toldi.infinityforlemmy;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import dagger.Module;
|
||||||
|
import dagger.Provides;
|
||||||
|
import dagger.multibindings.IntoSet;
|
||||||
|
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.post.enrich.CompositePostEnricher;
|
||||||
|
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
|
||||||
|
import eu.toldi.infinityforlemmy.post.enrich.RedGifsPostEnricher;
|
||||||
|
|
||||||
|
@Module
|
||||||
|
abstract class PostEnricherModule {
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@IntoSet
|
||||||
|
static PostEnricher provideRedGifsPostEnricher(RedgifsAPI redgifsAPI) {
|
||||||
|
return new RedGifsPostEnricher(redgifsAPI);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
static PostEnricher providePostEnricher(Set<PostEnricher> postEnrichers) {
|
||||||
|
return new CompositePostEnricher(postEnrichers);
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,10 @@ import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityDao;
|
|||||||
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
import eu.toldi.infinityforlemmy.blockedcommunity.BlockedCommunityData;
|
||||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserDao;
|
||||||
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
import eu.toldi.infinityforlemmy.blockeduser.BlockedUserData;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterDao;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsageDao;
|
||||||
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;
|
||||||
@ -42,7 +46,8 @@ 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, BlockedUserData.class, BlockedCommunityData.class}, version = 27)
|
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class,
|
||||||
|
BlockedUserData.class, BlockedCommunityData.class, CommentFilter.class, CommentFilterUsage.class}, version = 28)
|
||||||
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) {
|
||||||
@ -53,7 +58,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_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27)
|
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25, MIGRATION_25_26, MIGRATION_26_27, MIGRATION_27_28)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +90,10 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
|
|
||||||
public abstract AnonymousMultiredditSubredditDao anonymousMultiredditSubredditDao();
|
public abstract AnonymousMultiredditSubredditDao anonymousMultiredditSubredditDao();
|
||||||
|
|
||||||
|
public abstract CommentFilterDao commentFilterDao();
|
||||||
|
|
||||||
|
public abstract CommentFilterUsageDao commentFilterUsageDao();
|
||||||
|
|
||||||
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
private static final Migration MIGRATION_1_2 = new Migration(1, 2) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(SupportSQLiteDatabase database) {
|
public void migrate(SupportSQLiteDatabase database) {
|
||||||
@ -424,4 +433,16 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
|
|||||||
+ " ADD COLUMN is_favorite INTEGER DEFAULT 0 NOT NULL");
|
+ " ADD COLUMN is_favorite INTEGER DEFAULT 0 NOT NULL");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final Migration MIGRATION_27_28 = new Migration(27, 28) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE custom_themes ADD COLUMN filled_card_view_background_color INTEGER DEFAULT " + Color.parseColor("#E6F4FF") + " NOT NULL");
|
||||||
|
database.execSQL("ALTER TABLE custom_themes ADD COLUMN read_post_filled_card_view_background_color INTEGER DEFAULT " + Color.parseColor("#F5F5F5") + " NOT NULL");
|
||||||
|
database.execSQL("CREATE TABLE comment_filter " +
|
||||||
|
"(name TEXT NOT NULL PRIMARY KEY, max_vote INTEGER NOT NULL, min_vote INTEGER NOT NULL, exclude_strings TEXT, exclude_users TEXT)");
|
||||||
|
database.execSQL("CREATE TABLE comment_filter_usage (name TEXT NOT NULL, usage INTEGER NOT NULL, " +
|
||||||
|
"name_of_usage TEXT NOT NULL, PRIMARY KEY(name, usage, name_of_usage), FOREIGN KEY(name) REFERENCES comment_filter(name) ON DELETE CASCADE)");
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import java.util.Map;
|
|||||||
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
|
||||||
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 okhttp3.Headers;
|
|
||||||
import okhttp3.Interceptor;
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
@ -22,6 +21,8 @@ import retrofit2.Retrofit;
|
|||||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||||
|
|
||||||
public class RedgifsAccessTokenAuthenticator implements Interceptor {
|
public class RedgifsAccessTokenAuthenticator implements Interceptor {
|
||||||
|
private static final String REDGIFS_HOST = "redgifs.com";
|
||||||
|
|
||||||
private SharedPreferences mCurrentAccountSharedPreferences;
|
private SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
|
|
||||||
public RedgifsAccessTokenAuthenticator(SharedPreferences currentAccountSharedPreferences) {
|
public RedgifsAccessTokenAuthenticator(SharedPreferences currentAccountSharedPreferences) {
|
||||||
@ -60,7 +61,17 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||||
Response response = chain.proceed(chain.request());
|
if (!chain.request().url().host().endsWith(REDGIFS_HOST)) {
|
||||||
|
return chain.proceed(chain.request());
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "");
|
||||||
|
Response response = chain.proceed(
|
||||||
|
chain.request().newBuilder()
|
||||||
|
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + currentAccessToken)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
if (response.code() == 401 || response.code() == 400) {
|
if (response.code() == 401 || response.code() == 400) {
|
||||||
String accessTokenHeader = response.request().header(APIUtils.AUTHORIZATION_KEY);
|
String accessTokenHeader = response.request().header(APIUtils.AUTHORIZATION_KEY);
|
||||||
if (accessTokenHeader == null) {
|
if (accessTokenHeader == null) {
|
||||||
@ -74,13 +85,21 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
|
|||||||
String newAccessToken = refreshAccessToken();
|
String newAccessToken = refreshAccessToken();
|
||||||
if (!newAccessToken.equals("")) {
|
if (!newAccessToken.equals("")) {
|
||||||
response.close();
|
response.close();
|
||||||
return chain.proceed(response.request().newBuilder().headers(Headers.of(APIUtils.getRedgifsOAuthHeader(newAccessToken))).build());
|
return chain.proceed(
|
||||||
|
chain.request().newBuilder()
|
||||||
|
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + newAccessToken)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
response.close();
|
response.close();
|
||||||
return chain.proceed(response.request().newBuilder().headers(Headers.of(APIUtils.getRedgifsOAuthHeader(accessTokenFromSharedPreferences))).build());
|
return chain.proceed(
|
||||||
|
chain.request().newBuilder()
|
||||||
|
.addHeader(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + accessTokenFromSharedPreferences)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package eu.toldi.infinityforlemmy;
|
package eu.toldi.infinityforlemmy;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
|
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
|
import okhttp3.Interceptor;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
|
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
|
||||||
@ -12,8 +15,14 @@ public class RetrofitHolder {
|
|||||||
|
|
||||||
private Retrofit retrofit;
|
private Retrofit retrofit;
|
||||||
private OkHttpClient okHttpClient;
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
|
private OkHttpClient okHttpClientBase;
|
||||||
private String baseURL = APIUtils.API_BASE_URI;
|
private String baseURL = APIUtils.API_BASE_URI;
|
||||||
|
|
||||||
|
private String accessToken = null;
|
||||||
|
|
||||||
|
private Interceptor oAuthInterceptor;
|
||||||
|
|
||||||
public Retrofit getRetrofit() {
|
public Retrofit getRetrofit() {
|
||||||
return retrofit;
|
return retrofit;
|
||||||
}
|
}
|
||||||
@ -33,6 +42,7 @@ public class RetrofitHolder {
|
|||||||
|
|
||||||
public RetrofitHolder(OkHttpClient okHttpClient) {
|
public RetrofitHolder(OkHttpClient okHttpClient) {
|
||||||
this.okHttpClient = okHttpClient;
|
this.okHttpClient = okHttpClient;
|
||||||
|
this.okHttpClientBase = okHttpClient;
|
||||||
this.retrofit = createRetrofit(okHttpClient, APIUtils.API_BASE_URI);
|
this.retrofit = createRetrofit(okHttpClient, APIUtils.API_BASE_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,4 +56,18 @@ public class RetrofitHolder {
|
|||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
OkHttpClient.Builder builder = okHttpClientBase.newBuilder();
|
||||||
|
Log.d("RetrofitHolder", "Access token changed");
|
||||||
|
if (accessToken != null && !accessToken.equals("")) {
|
||||||
|
Log.i("RetrofitHolder", "Setting access token interceptor");
|
||||||
|
oAuthInterceptor = APIUtils.getOAuthInterceptor(accessToken);
|
||||||
|
builder.addInterceptor(oAuthInterceptor);
|
||||||
|
}
|
||||||
|
okHttpClient = builder.build();
|
||||||
|
retrofit = createRetrofit(okHttpClient, baseURL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,15 +69,15 @@ public class SortType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum Time {
|
public enum Time {
|
||||||
HOUR("TopHour", "Top Hour"),
|
HOUR("hour", "Hour"),
|
||||||
SIX_HOURS("TopSixHour", "Top Six Hours"),
|
SIX_HOURS("SixHour", "Six Hours"),
|
||||||
TWELVE_HOURS("TopTwelveHour", "Top Twelve Hours"),
|
TWELVE_HOURS("TwelveHour", "Twelve Hours"),
|
||||||
DAY("day", "Day"),
|
DAY("day", "Day"),
|
||||||
WEEK("week", "Week"),
|
WEEK("week", "Week"),
|
||||||
MONTH("month", "Month"),
|
MONTH("month", "Month"),
|
||||||
THREE_MONTHS("TopThreeMonth", "Top Three Months"),
|
THREE_MONTHS("ThreeMonths", "Three Months"),
|
||||||
SIX_MONTHS("TopSixMonth", "Top Six Months"),
|
SIX_MONTHS("SixMonths", "Six Months"),
|
||||||
NINE_MONTHS("TopNineMonth", "Top Nine Months"),
|
NINE_MONTHS("NineMonths", "Nine Months"),
|
||||||
YEAR("year", "Year"),
|
YEAR("year", "Year"),
|
||||||
ALL("all", "All Time");
|
ALL("all", "All Time");
|
||||||
|
|
||||||
@ -88,5 +88,14 @@ public class SortType {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Time fromValue(String value) {
|
||||||
|
for (Time time : values()) {
|
||||||
|
if (time.value.equalsIgnoreCase(value)) {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
PostFragment fragment = new PostFragment();
|
PostFragment fragment = new PostFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
|
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_USER);
|
||||||
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountName);
|
bundle.putString(PostFragment.EXTRA_USER_NAME, mAccountQualifiedName);
|
||||||
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
|
bundle.putString(PostFragment.EXTRA_USER_WHERE, PostPagingSource.USER_WHERE_SAVED);
|
||||||
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(PostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
@ -293,7 +293,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
}
|
}
|
||||||
CommentsListingFragment fragment = new CommentsListingFragment();
|
CommentsListingFragment fragment = new CommentsListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountName);
|
bundle.putString(CommentsListingFragment.EXTRA_USERNAME, mAccountQualifiedName);
|
||||||
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(CommentsListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
bundle.putString(CommentsListingFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
||||||
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);
|
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);
|
||||||
|
@ -205,7 +205,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||||
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null);
|
miscPlugin, parentTextColor, parentSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||||
binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
|
binding.commentContentMarkdownView.setLayoutManager(new LinearLayoutManagerBugFixed(this));
|
||||||
binding.commentContentMarkdownView.setAdapter(markwonAdapter);
|
binding.commentContentMarkdownView.setAdapter(markwonAdapter);
|
||||||
|
@ -0,0 +1,126 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.adapters.CommentFilterWithUsageRecyclerViewAdapter;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentFilterOptionsBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.DeleteCommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ActivityCommentFilterPreferenceBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterWithUsageViewModel;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class CommentFilterPreferenceActivity extends BaseActivity {
|
||||||
|
|
||||||
|
private ActivityCommentFilterPreferenceBinding binding;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper customThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
|
public CommentFilterWithUsageViewModel commentFilterWithUsageViewModel;
|
||||||
|
private CommentFilterWithUsageRecyclerViewAdapter adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = ActivityCommentFilterPreferenceBinding.inflate(getLayoutInflater());
|
||||||
|
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
setSupportActionBar(binding.toolbarCommentFilterPreferenceActivity);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
binding.fabCommentFilterPreferenceActivity.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, CustomizeCommentFilterActivity.class);
|
||||||
|
intent.putExtra(CustomizeCommentFilterActivity.EXTRA_FROM_SETTINGS, true);
|
||||||
|
startActivity(intent);
|
||||||
|
});
|
||||||
|
|
||||||
|
adapter = new CommentFilterWithUsageRecyclerViewAdapter(this, commentFilter -> {
|
||||||
|
CommentFilterOptionsBottomSheetFragment commentFilterOptionsBottomSheetFragment = new CommentFilterOptionsBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(CommentFilterOptionsBottomSheetFragment.EXTRA_POST_FILTER, commentFilter);
|
||||||
|
commentFilterOptionsBottomSheetFragment.setArguments(bundle);
|
||||||
|
commentFilterOptionsBottomSheetFragment.show(getSupportFragmentManager(), commentFilterOptionsBottomSheetFragment.getTag());
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.recyclerViewCommentFilterPreferenceActivity.setAdapter(adapter);
|
||||||
|
|
||||||
|
commentFilterWithUsageViewModel = new ViewModelProvider(this,
|
||||||
|
new CommentFilterWithUsageViewModel.Factory(redditDataRoomDatabase)).get(CommentFilterWithUsageViewModel.class);
|
||||||
|
|
||||||
|
commentFilterWithUsageViewModel.getCommentFilterWithUsageListLiveData().observe(this, commentFilterWithUsages -> adapter.setCommentFilterWithUsageList(commentFilterWithUsages));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editCommentFilter(CommentFilter commentFilter) {
|
||||||
|
Intent intent = new Intent(this, CustomizeCommentFilterActivity.class);
|
||||||
|
intent.putExtra(CustomizeCommentFilterActivity.EXTRA_COMMENT_FILTER, commentFilter);
|
||||||
|
intent.putExtra(CustomizeCommentFilterActivity.EXTRA_FROM_SETTINGS, true);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyCommentFilterTo(CommentFilter commentFilter) {
|
||||||
|
Intent intent = new Intent(this, CommentFilterUsageListingActivity.class);
|
||||||
|
intent.putExtra(CommentFilterUsageListingActivity.EXTRA_COMMENT_FILTER, commentFilter);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteCommentFilter(CommentFilter commentFilter) {
|
||||||
|
DeleteCommentFilter.deleteCommentFilter(redditDataRoomDatabase, executor, commentFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return customThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCommentFilterPreferenceActivity, binding.collapsingToolbarLayoutCommentFilterPreferenceActivity, binding.toolbarCommentFilterPreferenceActivity);
|
||||||
|
applyFABTheme(binding.fabCommentFilterPreferenceActivity, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
|
binding.getRoot().setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,181 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
import com.google.android.material.textfield.TextInputEditText;
|
||||||
|
import com.google.android.material.textfield.TextInputLayout;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentFilterUsageOptionsBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.NewCommentFilterUsageBottomSheetFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsageViewModel;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.DeleteCommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.SaveCommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ActivityCommentFilterUsageListingBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.adapters.CommentFilterUsageRecyclerViewAdapter;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
|
public class CommentFilterUsageListingActivity extends BaseActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_COMMENT_FILTER = "ECF";
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper customThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
|
private ActivityCommentFilterUsageListingBinding binding;
|
||||||
|
public CommentFilterUsageViewModel commentFilterUsageViewModel;
|
||||||
|
private CommentFilterUsageRecyclerViewAdapter adapter;
|
||||||
|
private CommentFilter commentFilter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = ActivityCommentFilterUsageListingBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
setSupportActionBar(binding.toolbarCommentFilterUsageListingActivity);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
commentFilter = getIntent().getParcelableExtra(EXTRA_COMMENT_FILTER);
|
||||||
|
|
||||||
|
setTitle(commentFilter.name);
|
||||||
|
|
||||||
|
binding.fabCommentFilterUsageListingActivity.setOnClickListener(view -> {
|
||||||
|
NewCommentFilterUsageBottomSheetFragment newCommentFilterUsageBottomSheetFragment = new NewCommentFilterUsageBottomSheetFragment();
|
||||||
|
newCommentFilterUsageBottomSheetFragment.show(getSupportFragmentManager(), newCommentFilterUsageBottomSheetFragment.getTag());
|
||||||
|
});
|
||||||
|
|
||||||
|
adapter = new CommentFilterUsageRecyclerViewAdapter(this, customThemeWrapper, commentFilterUsage -> {
|
||||||
|
CommentFilterUsageOptionsBottomSheetFragment commentFilterUsageOptionsBottomSheetFragment = new CommentFilterUsageOptionsBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(CommentFilterUsageOptionsBottomSheetFragment.EXTRA_COMMENT_FILTER_USAGE, commentFilterUsage);
|
||||||
|
commentFilterUsageOptionsBottomSheetFragment.setArguments(bundle);
|
||||||
|
commentFilterUsageOptionsBottomSheetFragment.show(getSupportFragmentManager(), commentFilterUsageOptionsBottomSheetFragment.getTag());
|
||||||
|
});
|
||||||
|
binding.recyclerViewCommentFilterUsageListingActivity.setAdapter(adapter);
|
||||||
|
|
||||||
|
commentFilterUsageViewModel = new ViewModelProvider(this,
|
||||||
|
new CommentFilterUsageViewModel.Factory(redditDataRoomDatabase, commentFilter.name)).get(CommentFilterUsageViewModel.class);
|
||||||
|
|
||||||
|
commentFilterUsageViewModel.getCommentFilterUsageListLiveData().observe(this, commentFilterUsages -> adapter.setCommentFilterUsages(commentFilterUsages));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void newCommentFilterUsage(int type) {
|
||||||
|
switch (type) {
|
||||||
|
case CommentFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
editAndCommentFilterUsageNameOfUsage(type, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editAndCommentFilterUsageNameOfUsage(int type, String nameOfUsage) {
|
||||||
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_or_comment_filter_name_of_usage, null);
|
||||||
|
TextView messageTextView = dialogView.findViewById(R.id.message_text_view_edit_post_or_comment_filter_name_of_usage_dialog);
|
||||||
|
messageTextView.setVisibility(View.GONE);
|
||||||
|
TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_or_comment_filter_name_of_usage_dialog);
|
||||||
|
TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_or_comment_filter_name_of_usage_dialog);
|
||||||
|
int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
textInputLayout.setBoxStrokeColor(primaryTextColor);
|
||||||
|
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
textInputEditText.setTextColor(primaryTextColor);
|
||||||
|
if (nameOfUsage != null) {
|
||||||
|
textInputEditText.setText(nameOfUsage);
|
||||||
|
}
|
||||||
|
textInputEditText.requestFocus();
|
||||||
|
int titleStringId = R.string.community;
|
||||||
|
switch (type) {
|
||||||
|
case CommentFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
textInputEditText.setHint(R.string.settings_tab_community_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.showKeyboard(this, new Handler(), textInputEditText);
|
||||||
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(titleStringId)
|
||||||
|
.setView(dialogView)
|
||||||
|
.setPositiveButton(R.string.ok, (editTextDialogInterface, i1)
|
||||||
|
-> {
|
||||||
|
Utils.hideKeyboard(this);
|
||||||
|
|
||||||
|
CommentFilterUsage commentFilterUsage;
|
||||||
|
if (!textInputEditText.getText().toString().equals("")) {
|
||||||
|
commentFilterUsage = new CommentFilterUsage(commentFilter.name, type, textInputEditText.getText().toString());
|
||||||
|
SaveCommentFilterUsage.saveCommentFilterUsage(redditDataRoomDatabase, executor, commentFilterUsage);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.setOnDismissListener(editTextDialogInterface -> {
|
||||||
|
Utils.hideKeyboard(this);
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void editCommentFilterUsage(CommentFilterUsage commentFilterUsage) {
|
||||||
|
editAndCommentFilterUsageNameOfUsage(commentFilterUsage.usage, commentFilterUsage.nameOfUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteCommentFilterUsage(CommentFilterUsage commentFilterUsage) {
|
||||||
|
DeleteCommentFilterUsage.deleteCommentFilterUsage(redditDataRoomDatabase, executor, commentFilterUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return sharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return customThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCommentFilterUsageListingActivity, binding.collapsingToolbarLayoutCommentFilterUsageListingActivity, binding.toolbarCommentFilterUsageListingActivity);
|
||||||
|
applyFABTheme(binding.fabCommentFilterUsageListingActivity, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||||
|
binding.getRoot().setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||||
|
}
|
||||||
|
}
|
@ -34,13 +34,13 @@ 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.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||||
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.multireddit.CreateMultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.CreateMultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiRedditJSONModel;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
|
||||||
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.Retrofit;
|
|
||||||
|
|
||||||
public class CreateMultiRedditActivity extends BaseActivity {
|
public class CreateMultiRedditActivity extends BaseActivity {
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
@BindView(R.id.select_subreddit_text_view_create_multi_reddit_activity)
|
@BindView(R.id.select_subreddit_text_view_create_multi_reddit_activity)
|
||||||
TextView selectSubredditTextView;
|
TextView selectSubredditTextView;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("no_oauth")
|
||||||
Retrofit mOauthRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@ -87,14 +87,14 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private ArrayList<String> mSubreddits;
|
private ArrayList<SubredditWithSelection> mSubreddits;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
setImmersiveModeNotApplicable();
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_create_multi_reddit);
|
setContentView(R.layout.activity_create_multi_reddit);
|
||||||
|
|
||||||
@ -114,10 +114,10 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||||
|
|
||||||
|
visibilityLinearLayout.setVisibility(View.GONE);
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
visibilityLinearLayout.setVisibility(View.GONE);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
nameEditText.setImeOptions(nameEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||||
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
descriptionEditText.setImeOptions(descriptionEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
|
||||||
@ -125,7 +125,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mSubreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE);
|
mSubreddits = savedInstanceState.getParcelableArrayList(SELECTED_SUBREDDITS_STATE);
|
||||||
} else {
|
} else {
|
||||||
mSubreddits = new ArrayList<>();
|
mSubreddits = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
private void bindView() {
|
private void bindView() {
|
||||||
selectSubredditTextView.setOnClickListener(view -> {
|
selectSubredditTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(CreateMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
Intent intent = new Intent(CreateMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
||||||
intent.putStringArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, mSubreddits);
|
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, mSubreddits);
|
||||||
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -159,42 +159,29 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAccessToken != null) {
|
// Create a list of community qualified names seperated by a comma
|
||||||
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
|
StringBuilder subredditList = new StringBuilder();
|
||||||
visibilitySwitch.isChecked(), mSubreddits).createJSONModel();
|
String prefix = "";
|
||||||
CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken,
|
for (SubredditWithSelection s : mSubreddits) {
|
||||||
"/user/" + mAccountName + "/m/" + nameEditText.getText().toString(),
|
subredditList.append(prefix);
|
||||||
jsonModel, new CreateMultiReddit.CreateMultiRedditListener() {
|
prefix = ",";
|
||||||
@Override
|
subredditList.append(s.getQualifiedName());
|
||||||
public void success() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed(int errorCode) {
|
|
||||||
if (errorCode == 409) {
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.duplicate_multi_reddit, Snackbar.LENGTH_SHORT).show();
|
|
||||||
} else {
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.create_multi_reddit_failed, Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
CreateMultiReddit.anonymousCreateMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
|
||||||
"/user/-/m/" + nameEditText.getText().toString(),
|
|
||||||
nameEditText.getText().toString(), descriptionEditText.getText().toString(),
|
|
||||||
mSubreddits, new CreateMultiReddit.CreateMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed(int errorType) {
|
|
||||||
//Will not be called
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateMultiReddit.anonymousCreateMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||||
|
mAccountName, subredditList.toString(),
|
||||||
|
nameEditText.getText().toString(), descriptionEditText.getText().toString(),
|
||||||
|
mSubreddits, new CreateMultiReddit.CreateMultiRedditListener() {
|
||||||
|
@Override
|
||||||
|
public void success() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(int errorType) {
|
||||||
|
//Will not be called
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -204,7 +191,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
mSubreddits = data.getStringArrayListExtra(
|
mSubreddits = data.getParcelableArrayListExtra(
|
||||||
SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
|
SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +200,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putStringArrayList(SELECTED_SUBREDDITS_STATE, mSubreddits);
|
outState.putParcelableArrayList(SELECTED_SUBREDDITS_STATE, mSubreddits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,302 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.SaveCommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ActivityCustomizeCommentFilterBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
|
public class CustomizeCommentFilterActivity extends BaseActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_COMMENT_FILTER = "ECF";
|
||||||
|
public static final String EXTRA_FROM_SETTINGS = "EFS";
|
||||||
|
public static final String RETURN_EXTRA_COMMENT_FILTER = "RECF";
|
||||||
|
private static final String COMMENT_FILTER_STATE = "CFS";
|
||||||
|
private static final String ORIGINAL_NAME_STATE = "ONS";
|
||||||
|
@Inject
|
||||||
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
@Named("current_account")
|
||||||
|
SharedPreferences currentAccountSharedPreferences;
|
||||||
|
@Inject
|
||||||
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor mExecutor;
|
||||||
|
private CommentFilter commentFilter;
|
||||||
|
private boolean fromSettings;
|
||||||
|
private String originalName;
|
||||||
|
private ActivityCustomizeCommentFilterBinding binding;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
binding = ActivityCustomizeCommentFilterBinding.inflate(getLayoutInflater());
|
||||||
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
|
applyCustomTheme();
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
|
||||||
|
addOnOffsetChangedListener(binding.appbarLayoutCustomizeCommentFilterActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
setSupportActionBar(binding.toolbarCustomizeCommentFilterActivity);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
setToolbarGoToTop(binding.toolbarCustomizeCommentFilterActivity);
|
||||||
|
|
||||||
|
ActivityResultLauncher<Intent> requestAddUsersLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
|
||||||
|
Intent data = result.getData();
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<String> usernames = data.getStringArrayListExtra(SearchActivity.RETURN_EXTRA_SELECTED_USERNAMES);
|
||||||
|
String currentUsers = binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.getText().toString().trim();
|
||||||
|
if (usernames != null && !usernames.isEmpty()) {
|
||||||
|
if (!currentUsers.isEmpty() && currentUsers.charAt(currentUsers.length() - 1) != ',') {
|
||||||
|
String newString = currentUsers + ",";
|
||||||
|
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.setText(newString);
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (String s : usernames) {
|
||||||
|
stringBuilder.append(s).append(",");
|
||||||
|
}
|
||||||
|
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||||
|
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.append(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.addUsersImageViewCustomizeCommentFilterActivity.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_USERS, true);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_IS_MULTI_SELECTION, true);
|
||||||
|
requestAddUsersLauncher.launch(intent);
|
||||||
|
});
|
||||||
|
|
||||||
|
fromSettings = getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS, false);
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
commentFilter = savedInstanceState.getParcelable(COMMENT_FILTER_STATE);
|
||||||
|
originalName = savedInstanceState.getString(ORIGINAL_NAME_STATE);
|
||||||
|
} else {
|
||||||
|
commentFilter = getIntent().getParcelableExtra(EXTRA_COMMENT_FILTER);
|
||||||
|
if (commentFilter == null) {
|
||||||
|
commentFilter = new CommentFilter();
|
||||||
|
originalName = "";
|
||||||
|
} else {
|
||||||
|
if (!fromSettings) {
|
||||||
|
originalName = "";
|
||||||
|
} else {
|
||||||
|
originalName = commentFilter.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bindView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindView() {
|
||||||
|
binding.nameTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.name);
|
||||||
|
binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.excludeStrings);
|
||||||
|
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.setText(commentFilter.excludeUsers);
|
||||||
|
binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.setText(Integer.toString(commentFilter.minVote));
|
||||||
|
binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.setText(Integer.toString(commentFilter.maxVote));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
|
return mSharedPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||||
|
return mCustomThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applyCustomTheme() {
|
||||||
|
binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
|
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCustomizeCommentFilterActivity, binding.collapsingToolbarLayoutCustomizeCommentFilterActivity, binding.toolbarCustomizeCommentFilterActivity);
|
||||||
|
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||||
|
int primaryIconColor = mCustomThemeWrapper.getPrimaryIconColor();
|
||||||
|
Drawable cursorDrawable = Utils.getTintedDrawable(this, R.drawable.edit_text_cursor, primaryTextColor);
|
||||||
|
binding.nameTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
|
||||||
|
binding.nameTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
binding.nameTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
|
||||||
|
binding.excludeStringsTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
|
||||||
|
binding.excludeStringsTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
|
||||||
|
binding.excludeUsersTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
|
||||||
|
binding.addUsersImageViewCustomizeCommentFilterActivity.setImageDrawable(Utils.getTintedDrawable(this, R.drawable.ic_add_24dp, primaryIconColor));
|
||||||
|
binding.minVoteTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
|
||||||
|
binding.minVoteTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
|
||||||
|
binding.maxVoteTextInputLayoutCustomizeCommentFilterActivity.setBoxStrokeColor(primaryTextColor);
|
||||||
|
binding.maxVoteTextInputLayoutCustomizeCommentFilterActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.setTextColor(primaryTextColor);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
binding.nameTextInputEditTextCustomizeCommentFilterActivity.setTextCursorDrawable(cursorDrawable);
|
||||||
|
binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.setTextCursorDrawable(cursorDrawable);
|
||||||
|
binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.setTextCursorDrawable(cursorDrawable);
|
||||||
|
binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.setTextCursorDrawable(cursorDrawable);
|
||||||
|
binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.setTextCursorDrawable(cursorDrawable);
|
||||||
|
} else {
|
||||||
|
setCursorDrawableColor(binding.nameTextInputEditTextCustomizeCommentFilterActivity, primaryTextColor);
|
||||||
|
setCursorDrawableColor(binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity, primaryTextColor);
|
||||||
|
setCursorDrawableColor(binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity, primaryTextColor);
|
||||||
|
setCursorDrawableColor(binding.minVoteTextInputEditTextCustomizeCommentFilterActivity, primaryTextColor);
|
||||||
|
setCursorDrawableColor(binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity, primaryTextColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeface != null) {
|
||||||
|
Utils.setFontToAllTextViews(binding.getRoot(), typeface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCursorDrawableColor(EditText editText, int color) {
|
||||||
|
try {
|
||||||
|
Field fCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
|
||||||
|
fCursorDrawableRes.setAccessible(true);
|
||||||
|
int mCursorDrawableRes = fCursorDrawableRes.getInt(editText);
|
||||||
|
Field fEditor = TextView.class.getDeclaredField("mEditor");
|
||||||
|
fEditor.setAccessible(true);
|
||||||
|
Object editor = fEditor.get(editText);
|
||||||
|
Class<?> clazz = editor.getClass();
|
||||||
|
Field fCursorDrawable = clazz.getDeclaredField("mCursorDrawable");
|
||||||
|
fCursorDrawable.setAccessible(true);
|
||||||
|
Drawable[] drawables = new Drawable[2];
|
||||||
|
drawables[0] = editText.getContext().getResources().getDrawable(mCursorDrawableRes);
|
||||||
|
drawables[1] = editText.getContext().getResources().getDrawable(mCursorDrawableRes);
|
||||||
|
drawables[0].setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
|
drawables[1].setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||||
|
fCursorDrawable.set(editor, drawables);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.customize_comment_filter_activity, menu);
|
||||||
|
if (fromSettings) {
|
||||||
|
menu.findItem(R.id.action_save_customize_comment_filter_activity).setVisible(false);
|
||||||
|
}
|
||||||
|
applyMenuItemTheme(menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.action_save_customize_comment_filter_activity) {
|
||||||
|
try {
|
||||||
|
constructCommentFilter();
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(RETURN_EXTRA_COMMENT_FILTER, commentFilter);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
} catch (PatternSyntaxException e) {
|
||||||
|
Toast.makeText(this, R.string.invalid_regex, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.action_save_to_database_customize_comment_filter_activity) {
|
||||||
|
try {
|
||||||
|
constructCommentFilter();
|
||||||
|
|
||||||
|
if (!commentFilter.name.equals("")) {
|
||||||
|
saveCommentFilter(originalName);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(CustomizeCommentFilterActivity.this, R.string.comment_filter_requires_a_name, Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
} catch (PatternSyntaxException e) {
|
||||||
|
Toast.makeText(this, R.string.invalid_regex, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveCommentFilter(String originalName) {
|
||||||
|
SaveCommentFilter.saveCommentFilter(mExecutor, new Handler(), mRedditDataRoomDatabase, commentFilter, originalName,
|
||||||
|
new SaveCommentFilter.SaveCommentFilterListener() {
|
||||||
|
@Override
|
||||||
|
public void success() {
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(RETURN_EXTRA_COMMENT_FILTER, commentFilter);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void duplicate() {
|
||||||
|
new MaterialAlertDialogBuilder(CustomizeCommentFilterActivity.this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(getString(R.string.duplicate_comment_filter_dialog_title, commentFilter.name))
|
||||||
|
.setMessage(R.string.duplicate_comment_filter_dialog_message)
|
||||||
|
.setPositiveButton(R.string.override, (dialogInterface, i) -> saveCommentFilter(commentFilter.name))
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void constructCommentFilter() throws PatternSyntaxException {
|
||||||
|
commentFilter.name = binding.nameTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
|
||||||
|
commentFilter.excludeStrings = binding.excludeStringsTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
|
||||||
|
commentFilter.excludeUsers = binding.excludeUsersTextInputEditTextCustomizeCommentFilterActivity.getText().toString();
|
||||||
|
commentFilter.maxVote = binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText() == null || binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString().equals("") ? -1 : Integer.parseInt(binding.maxVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString());
|
||||||
|
commentFilter.minVote = binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.getText() == null || binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString().equals("") ? -1 : Integer.parseInt(binding.minVoteTextInputEditTextCustomizeCommentFilterActivity.getText().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelable(COMMENT_FILTER_STATE, commentFilter);
|
||||||
|
outState.putString(ORIGINAL_NAME_STATE, originalName);
|
||||||
|
}
|
||||||
|
}
|
@ -226,10 +226,6 @@ public class CustomizePostFilterActivity extends BaseActivity {
|
|||||||
|
|
||||||
applyCustomTheme();
|
applyCustomTheme();
|
||||||
|
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
|
||||||
Slidr.attach(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
|
||||||
addOnOffsetChangedListener(appBarLayout);
|
addOnOffsetChangedListener(appBarLayout);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
|||||||
import eu.toldi.infinityforlemmy.multireddit.EditMultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.EditMultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.FetchMultiRedditInfo;
|
import eu.toldi.infinityforlemmy.multireddit.FetchMultiRedditInfo;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiRedditJSONModel;
|
|
||||||
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.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -123,7 +122,7 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||||
|
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
visibilityLinearLayout.setVisibility(View.GONE);
|
visibilityLinearLayout.setVisibility(View.GONE);
|
||||||
@ -145,41 +144,24 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void bindView() {
|
private void bindView() {
|
||||||
if (multiReddit == null) {
|
if (multiReddit == null) {
|
||||||
if (mAccessToken == null) {
|
|
||||||
FetchMultiRedditInfo.anonymousFetchMultiRedditInfo(mExecutor, new Handler(),
|
|
||||||
mRedditDataRoomDatabase, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
|
|
||||||
@Override
|
|
||||||
public void success(MultiReddit multiReddit) {
|
|
||||||
EditMultiRedditActivity.this.multiReddit = multiReddit;
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
linearLayout.setVisibility(View.VISIBLE);
|
|
||||||
nameEditText.setText(multiReddit.getDisplayName());
|
|
||||||
descriptionEditText.setText(multiReddit.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
FetchMultiRedditInfo.anonymousFetchMultiRedditInfo(mExecutor, new Handler(),
|
||||||
public void failed() {
|
mRedditDataRoomDatabase, multipath, mAccountName, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
|
||||||
//Will not be called
|
@Override
|
||||||
}
|
public void success(MultiReddit multiReddit) {
|
||||||
});
|
EditMultiRedditActivity.this.multiReddit = multiReddit;
|
||||||
} else {
|
progressBar.setVisibility(View.GONE);
|
||||||
FetchMultiRedditInfo.fetchMultiRedditInfo(mRetrofit, mAccessToken, multipath, new FetchMultiRedditInfo.FetchMultiRedditInfoListener() {
|
linearLayout.setVisibility(View.VISIBLE);
|
||||||
@Override
|
nameEditText.setText(multiReddit.getDisplayName());
|
||||||
public void success(MultiReddit multiReddit) {
|
descriptionEditText.setText(multiReddit.getDescription());
|
||||||
EditMultiRedditActivity.this.multiReddit = multiReddit;
|
}
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
linearLayout.setVisibility(View.VISIBLE);
|
@Override
|
||||||
nameEditText.setText(multiReddit.getDisplayName());
|
public void failed() {
|
||||||
descriptionEditText.setText(multiReddit.getDescription());
|
//Will not be called
|
||||||
visibilitySwitch.setChecked(!multiReddit.getVisibility().equals("public"));
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed() {
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.cannot_fetch_multireddit, Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
linearLayout.setVisibility(View.VISIBLE);
|
linearLayout.setVisibility(View.VISIBLE);
|
||||||
@ -191,7 +173,7 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
selectSubredditTextView.setOnClickListener(view -> {
|
selectSubredditTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
|
||||||
if (multiReddit.getSubreddits() != null) {
|
if (multiReddit.getSubreddits() != null) {
|
||||||
intent.putStringArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
|
intent.putParcelableArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, multiReddit.getSubreddits());
|
||||||
}
|
}
|
||||||
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
||||||
});
|
});
|
||||||
@ -216,39 +198,24 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAccessToken == null) {
|
|
||||||
String name = nameEditText.getText().toString();
|
|
||||||
multiReddit.setDisplayName(name);
|
|
||||||
multiReddit.setName(name);
|
|
||||||
multiReddit.setDescription(descriptionEditText.getText().toString());
|
|
||||||
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
|
||||||
multiReddit, new EditMultiReddit.EditMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
String name = nameEditText.getText().toString();
|
||||||
public void failed() {
|
multiReddit.setDisplayName(name);
|
||||||
//Will not be called
|
multiReddit.setName(name);
|
||||||
}
|
multiReddit.setDescription(descriptionEditText.getText().toString());
|
||||||
});
|
EditMultiReddit.anonymousEditMultiReddit(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||||
} else {
|
multiReddit, new EditMultiReddit.EditMultiRedditListener() {
|
||||||
String jsonModel = new MultiRedditJSONModel(nameEditText.getText().toString(), descriptionEditText.getText().toString(),
|
@Override
|
||||||
visibilitySwitch.isChecked(), multiReddit.getSubreddits()).createJSONModel();
|
public void success() {
|
||||||
EditMultiReddit.editMultiReddit(mRetrofit, mAccessToken, multiReddit.getPath(),
|
finish();
|
||||||
jsonModel, new EditMultiReddit.EditMultiRedditListener() {
|
}
|
||||||
@Override
|
|
||||||
public void success() {
|
@Override
|
||||||
finish();
|
public void failed() {
|
||||||
}
|
//Will not be called
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed() {
|
|
||||||
Snackbar.make(coordinatorLayout, R.string.edit_multi_reddit_failed, Snackbar.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -259,7 +226,7 @@ public class EditMultiRedditActivity extends BaseActivity {
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
|
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE && resultCode == RESULT_OK) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
multiReddit.setSubreddits(data.getStringArrayListExtra(
|
multiReddit.setSubreddits(data.getParcelableArrayListExtra(
|
||||||
SelectedSubredditsAndUsersActivity.EXTRA_RETURN_SELECTED_SUBREDDITS));
|
SelectedSubredditsAndUsersActivity.EXTRA_RETURN_SELECTED_SUBREDDITS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
Markwon markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||||
miscPlugin, markdownColor, spoilerBackgroundColor, null);
|
miscPlugin, markdownColor, spoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
|
|
||||||
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||||
|
@ -1,336 +0,0 @@
|
|||||||
package eu.toldi.infinityforlemmy.activities;
|
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
|
||||||
|
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
|
||||||
import com.google.android.material.tabs.TabLayout;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostLayoutBottomSheetFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|
||||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
|
||||||
import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
|
||||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
|
||||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.fragments.HistoryPostFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
|
||||||
|
|
||||||
public class HistoryActivity extends BaseActivity implements ActivityToolbarInterface,
|
|
||||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback {
|
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_history_activity)
|
|
||||||
CoordinatorLayout coordinatorLayout;
|
|
||||||
@BindView(R.id.appbar_layout_history_activity)
|
|
||||||
AppBarLayout appBarLayout;
|
|
||||||
@BindView(R.id.collapsing_toolbar_layout_history_activity)
|
|
||||||
CollapsingToolbarLayout collapsingToolbarLayout;
|
|
||||||
@BindView(R.id.toolbar_history_activity)
|
|
||||||
Toolbar toolbar;
|
|
||||||
@BindView(R.id.tab_layout_tab_layout_history_activity_activity)
|
|
||||||
TabLayout tabLayout;
|
|
||||||
@BindView(R.id.view_pager_history_activity)
|
|
||||||
ViewPager2 viewPager2;
|
|
||||||
@Inject
|
|
||||||
@Named("default")
|
|
||||||
SharedPreferences mSharedPreferences;
|
|
||||||
@Inject
|
|
||||||
@Named("post_layout")
|
|
||||||
SharedPreferences mPostLayoutSharedPreferences;
|
|
||||||
@Inject
|
|
||||||
@Named("current_account")
|
|
||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
|
||||||
@Inject
|
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
|
||||||
private FragmentManager fragmentManager;
|
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
|
||||||
private String mAccessToken;
|
|
||||||
private String mAccountName;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.activity_history);
|
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
|
||||||
|
|
||||||
EventBus.getDefault().register(this);
|
|
||||||
|
|
||||||
applyCustomTheme();
|
|
||||||
|
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
|
|
||||||
mSliderPanel = Slidr.attach(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//mViewPager2 = viewPager2;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
setToolbarGoToTop(toolbar);
|
|
||||||
|
|
||||||
fragmentManager = getSupportFragmentManager();
|
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
|
||||||
|
|
||||||
initializeViewPager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
||||||
if (sectionsPagerAdapter != null) {
|
|
||||||
return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeViewPager() {
|
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
|
||||||
tabLayout.setVisibility(View.GONE);
|
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
|
||||||
viewPager2.setOffscreenPageLimit(2);
|
|
||||||
//viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
|
||||||
viewPager2.setUserInputEnabled(false);
|
|
||||||
/*new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.posts));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}).attach();*/
|
|
||||||
|
|
||||||
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
|
||||||
@Override
|
|
||||||
public void onPageSelected(int position) {
|
|
||||||
if (position == 0) {
|
|
||||||
unlockSwipeRightToGoBack();
|
|
||||||
} else {
|
|
||||||
lockSwipeRightToGoBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
fixViewPager2Sensitivity(viewPager2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
getMenuInflater().inflate(R.menu.history_activity, menu);
|
|
||||||
applyMenuItemTheme(menu);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
||||||
int itemId = item.getItemId();
|
|
||||||
if (itemId == android.R.id.home) {
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
} else if (itemId == R.id.action_refresh_history_activity) {
|
|
||||||
sectionsPagerAdapter.refresh();
|
|
||||||
return true;
|
|
||||||
} else if (itemId == R.id.action_change_post_layout_history_activity) {
|
|
||||||
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
|
|
||||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
EventBus.getDefault().unregister(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onAccountSwitchEvent(SwitchAccountEvent event) {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) {
|
|
||||||
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postLayoutSelected(int postLayout) {
|
|
||||||
if (sectionsPagerAdapter != null) {
|
|
||||||
mPostLayoutSharedPreferences.edit().putInt(SharedPreferencesUtils.HISTORY_POST_LAYOUT_READ_POST, postLayout).apply();
|
|
||||||
sectionsPagerAdapter.changePostLayout(postLayout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
|
||||||
|
|
||||||
SectionsPagerAdapter(FragmentActivity fa) {
|
|
||||||
super(fa);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Fragment createFragment(int position) {
|
|
||||||
if (position == 0) {
|
|
||||||
HistoryPostFragment fragment = new HistoryPostFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(HistoryPostFragment.EXTRA_HISTORY_TYPE, HistoryPostFragment.HISTORY_TYPE_READ_POSTS);
|
|
||||||
bundle.putString(HistoryPostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(HistoryPostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
} else {
|
|
||||||
HistoryPostFragment fragment = new HistoryPostFragment();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(HistoryPostFragment.EXTRA_HISTORY_TYPE, HistoryPostFragment.HISTORY_TYPE_READ_POSTS);
|
|
||||||
bundle.putString(HistoryPostFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
|
||||||
bundle.putString(HistoryPostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private Fragment getCurrentFragment() {
|
|
||||||
if (viewPager2 == null || fragmentManager == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return fragmentManager.findFragmentByTag("f" + viewPager2.getCurrentItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean handleKeyDown(int keyCode) {
|
|
||||||
if (viewPager2.getCurrentItem() == 0) {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof PostFragment) {
|
|
||||||
return ((PostFragment) fragment).handleKeyDown(keyCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refresh() {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof PostFragment) {
|
|
||||||
((PostFragment) fragment).refresh();
|
|
||||||
} else if (fragment instanceof CommentsListingFragment) {
|
|
||||||
((CommentsListingFragment) fragment).refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeNSFW(boolean nsfw) {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof PostFragment) {
|
|
||||||
((PostFragment) fragment).changeNSFW(nsfw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changePostLayout(int postLayout) {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof HistoryPostFragment) {
|
|
||||||
((HistoryPostFragment) fragment).changePostLayout(postLayout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void goBackToTop() {
|
|
||||||
Fragment fragment = getCurrentFragment();
|
|
||||||
if (fragment instanceof PostFragment) {
|
|
||||||
((PostFragment) fragment).goBackToTop();
|
|
||||||
} else if (fragment instanceof CommentsListingFragment) {
|
|
||||||
((CommentsListingFragment) fragment).goBackToTop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -149,7 +149,7 @@ public class InstanceInfoActivity extends BaseActivity {
|
|||||||
};
|
};
|
||||||
|
|
||||||
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||||
miscPlugin, markdownColor, postSpoilerBackgroundColor, null);
|
miscPlugin, markdownColor, postSpoilerBackgroundColor, null, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
|
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||||
mContentMarkdownView.setAdapter(mMarkwonAdapter);
|
mContentMarkdownView.setAdapter(mMarkwonAdapter);
|
||||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
|
||||||
|
@ -36,6 +36,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
|||||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||||
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
|
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
|
||||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
@ -83,6 +84,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
PostEnricher postEnricher;
|
||||||
|
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
|
|
||||||
private Uri getRedditUriByPath(String path) {
|
private Uri getRedditUriByPath(String path) {
|
||||||
@ -102,6 +106,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
if (mAccessToken != null) {
|
if (mAccessToken != null) {
|
||||||
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||||
mRetrofit.setBaseURL(instance);
|
mRetrofit.setBaseURL(instance);
|
||||||
|
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
|
||||||
|
mRetrofit.setAccessToken(mAccessToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
@ -214,7 +221,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
URL baseURL = new URL(mRetrofit.getBaseURL());
|
URL baseURL = new URL(mRetrofit.getBaseURL());
|
||||||
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
|
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
|
||||||
local = true;
|
local = true;
|
||||||
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), segments.get(segments.size() - 1), mAccessToken, new FetchPost.FetchPostListener() {
|
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), segments.get(segments.size() - 1), mAccessToken, postEnricher, new FetchPost.FetchPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchPostSuccess(Post post) {
|
public void fetchPostSuccess(Post post) {
|
||||||
|
|
||||||
@ -335,64 +342,6 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_V_REDD_IT_URL, uri.toString());
|
intent.putExtra(ViewVideoActivity.EXTRA_V_REDD_IT_URL, uri.toString());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app")) {
|
|
||||||
if (authority.equals("reddit.app.link") && path.isEmpty()) {
|
|
||||||
String redirect = uri.getQueryParameter("$og_redirect");
|
|
||||||
if (redirect != null) {
|
|
||||||
handleUri(Uri.parse(redirect));
|
|
||||||
} else {
|
|
||||||
deepLinkError(uri);
|
|
||||||
}
|
|
||||||
} else if (path.isEmpty()) {
|
|
||||||
Intent intent = new Intent(this, MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (path.equals("/report")) {
|
|
||||||
openInWebView(uri);
|
|
||||||
} else if (path.matches(POST_PATTERN_3)) {
|
|
||||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (path.matches(WIKI_PATTERN)) {
|
|
||||||
String[] pathSegments = path.split("/");
|
|
||||||
String wikiPage;
|
|
||||||
if (pathSegments.length == 4) {
|
|
||||||
wikiPage = "index";
|
|
||||||
} else {
|
|
||||||
int lengthThroughWiki = 0;
|
|
||||||
for (int i = 1; i <= 3; ++i) {
|
|
||||||
lengthThroughWiki += pathSegments[i].length() + 1;
|
|
||||||
}
|
|
||||||
wikiPage = path.substring(lengthThroughWiki);
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(this, WikiActivity.class);
|
|
||||||
intent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, segments.get(1));
|
|
||||||
intent.putExtra(WikiActivity.EXTRA_WIKI_PATH, wikiPage);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (path.matches(SIDEBAR_PATTERN)) {
|
|
||||||
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
|
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3, path.length() - 14));
|
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_VIEW_SIDEBAR, true);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (path.matches(MULTIREDDIT_PATTERN)) {
|
|
||||||
Intent intent = new Intent(this, ViewMultiRedditDetailActivity.class);
|
|
||||||
intent.putExtra(ViewMultiRedditDetailActivity.EXTRA_MULTIREDDIT_PATH, path);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (path.matches(MULTIREDDIT_PATTERN_2)) {
|
|
||||||
String subredditName = path.substring(3);
|
|
||||||
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
|
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
|
||||||
startActivity(intent);
|
|
||||||
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
|
|
||||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
|
||||||
startActivity(intent);
|
|
||||||
} else {
|
|
||||||
deepLinkError(uri);
|
|
||||||
}
|
|
||||||
} else if (authority.equals("click.redditmail.com")) {
|
} else if (authority.equals("click.redditmail.com")) {
|
||||||
if (path.startsWith("/CL0/")) {
|
if (path.startsWith("/CL0/")) {
|
||||||
handleUri(Uri.parse(path.substring("/CL0/".length())));
|
handleUri(Uri.parse(path.substring("/CL0/".length())));
|
||||||
@ -481,7 +430,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
String authority = uri.getAuthority();
|
String authority = uri.getAuthority();
|
||||||
if(authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app.link"))) {
|
if(authority != null && (authority.contains("reddit.com") || authority.contains("redd.it") || authority.contains("reddit.app.link"))) {
|
||||||
openInCustomTabs(uri, pm, false);
|
openInBrowser(uri, pm, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,15 +8,16 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
|
||||||
import android.view.InflateException;
|
import android.view.InflateException;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
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.widget.AppCompatAutoCompleteTextView;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
@ -29,6 +30,8 @@ import org.json.JSONObject;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
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;
|
||||||
@ -41,11 +44,15 @@ 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.adapters.CustomArrayAdapter;
|
||||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.ParseAndInsertNewAccount;
|
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.lemmyverse.FetchInstancesListener;
|
||||||
|
import eu.toldi.infinityforlemmy.lemmyverse.LemmyInstance;
|
||||||
|
import eu.toldi.infinityforlemmy.lemmyverse.LemmyVerseFetchInstances;
|
||||||
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
import eu.toldi.infinityforlemmy.site.FetchSiteInfo;
|
||||||
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
import eu.toldi.infinityforlemmy.site.SiteInfo;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
@ -70,7 +77,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
TextView twoFAInfoTextView;
|
TextView twoFAInfoTextView;
|
||||||
|
|
||||||
@BindView(R.id.instance_url_input)
|
@BindView(R.id.instance_url_input)
|
||||||
TextInputEditText instance_input;
|
AppCompatAutoCompleteTextView instance_input;
|
||||||
@BindView(R.id.username_input)
|
@BindView(R.id.username_input)
|
||||||
TextInputEditText username_input;
|
TextInputEditText username_input;
|
||||||
@BindView(R.id.user_password_input)
|
@BindView(R.id.user_password_input)
|
||||||
@ -87,9 +94,11 @@ public class LoginActivity extends BaseActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
@Named("no_oauth")
|
@Named("no_oauth")
|
||||||
RetrofitHolder mRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("lemmyVerse")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mLemmyVerseRetrofit;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@ -140,9 +149,23 @@ public class LoginActivity extends BaseActivity {
|
|||||||
isAgreeToUserAgreement = savedInstanceState.getBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE);
|
isAgreeToUserAgreement = savedInstanceState.getBoolean(IS_AGREE_TO_USER_AGGREMENT_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LemmyVerseFetchInstances.INSTANCE.fetchInstances(mLemmyVerseRetrofit, new FetchInstancesListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFetchInstancesSuccess(@NonNull List<LemmyInstance> instances) {
|
||||||
|
ArrayList<String> instanceNames = new ArrayList<>();
|
||||||
|
for (LemmyInstance instance : instances) {
|
||||||
|
instanceNames.add(instance.getFqdn());
|
||||||
|
}
|
||||||
|
ArrayAdapter<String> adapter = new CustomArrayAdapter(LoginActivity.this, android.R.layout.simple_dropdown_item_1line, instanceNames, mCustomThemeWrapper);
|
||||||
|
instance_input.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
loginButton.setOnClickListener(view -> {
|
loginButton.setOnClickListener(view -> {
|
||||||
Log.i("LoginActivity", "Login button clicked");
|
Log.i("LoginActivity", "Login button clicked");
|
||||||
if(!checkFields())
|
if (!checkFields())
|
||||||
return;
|
return;
|
||||||
loginButton.setEnabled(false);
|
loginButton.setEnabled(false);
|
||||||
progressBar.setVisibility(ProgressBar.VISIBLE);
|
progressBar.setVisibility(ProgressBar.VISIBLE);
|
||||||
@ -180,6 +203,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
try {
|
try {
|
||||||
JSONObject responseJSON = new JSONObject(accountResponse);
|
JSONObject responseJSON = new JSONObject(accountResponse);
|
||||||
String accessToken = responseJSON.getString("jwt");
|
String accessToken = responseJSON.getString("jwt");
|
||||||
|
mRetrofit.setAccessToken(null);
|
||||||
|
|
||||||
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
|
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
|
||||||
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
accessToken, new FetchMyInfo.FetchMyInfoListener() {
|
||||||
@ -189,13 +213,23 @@ public class LoginActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||||
boolean canDownvote = siteInfo.isEnable_downvotes();
|
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||||
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,canDownvote, mRedditDataRoomDatabase.accountDao(),
|
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name, display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance, canDownvote, mRedditDataRoomDatabase.accountDao(),
|
||||||
() -> {
|
() -> {
|
||||||
Intent resultIntent = new Intent();
|
Intent resultIntent = new Intent();
|
||||||
setResult(Activity.RESULT_OK, resultIntent);
|
setResult(Activity.RESULT_OK, resultIntent);
|
||||||
finish();
|
finish();
|
||||||
});
|
});
|
||||||
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||||
|
String[] version = siteInfo.getVersion().split("\\.");
|
||||||
|
if (version.length > 0) {
|
||||||
|
Log.d("SwitchAccount", "Lemmy Version: " + version[0] + "." + version[1]);
|
||||||
|
int majorVersion = Integer.parseInt(version[0]);
|
||||||
|
int minorVersion = Integer.parseInt(version[1]);
|
||||||
|
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
|
||||||
|
mRetrofit.setAccessToken(accessToken);
|
||||||
|
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -328,6 +362,7 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
twoFAInfoTextView.setTypeface(typeface);
|
twoFAInfoTextView.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
|
instance_input.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,6 +33,7 @@ import androidx.appcompat.app.AppCompatDelegate;
|
|||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.splashscreen.SplashScreen;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
@ -249,6 +250,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
SplashScreen.installSplashScreen(this);
|
||||||
|
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);
|
setTheme(R.style.AppTheme_NoActionBarWithTransparentStatusBar);
|
||||||
@ -336,11 +339,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
fragmentManager = getSupportFragmentManager();
|
fragmentManager = getSupportFragmentManager();
|
||||||
|
|
||||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||||
|
mRetrofit.setAccessToken(mAccessToken);
|
||||||
|
|
||||||
|
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||||
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
String instance = (mAccessToken == null) ? mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI) : mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
|
||||||
if(instance != null) {
|
if (instance != null) {
|
||||||
mRetrofit.setBaseURL(instance);
|
mRetrofit.setBaseURL(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,8 +826,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
} 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) {
|
|
||||||
intent = new Intent(MainActivity.this, HistoryActivity.class);
|
|
||||||
} else if (stringId == R.string.trending) {
|
} else if (stringId == R.string.trending) {
|
||||||
intent = new Intent(MainActivity.this, TrendingActivity.class);
|
intent = new Intent(MainActivity.this, TrendingActivity.class);
|
||||||
} else if (stringId == R.string.upvoted) {
|
} else if (stringId == R.string.upvoted) {
|
||||||
@ -924,7 +927,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
|
sectionsPagerAdapter = new SectionsPagerAdapter(this, tabCount, mShowFavoriteMultiReddits,
|
||||||
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
|
mShowMultiReddits, mShowFavoriteSubscribedSubreddits, mShowSubscribedSubreddits);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(1);
|
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
||||||
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
|
viewPager2.setUserInputEnabled(!mDisableSwipingBetweenTabs);
|
||||||
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
|
if (mMainActivityTabsSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.MAIN_PAGE_SHOW_TAB_NAMES, true)) {
|
||||||
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
|
if (mShowFavoriteMultiReddits || mShowMultiReddits || mShowFavoriteSubscribedSubreddits || mShowSubscribedSubreddits) {
|
||||||
@ -1511,7 +1514,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
|
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1569,7 +1577,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -1590,7 +1602,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
|
String qualifiedName = thingEditText.getText().toString();
|
||||||
|
if (qualifiedName.startsWith("@")) {
|
||||||
|
qualifiedName = qualifiedName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1603,7 +1619,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
|
String qualifiedName = thingEditText.getText().toString();
|
||||||
|
if (qualifiedName.startsWith("@")) {
|
||||||
|
qualifiedName = qualifiedName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -1646,7 +1666,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void doNotShowRedditAPIInfoAgain() {
|
public void doNotShowRedditAPIInfoAgain() {
|
||||||
mInternalSharedPreferences.edit().putBoolean(SharedPreferencesUtils.DO_NOT_SHOW_REDDIT_API_INFO_AGAIN, true).apply();
|
mInternalSharedPreferences.edit().putBoolean(SharedPreferencesUtils.DO_NOT_SHOW_REDDIT_API_INFO_V2_AGAIN, true).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||||
|
@ -117,7 +117,7 @@ public class MultiredditSelectionActivity extends BaseActivity implements Activi
|
|||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
bindView(true);
|
bindView(true);
|
||||||
|
@ -8,6 +8,7 @@ import android.view.MenuItem;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -26,13 +28,14 @@ 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.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.adapters.PostFilterRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.PostFilterWithUsageRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostFilterOptionsBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.PostFilterOptionsBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
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.PostFilterWithUsageViewModel;
|
||||||
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterWithUsage;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class PostFilterPreferenceActivity extends BaseActivity {
|
public class PostFilterPreferenceActivity extends BaseActivity {
|
||||||
@ -62,8 +65,8 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
CustomThemeWrapper customThemeWrapper;
|
CustomThemeWrapper customThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor executor;
|
Executor executor;
|
||||||
public PostFilterViewModel postFilterViewModel;
|
public PostFilterWithUsageViewModel postFilterWithUsageViewModel;
|
||||||
private PostFilterRecyclerViewAdapter adapter;
|
private PostFilterWithUsageRecyclerViewAdapter adapter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -99,7 +102,7 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new PostFilterRecyclerViewAdapter(this, customThemeWrapper, postFilter -> {
|
adapter = new PostFilterWithUsageRecyclerViewAdapter(this, customThemeWrapper, postFilter -> {
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
showPostFilterOptions(post, postFilter);
|
showPostFilterOptions(post, postFilter);
|
||||||
} else if (subredditName != null) {
|
} else if (subredditName != null) {
|
||||||
@ -117,10 +120,15 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
|||||||
|
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
postFilterViewModel = new ViewModelProvider(this,
|
postFilterWithUsageViewModel = new ViewModelProvider(this,
|
||||||
new PostFilterViewModel.Factory(redditDataRoomDatabase)).get(PostFilterViewModel.class);
|
new PostFilterWithUsageViewModel.Factory(redditDataRoomDatabase)).get(PostFilterWithUsageViewModel.class);
|
||||||
|
|
||||||
postFilterViewModel.getPostFilterListLiveData().observe(this, postFilters -> adapter.setPostFilterList(postFilters));
|
postFilterWithUsageViewModel.getPostFilterWithUsageListLiveData().observe(this, new Observer<List<PostFilterWithUsage>>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(List<PostFilterWithUsage> postFilterWithUsages) {
|
||||||
|
adapter.setPostFilterWithUsageList(postFilterWithUsages);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPostFilterOptions(Post post, PostFilter postFilter) {
|
public void showPostFilterOptions(Post post, PostFilter postFilter) {
|
||||||
|
@ -126,9 +126,9 @@ public class PostFilterUsageListingActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editAndPostFilterUsageNameOfUsage(int type, String nameOfUsage) {
|
private void editAndPostFilterUsageNameOfUsage(int type, String nameOfUsage) {
|
||||||
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_filter_name_of_usage, null);
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_edit_post_or_comment_filter_name_of_usage, null);
|
||||||
TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_filter_name_of_usage_dialog);
|
TextInputLayout textInputLayout = dialogView.findViewById(R.id.text_input_layout_edit_post_or_comment_filter_name_of_usage_dialog);
|
||||||
TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_filter_name_of_usage_dialog);
|
TextInputEditText textInputEditText = dialogView.findViewById(R.id.text_input_edit_text_edit_post_or_comment_filter_name_of_usage_dialog);
|
||||||
int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
int primaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
textInputLayout.setBoxStrokeColor(primaryTextColor);
|
textInputLayout.setBoxStrokeColor(primaryTextColor);
|
||||||
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
textInputLayout.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
|
||||||
|
@ -132,7 +132,7 @@ public class RulesActivity extends BaseActivity {
|
|||||||
|
|
||||||
mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
mSubredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
|
|
||||||
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel);
|
mAdapter = new RulesRecyclerViewAdapter(this, mCustomThemeWrapper, sliderPanel, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mSubredditName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,7 @@ package eu.toldi.infinityforlemmy.activities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.ColorStateList;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -27,11 +28,14 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
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 org.greenrobot.eventbus.EventBus;
|
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.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -47,13 +51,14 @@ import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
|||||||
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.events.SwitchAccountEvent;
|
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||||
import eu.toldi.infinityforlemmy.recentsearchquery.DeleteRecentSearchQuery;
|
|
||||||
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
|
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.subreddit.SubredditWithSelection;
|
||||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
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;
|
||||||
@ -98,6 +103,8 @@ public class SearchActivity extends BaseActivity {
|
|||||||
ImageView clearSearchTextImageView;
|
ImageView clearSearchTextImageView;
|
||||||
@BindView(R.id.link_handler_image_view_search_activity)
|
@BindView(R.id.link_handler_image_view_search_activity)
|
||||||
ImageView linkHandlerImageView;
|
ImageView linkHandlerImageView;
|
||||||
|
@BindView(R.id.delete_all_recent_searches_button_search_activity)
|
||||||
|
MaterialButton deleteAllSearchesButton;
|
||||||
@BindView(R.id.subreddit_name_relative_layout_search_activity)
|
@BindView(R.id.subreddit_name_relative_layout_search_activity)
|
||||||
RelativeLayout subredditNameRelativeLayout;
|
RelativeLayout subredditNameRelativeLayout;
|
||||||
@BindView(R.id.search_in_text_view_search_activity)
|
@BindView(R.id.search_in_text_view_search_activity)
|
||||||
@ -124,6 +131,8 @@ public class SearchActivity extends BaseActivity {
|
|||||||
SharedPreferences mNsfwAndSpoilerSharedPreferences;
|
SharedPreferences mNsfwAndSpoilerSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String query;
|
private String query;
|
||||||
@ -163,6 +172,7 @@ public class SearchActivity extends BaseActivity {
|
|||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
clearSearchTextImageView.setVisibility(View.GONE);
|
clearSearchTextImageView.setVisibility(View.GONE);
|
||||||
|
deleteAllSearchesButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
|
searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false);
|
||||||
searchOnlyUsers = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_USERS, false);
|
searchOnlyUsers = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_USERS, false);
|
||||||
@ -182,9 +192,9 @@ public class SearchActivity extends BaseActivity {
|
|||||||
if (searchOnlySubreddits) {
|
if (searchOnlySubreddits) {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
|
if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) {
|
||||||
ArrayList<String> subredditNameList = new ArrayList<>();
|
ArrayList<SubredditWithSelection> subredditNameList = new ArrayList<>();
|
||||||
subredditNameList.add(subredditData.getName());
|
subredditNameList.add(new SubredditWithSelection(subredditData.getName(), subredditData.getIconUrl(), LemmyUtils.actorID2FullName(subredditData.getActorId())));
|
||||||
returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
|
returnIntent.putParcelableArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, subredditNameList);
|
||||||
} else {
|
} else {
|
||||||
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, new SubscribedSubredditData(subredditData));
|
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());
|
||||||
@ -276,6 +286,17 @@ public class SearchActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deleteAllSearchesButton.setOnClickListener(view -> {
|
||||||
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
|
.setTitle(R.string.confirm)
|
||||||
|
.setMessage(R.string.confirm_delete_all_recent_searches)
|
||||||
|
.setPositiveButton(R.string.yes, (dialogInterface, i) -> {
|
||||||
|
executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().deleteAllRecentSearchQueries(mAccountName));
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.no, null)
|
||||||
|
.show();
|
||||||
|
});
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
@ -319,7 +340,7 @@ public class SearchActivity extends BaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDelete(RecentSearchQuery recentSearchQuery) {
|
public void onDelete(RecentSearchQuery recentSearchQuery) {
|
||||||
DeleteRecentSearchQuery.deleteRecentSearchQueryListener(mRedditDataRoomDatabase, recentSearchQuery, () -> {});
|
executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().deleteRecentSearchQueries(recentSearchQuery));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recyclerView.setVisibility(View.VISIBLE);
|
recyclerView.setVisibility(View.VISIBLE);
|
||||||
@ -334,8 +355,10 @@ public class SearchActivity extends BaseActivity {
|
|||||||
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
mRecentSearchQueryViewModel.getAllRecentSearchQueries().observe(this, recentSearchQueries -> {
|
||||||
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
|
||||||
divider.setVisibility(View.VISIBLE);
|
divider.setVisibility(View.VISIBLE);
|
||||||
|
deleteAllSearchesButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
divider.setVisibility(View.GONE);
|
divider.setVisibility(View.GONE);
|
||||||
|
deleteAllSearchesButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
adapter.setRecentSearchQueries(recentSearchQueries);
|
adapter.setRecentSearchQueries(recentSearchQueries);
|
||||||
});
|
});
|
||||||
@ -401,6 +424,7 @@ public class SearchActivity extends BaseActivity {
|
|||||||
linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
|
linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
int colorAccent = mCustomThemeWrapper.getColorAccent();
|
int colorAccent = mCustomThemeWrapper.getColorAccent();
|
||||||
searchInTextView.setTextColor(colorAccent);
|
searchInTextView.setTextColor(colorAccent);
|
||||||
|
deleteAllSearchesButton.setIconTint(ColorStateList.valueOf(mCustomThemeWrapper.getPrimaryIconColor()));
|
||||||
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||||
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
divider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
||||||
if (typeface != null) {
|
if (typeface != null) {
|
||||||
|
@ -38,6 +38,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.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -130,10 +131,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
@Inject
|
||||||
|
Executor executor;
|
||||||
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 mAccountQualifiedName;
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
private String mSubredditName;
|
private String mSubredditName;
|
||||||
@ -244,7 +246,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
private void bindView(Bundle savedInstanceState) {
|
private void bindView(Bundle savedInstanceState) {
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(3);
|
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
||||||
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
||||||
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
viewPager2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||||
@Override
|
@Override
|
||||||
@ -392,8 +394,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
|
if (mAccountName != null && mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
|
||||||
InsertRecentSearchQuery.insertRecentSearchQueryListener(mRedditDataRoomDatabase, mAccountQualifiedName,
|
InsertRecentSearchQuery.insertRecentSearchQueryListener(executor, new Handler(getMainLooper()),
|
||||||
mQuery, () -> mInsertSearchQuerySuccess = true);
|
mRedditDataRoomDatabase, mAccountQualifiedName, mQuery, () -> mInsertSearchQuerySuccess = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import com.google.android.material.appbar.CollapsingToolbarLayout;
|
|||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
@ -33,6 +32,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.SelectSubredditsOrUsersOpt
|
|||||||
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.subreddit.SubredditWithSelection;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class SelectedSubredditsAndUsersActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
@ -62,7 +62,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private LinearLayoutManagerBugFixed linearLayoutManager;
|
private LinearLayoutManagerBugFixed linearLayoutManager;
|
||||||
private SelectedSubredditsRecyclerViewAdapter adapter;
|
private SelectedSubredditsRecyclerViewAdapter adapter;
|
||||||
private ArrayList<String> subreddits;
|
private ArrayList<SubredditWithSelection> subreddits;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -86,12 +86,11 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
setToolbarGoToTop(toolbar);
|
setToolbarGoToTop(toolbar);
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
subreddits = savedInstanceState.getStringArrayList(SELECTED_SUBREDDITS_STATE);
|
subreddits = savedInstanceState.getParcelableArrayList(SELECTED_SUBREDDITS_STATE);
|
||||||
} else {
|
} else {
|
||||||
subreddits = getIntent().getStringArrayListExtra(EXTRA_SELECTED_SUBREDDITS);
|
subreddits = getIntent().getParcelableArrayListExtra(EXTRA_SELECTED_SUBREDDITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(subreddits);
|
|
||||||
|
|
||||||
adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits);
|
adapter = new SelectedSubredditsRecyclerViewAdapter(this, mCustomThemeWrapper, subreddits);
|
||||||
linearLayoutManager = new LinearLayoutManagerBugFixed(this);
|
linearLayoutManager = new LinearLayoutManagerBugFixed(this);
|
||||||
@ -158,7 +157,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
if (subreddits == null) {
|
if (subreddits == null) {
|
||||||
subreddits = new ArrayList<>();
|
subreddits = new ArrayList<>();
|
||||||
}
|
}
|
||||||
subreddits = data.getStringArrayListExtra(SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
|
subreddits = data.getParcelableArrayListExtra(SubredditMultiselectionActivity.EXTRA_RETURN_SELECTED_SUBREDDITS);
|
||||||
adapter.addSubreddits(subreddits);
|
adapter.addSubreddits(subreddits);
|
||||||
}
|
}
|
||||||
} else if (requestCode == USER_SELECTION_REQUEST_CODE) {
|
} else if (requestCode == USER_SELECTION_REQUEST_CODE) {
|
||||||
@ -176,7 +175,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
|||||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
outState.putStringArrayList(SELECTED_SUBREDDITS_STATE, adapter.getSubreddits());
|
outState.putParcelableArrayList(SELECTED_SUBREDDITS_STATE, adapter.getSubreddits());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +112,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
View divider1;
|
View divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_submit_crosspost_activity)
|
@BindView(R.id.flair_custom_text_view_submit_crosspost_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_submit_crosspost_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity)
|
@BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_submit_crosspost_activity)
|
@BindView(R.id.divider_2_submit_crosspost_activity)
|
||||||
@ -259,11 +257,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
flairTextView.setBorderColor(flairBackgroundColor);
|
||||||
flairTextView.setTextColor(flairTextColor);
|
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);
|
||||||
@ -287,13 +280,14 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
titleEditText.setText(post.getTitle());
|
titleEditText.setText(post.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.getPostType() == Post.TEXT_TYPE) {
|
if (post.getPostType() == Post.TEXT_TYPE || post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||||
contentTextView.setVisibility(View.VISIBLE);
|
contentTextView.setVisibility(View.VISIBLE);
|
||||||
contentTextView.setText(post.getSelfTextPlain());
|
contentTextView.setText(generateCrossPostText(post));
|
||||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
|
||||||
contentTextView.setVisibility(View.VISIBLE);
|
|
||||||
contentTextView.setText(post.getUrl());
|
|
||||||
} else {
|
} else {
|
||||||
|
if (post.getSelfTextPlain() != null && !post.getSelfTextPlain().equals("")) {
|
||||||
|
contentTextView.setVisibility(View.VISIBLE);
|
||||||
|
contentTextView.setText(generateCrossPostText(post));
|
||||||
|
}
|
||||||
Post.Preview preview = getPreview(post);
|
Post.Preview preview = getPreview(post);
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
frameLayout.setVisibility(View.VISIBLE);
|
frameLayout.setVisibility(View.VISIBLE);
|
||||||
@ -368,18 +362,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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) {
|
||||||
@ -461,7 +443,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
flairTextView.setTextColor(primaryTextColor);
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@ -474,7 +455,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
flairTextView.setTypeface(typeface);
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
@ -561,22 +541,19 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
|
|
||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
|
|
||||||
String subredditName;
|
String subredditName = subredditNameTextView.getText().toString();
|
||||||
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, communityData.getId());
|
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()) {
|
|
||||||
intent.putExtra(SubmitPostService.EXTRA_BODY, "t3_" + post.getCrosspostParentId());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, generateCrossPostText(post));
|
||||||
} else {
|
if (post.getUrl() != null && !post.getUrl().equals("")) {
|
||||||
intent.putExtra(SubmitPostService.EXTRA_BODY, post.getFullName());
|
intent.putExtra(SubmitPostService.EXTRA_URL, post.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
@ -699,4 +676,15 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String generateCrossPostText(Post post) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("cross-posted from: ").append(post.getPermalink()).append("\n");
|
||||||
|
String[] lines = post.getSelfTextPlain().split("\n");
|
||||||
|
for (String line : lines) {
|
||||||
|
stringBuilder.append("> ").append(line).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -37,13 +37,14 @@ import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
|||||||
import eu.toldi.infinityforlemmy.Infinity;
|
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.adapters.SubredditMultiselectionRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.SubredditMultiselectionRecyclerViewAdapter;
|
||||||
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.subreddit.SubredditWithSelection;
|
||||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditViewModel;
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditViewModel;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Retrofit;
|
|
||||||
|
|
||||||
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
public class SubredditMultiselectionActivity extends BaseActivity implements ActivityToolbarInterface {
|
||||||
|
|
||||||
@ -70,8 +71,8 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
|||||||
@BindView(R.id.error_text_view_subscribed_subreddits_multiselection_activity)
|
@BindView(R.id.error_text_view_subscribed_subreddits_multiselection_activity)
|
||||||
TextView mErrorTextView;
|
TextView mErrorTextView;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("oauth")
|
@Named("no_oauth")
|
||||||
Retrofit mOauthRetrofit;
|
RetrofitHolder mRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@ -131,7 +132,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
|||||||
|
|
||||||
mSwipeRefreshLayout.setEnabled(false);
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
|
|
||||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, "-");
|
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, "-");
|
||||||
|
|
||||||
bindView();
|
bindView();
|
||||||
}
|
}
|
||||||
@ -177,7 +178,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
|||||||
} else if (itemId == R.id.action_save_subreddit_multiselection_activity) {
|
} else if (itemId == R.id.action_save_subreddit_multiselection_activity) {
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putStringArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS,
|
returnIntent.putExtra(EXTRA_RETURN_SELECTED_SUBREDDITS,
|
||||||
mAdapter.getAllSelectedSubreddits());
|
mAdapter.getAllSelectedSubreddits());
|
||||||
setResult(RESULT_OK, returnIntent);
|
setResult(RESULT_OK, returnIntent);
|
||||||
}
|
}
|
||||||
@ -198,12 +199,12 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null && mAdapter != null) {
|
if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE && resultCode == RESULT_OK && data != null && mAdapter != null) {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
ArrayList<String> selectedSubreddits = mAdapter.getAllSelectedSubreddits();
|
ArrayList<SubredditWithSelection> selectedSubreddits = mAdapter.getAllSelectedSubreddits();
|
||||||
ArrayList<String> searchedSubreddits = data.getStringArrayListExtra(SearchActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES);
|
ArrayList<SubredditWithSelection> searchedSubreddits = data.getParcelableArrayListExtra(SearchActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES);
|
||||||
if (searchedSubreddits != null) {
|
if (searchedSubreddits != null) {
|
||||||
selectedSubreddits.addAll(searchedSubreddits);
|
selectedSubreddits.addAll(searchedSubreddits);
|
||||||
}
|
}
|
||||||
returnIntent.putStringArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS, selectedSubreddits);
|
returnIntent.putParcelableArrayListExtra(EXTRA_RETURN_SELECTED_SUBREDDITS, selectedSubreddits);
|
||||||
setResult(RESULT_OK, returnIntent);
|
setResult(RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,6 @@ import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
|||||||
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.FollowedUsersListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.MultiRedditListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
|
import eu.toldi.infinityforlemmy.fragments.SubscribedSubredditsListingFragment;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
|
||||||
import eu.toldi.infinityforlemmy.multireddit.FetchMyMultiReddits;
|
import eu.toldi.infinityforlemmy.multireddit.FetchMyMultiReddits;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||||
@ -112,6 +111,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
@Named("current_account")
|
@Named("current_account")
|
||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
SharedPreferences mCurrentAccountSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("internal")
|
||||||
|
SharedPreferences mInternalSharedPreferences;
|
||||||
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
@Inject
|
@Inject
|
||||||
Executor mExecutor;
|
Executor mExecutor;
|
||||||
@ -233,7 +235,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(sectionsPagerAdapter);
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(1);
|
viewPager.setOffscreenPageLimit(1);
|
||||||
if (viewPager.getCurrentItem() != 2) {
|
if (viewPager.getCurrentItem() != 1) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
}
|
}
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||||
@ -244,7 +246,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
fab.hide();
|
fab.hide();
|
||||||
} else {
|
} else {
|
||||||
lockSwipeRightToGoBack();
|
lockSwipeRightToGoBack();
|
||||||
if (position != 2) {
|
if (position != 1) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
} else {
|
} else {
|
||||||
fab.show();
|
fab.show();
|
||||||
@ -323,6 +325,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadSubscriptions(boolean forceLoad) {
|
public void loadSubscriptions(boolean forceLoad) {
|
||||||
|
if (!forceLoad && System.currentTimeMillis() - mInternalSharedPreferences.getLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, 0L) < 24 * 60 * 60 * 1000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
if (mAccessToken != null && !(!forceLoad && mInsertSuccess)) {
|
||||||
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, null,
|
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, null,
|
||||||
new ArrayList<>(), new ArrayList<>(),
|
new ArrayList<>(), new ArrayList<>(),
|
||||||
@ -332,6 +338,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
public void onFetchSubscribedThingSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData,
|
public void onFetchSubscribedThingSuccess(ArrayList<SubscribedSubredditData> subscribedSubredditData,
|
||||||
ArrayList<SubscribedUserData> subscribedUserData,
|
ArrayList<SubscribedUserData> subscribedUserData,
|
||||||
ArrayList<SubredditData> subredditData) {
|
ArrayList<SubredditData> subredditData) {
|
||||||
|
mInternalSharedPreferences.edit().putLong(SharedPreferencesUtils.SUBSCRIBED_THINGS_SYNC_TIME, System.currentTimeMillis()).apply();
|
||||||
InsertSubscribedThings.insertSubscribedThings(
|
InsertSubscribedThings.insertSubscribedThings(
|
||||||
mExecutor,
|
mExecutor,
|
||||||
new Handler(),
|
new Handler(),
|
||||||
@ -378,7 +385,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(ArrayList<MultiReddit> multiReddits) {
|
public void success(ArrayList<MultiReddit> multiReddits) {
|
||||||
InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountName, () -> {
|
InsertMultireddit.insertMultireddits(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddits, mAccountQualifiedName, () -> {
|
||||||
mInsertMultiredditSuccess = true;
|
mInsertMultiredditSuccess = true;
|
||||||
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
sectionsPagerAdapter.stopMultiRedditRefreshProgressbar();
|
||||||
});
|
});
|
||||||
@ -400,27 +407,11 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
.setMessage(R.string.delete_multi_reddit_dialog_message)
|
||||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||||
-> {
|
-> {
|
||||||
if (mAccessToken == null) {
|
|
||||||
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountName, multiReddit.getPath(),
|
|
||||||
() -> Toast.makeText(SubscribedThingListingActivity.this,
|
|
||||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
|
|
||||||
} else {
|
|
||||||
DeleteMultiReddit.deleteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, mAccountName, multiReddit.getPath(), new DeleteMultiReddit.DeleteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
Toast.makeText(SubscribedThingListingActivity.this,
|
|
||||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
|
||||||
//loadMultiReddits();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
DeleteMultiredditInDatabase.deleteMultiredditInDatabase(mExecutor, new Handler(), mRedditDataRoomDatabase, mAccountQualifiedName, multiReddit.getPath(),
|
||||||
public void failed() {
|
() -> Toast.makeText(SubscribedThingListingActivity.this,
|
||||||
Toast.makeText(SubscribedThingListingActivity.this,
|
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show());
|
||||||
R.string.delete_multi_reddit_failed, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
@ -476,7 +467,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,12 +478,20 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
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 ? "-" : mAccountQualifiedName);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return 1;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -501,8 +500,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
case 0:
|
case 0:
|
||||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.communities));
|
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.communities));
|
||||||
case 1:
|
case 1:
|
||||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.users));
|
|
||||||
case 2:
|
|
||||||
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
|
return Utils.getTabTextWithCustomFont(typeface, getString(R.string.multi_reddits));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,8 +512,6 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
Fragment fragment = (Fragment) super.instantiateItem(container, position);
|
Fragment fragment = (Fragment) super.instantiateItem(container, position);
|
||||||
if (position == 0) {
|
if (position == 0) {
|
||||||
subscribedSubredditsListingFragment = (SubscribedSubredditsListingFragment) fragment;
|
subscribedSubredditsListingFragment = (SubscribedSubredditsListingFragment) fragment;
|
||||||
} else if (position == 1) {
|
|
||||||
followedUsersListingFragment = (FollowedUsersListingFragment) fragment;
|
|
||||||
} else {
|
} else {
|
||||||
multiRedditListingFragment = (MultiRedditListingFragment) fragment;
|
multiRedditListingFragment = (MultiRedditListingFragment) fragment;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.SaveComment;
|
|||||||
import eu.toldi.infinityforlemmy.SaveThing;
|
import eu.toldi.infinityforlemmy.SaveThing;
|
||||||
import eu.toldi.infinityforlemmy.SortType;
|
import eu.toldi.infinityforlemmy.SortType;
|
||||||
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
|
||||||
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
||||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
@ -81,6 +82,7 @@ import eu.toldi.infinityforlemmy.post.HistoryPostPagingSource;
|
|||||||
import eu.toldi.infinityforlemmy.post.ParsePost;
|
import eu.toldi.infinityforlemmy.post.ParsePost;
|
||||||
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.post.enrich.PostEnricher;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||||
import eu.toldi.infinityforlemmy.readpost.ReadPost;
|
import eu.toldi.infinityforlemmy.readpost.ReadPost;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
@ -151,6 +153,8 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
@Inject
|
@Inject
|
||||||
@Named("glide")
|
@Named("glide")
|
||||||
OkHttpClient okHttpClient;
|
OkHttpClient okHttpClient;
|
||||||
|
@Inject
|
||||||
|
PostEnricher postEnricher;
|
||||||
@State
|
@State
|
||||||
ArrayList<Post> posts;
|
ArrayList<Post> posts;
|
||||||
@State
|
@State
|
||||||
@ -530,69 +534,38 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
Handler handler = new Handler(Looper.getMainLooper());
|
Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {
|
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {
|
||||||
|
int nextPage = posts.size() / 25 + 1;
|
||||||
|
|
||||||
mExecutor.execute(() -> {
|
mExecutor.execute(() -> {
|
||||||
RedditAPI api = (mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit).create(RedditAPI.class);
|
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
|
||||||
Call<String> call;
|
Call<String> call;
|
||||||
String afterKey = posts.isEmpty() ? null : posts.get(posts.size() - 1).getFullName();
|
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
case PostPagingSource.TYPE_SUBREDDIT:
|
case PostPagingSource.TYPE_SUBREDDIT:
|
||||||
if (mAccessToken == null) {
|
call = api.getPosts(null, sortType.value, nextPage, 25, null, post.getSubredditNamePrefixed(), false, mAccessToken);
|
||||||
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
|
|
||||||
} else {
|
|
||||||
call = api.getSubredditBestPostsOauth(subredditName, sortType,
|
|
||||||
sortTime, afterKey, APIUtils.getOAuthHeader(mAccessToken));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_USER:
|
case PostPagingSource.TYPE_USER:
|
||||||
if (mAccessToken == null) {
|
call = api.getUserPosts(username, sortType.value, nextPage, 25, false, mAccessToken);
|
||||||
call = api.getUserPosts(username, afterKey, sortType, sortTime);
|
|
||||||
} else {
|
|
||||||
call = api.getUserPostsOauth(username, userWhere, afterKey, sortType,
|
|
||||||
sortTime, APIUtils.getOAuthHeader(mAccessToken));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_SEARCH:
|
case PostPagingSource.TYPE_SEARCH:
|
||||||
if (subredditName == null) {
|
call = api.search(query, null, subredditName, null, "Post", sortType.value, "All", nextPage, 25, mAccessToken);
|
||||||
if (mAccessToken == null) {
|
|
||||||
call = api.searchPosts(query, afterKey, sortType, sortTime,
|
|
||||||
trendingSource);
|
|
||||||
} else {
|
|
||||||
call = api.searchPostsOauth(query, afterKey, sortType,
|
|
||||||
sortTime, trendingSource, APIUtils.getOAuthHeader(mAccessToken));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mAccessToken == null) {
|
|
||||||
call = api.searchPostsInSpecificSubreddit(subredditName, query,
|
|
||||||
sortType, sortTime, afterKey);
|
|
||||||
} else {
|
|
||||||
call = api.searchPostsInSpecificSubredditOauth(subredditName, query,
|
|
||||||
sortType, sortTime, afterKey,
|
|
||||||
APIUtils.getOAuthHeader(mAccessToken));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||||
if (mAccessToken == null) {
|
// TODO: Implement multi community
|
||||||
call = api.getMultiRedditPosts(multiPath, afterKey, sortTime);
|
|
||||||
} else {
|
|
||||||
call = api.getMultiRedditPostsOauth(multiPath, afterKey,
|
|
||||||
sortTime, APIUtils.getOAuthHeader(mAccessToken));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
|
||||||
//case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT
|
// TODO: Implement anonymous front page
|
||||||
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
call = api.getBestPosts(sortType, sortTime, afterKey,
|
String type = (subredditName == null) ? "Subscribed" : (subredditName.equals("all")) ? "All" : "Local";
|
||||||
APIUtils.getOAuthHeader(mAccessToken));
|
call = api.getPosts(type, sortType.value, nextPage, 25, null, null, false, mAccessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Response<String> response = call.execute();
|
Response<String> response = call.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
String responseString = response.body();
|
String responseString = response.body();
|
||||||
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList);
|
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, readPostList, postEnricher);
|
||||||
if (newPosts == null) {
|
if (newPosts == null) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
|
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
|
||||||
@ -674,7 +647,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
Response<String> response = historyPosts.execute();
|
Response<String> response = historyPosts.execute();
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
String responseString = response.body();
|
String responseString = response.body();
|
||||||
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null);
|
LinkedHashSet<Post> newPosts = ParsePost.parsePostsSync(responseString, -1, postFilter, null, postEnricher);
|
||||||
if (newPosts == null || newPosts.isEmpty()) {
|
if (newPosts == null || newPosts.isEmpty()) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
|
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package eu.toldi.infinityforlemmy.activities;
|
package eu.toldi.infinityforlemmy.activities;
|
||||||
|
|
||||||
|
import static android.graphics.BitmapFactory.decodeResource;
|
||||||
|
|
||||||
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.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -40,6 +44,8 @@ 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.bumptech.glide.request.target.CustomTarget;
|
||||||
|
import com.bumptech.glide.request.transition.Transition;
|
||||||
import com.evernote.android.state.State;
|
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;
|
||||||
@ -104,6 +110,7 @@ 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.shortcut.ShortcutManager;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.CommunitySubscription;
|
import eu.toldi.infinityforlemmy.subreddit.CommunitySubscription;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.ParseSubredditData;
|
||||||
@ -260,10 +267,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
private int subscribedColor;
|
private int subscribedColor;
|
||||||
private int fabOption;
|
private int fabOption;
|
||||||
private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||||
|
private Bitmap subredditIconBitmap;
|
||||||
|
|
||||||
private boolean showStatistics;
|
private boolean showStatistics;
|
||||||
|
|
||||||
|
private boolean disableImagePreview;
|
||||||
|
|
||||||
private boolean hideSubredditDescription;
|
private boolean hideSubredditDescription;
|
||||||
|
private boolean isKbinMagazine = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -277,6 +288,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
|
|
||||||
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
||||||
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
|
showStatistics = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_STATISTICS, true);
|
||||||
|
disableImagePreview = mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, 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),
|
||||||
findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar),
|
findViewById(R.id.option_1_bottom_app_bar), findViewById(R.id.option_2_bottom_app_bar),
|
||||||
@ -538,7 +550,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
|
|
||||||
descriptionTextView.setOnLongClickListener(view -> {
|
descriptionTextView.setOnLongClickListener(view -> {
|
||||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||||
@ -546,10 +558,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
String actorID = (!isKbinMagazine) ? LemmyUtils.qualifiedCommunityName2ActorId(qualifiedName) : LemmyUtils.qualifiedMagazineName2ActorId(qualifiedName);
|
||||||
mSubredditViewModel = new ViewModelProvider(this,
|
mSubredditViewModel = new ViewModelProvider(this,
|
||||||
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, LemmyUtils.qualifiedCommunityName2ActorId(qualifiedName)))
|
new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, actorID))
|
||||||
.get(SubredditViewModel.class);
|
.get(SubredditViewModel.class);
|
||||||
|
addObserverToLiveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addObserverToLiveData() {
|
||||||
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
|
mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> {
|
||||||
if (subredditData != null) {
|
if (subredditData != null) {
|
||||||
isNsfwSubreddit = subredditData.isNSFW();
|
isNsfwSubreddit = subredditData.isNSFW();
|
||||||
@ -575,11 +591,23 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
.into(iconGifImageView);
|
.into(iconGifImageView);
|
||||||
iconGifImageView.setOnClickListener(null);
|
iconGifImageView.setOnClickListener(null);
|
||||||
} else {
|
} else {
|
||||||
glide.load(subredditData.getIconUrl())
|
glide.asBitmap()
|
||||||
|
.load(subredditData.getIconUrl())
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0)))
|
||||||
.error(glide.load(R.drawable.subreddit_default_icon)
|
.error(glide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(216, 0))))
|
||||||
.into(iconGifImageView);
|
.into(new CustomTarget<Bitmap>() {
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
|
subredditIconBitmap = resource;
|
||||||
|
iconGifImageView.setImageBitmap(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||||
|
subredditIconBitmap = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
iconGifImageView.setOnClickListener(view -> {
|
iconGifImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class);
|
Intent intent = new Intent(ViewSubredditDetailActivity.this, ViewImageOrGifActivity.class);
|
||||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, subredditData.getIconUrl());
|
intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, subredditData.getIconUrl());
|
||||||
@ -745,6 +773,14 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
communityName = communityData.getTitle();
|
communityName = communityData.getTitle();
|
||||||
}
|
}
|
||||||
mCommunityStats = communityData.getCommunityStats();
|
mCommunityStats = communityData.getCommunityStats();
|
||||||
|
if (communityData.getActorId().contains("/m/")) {
|
||||||
|
isKbinMagazine = true;
|
||||||
|
if (mSubredditViewModel != null) {
|
||||||
|
// Remove current observer
|
||||||
|
mSubredditViewModel.getSubredditLiveData().removeObservers(ViewSubredditDetailActivity.this);
|
||||||
|
addObserverToLiveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
setupVisibleElements();
|
setupVisibleElements();
|
||||||
communityId = communityData.getId();
|
communityId = communityData.getId();
|
||||||
ViewSubredditDetailActivity.this.communityData = communityData;
|
ViewSubredditDetailActivity.this.communityData = communityData;
|
||||||
@ -1148,7 +1184,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(2);
|
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
||||||
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
@ -1274,6 +1310,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
} else if (itemId == R.id.action_add_to_home_screen_view_subreddit_detail_activity) {
|
||||||
|
Bitmap icon = subredditIconBitmap == null ? decodeResource(getResources(), R.drawable.subreddit_default_icon) : subredditIconBitmap;
|
||||||
|
return ShortcutManager.requestPinShortcut(this, qualifiedName, icon);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1557,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1576,7 +1619,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -1597,7 +1644,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
String qualifiedName = thingEditText.getText().toString();
|
||||||
|
if (qualifiedName.startsWith("@")) {
|
||||||
|
qualifiedName = qualifiedName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1610,7 +1661,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
String qualifiedName = thingEditText.getText().toString();
|
||||||
|
if (qualifiedName.startsWith("@")) {
|
||||||
|
qualifiedName = qualifiedName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, qualifiedName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -1692,6 +1747,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
|||||||
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, communityName);
|
bundle.putString(SidebarFragment.EXTRA_SUBREDDIT_NAME, communityName);
|
||||||
bundle.putString(SidebarFragment.EXTRA_COMMUNITY_QUALIFIED_NAME, qualifiedName);
|
bundle.putString(SidebarFragment.EXTRA_COMMUNITY_QUALIFIED_NAME, qualifiedName);
|
||||||
bundle.putBoolean(SidebarFragment.EXTRA_SHOW_STATISTICS, !showStatistics);
|
bundle.putBoolean(SidebarFragment.EXTRA_SHOW_STATISTICS, !showStatistics);
|
||||||
|
bundle.putBoolean(SidebarFragment.EXTRA_DISABLE_IMAGE_PREVIEW, disableImagePreview);
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null);
|
urlMenuBottomSheetFragment.show(getSupportFragmentManager(), null);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener);
|
Markwon markwon = MarkdownUtils.createDescriptionMarkwon(this, miscPlugin, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
|
|
||||||
descriptionTextView.setOnLongClickListener(view -> {
|
descriptionTextView.setOnLongClickListener(view -> {
|
||||||
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
if (description != null && !description.equals("") && descriptionTextView.getSelectionStart() == -1 && descriptionTextView.getSelectionEnd() == -1) {
|
||||||
@ -761,7 +761,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
private void initializeViewPager() {
|
private void initializeViewPager() {
|
||||||
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
sectionsPagerAdapter = new SectionsPagerAdapter(this);
|
||||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager2.setOffscreenPageLimit(2);
|
viewPager2.setOffscreenPageLimit(ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT);
|
||||||
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
viewPager2.setUserInputEnabled(!mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_SWIPING_BETWEEN_TABS, false));
|
||||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||||
switch (position) {
|
switch (position) {
|
||||||
@ -1514,7 +1514,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1572,7 +1576,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||||
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString());
|
String communityName = thingEditText.getText().toString();
|
||||||
|
if (communityName.startsWith("!")) {
|
||||||
|
communityName = communityName.substring(1);
|
||||||
|
}
|
||||||
|
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, communityName);
|
||||||
startActivity(subredditIntent);
|
startActivity(subredditIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
@ -1593,7 +1601,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
String userName = thingEditText.getText().toString();
|
||||||
|
if (userName.startsWith("@")) {
|
||||||
|
userName = userName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, userName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1606,7 +1618,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
-> {
|
-> {
|
||||||
Utils.hideKeyboard(this);
|
Utils.hideKeyboard(this);
|
||||||
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString());
|
String userName = thingEditText.getText().toString();
|
||||||
|
if (userName.startsWith("@")) {
|
||||||
|
userName = userName.substring(1);
|
||||||
|
}
|
||||||
|
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userName);
|
||||||
startActivity(userIntent);
|
startActivity(userIntent);
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
|
||||||
|
@ -23,14 +23,11 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.Html;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.OrientationEventListener;
|
import android.view.OrientationEventListener;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -70,6 +67,7 @@ import com.google.android.exoplayer2.upstream.cache.SimpleCache;
|
|||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import com.google.android.material.bottomappbar.BottomAppBar;
|
import com.google.android.material.bottomappbar.BottomAppBar;
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.otaliastudios.zoom.ZoomEngine;
|
import com.otaliastudios.zoom.ZoomEngine;
|
||||||
@ -108,6 +106,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontFamily;
|
|||||||
import eu.toldi.infinityforlemmy.font.TitleFontStyle;
|
import eu.toldi.infinityforlemmy.font.TitleFontStyle;
|
||||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
|
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
|
||||||
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
|
||||||
import eu.toldi.infinityforlemmy.services.DownloadRedditVideoService;
|
import eu.toldi.infinityforlemmy.services.DownloadRedditVideoService;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
@ -131,7 +130,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
public static final String EXTRA_VIDEO_DOWNLOAD_URL = "EVDU";
|
public static final String EXTRA_VIDEO_DOWNLOAD_URL = "EVDU";
|
||||||
public static final String EXTRA_SUBREDDIT = "ES";
|
public static final String EXTRA_SUBREDDIT = "ES";
|
||||||
public static final String EXTRA_ID = "EI";
|
public static final String EXTRA_ID = "EI";
|
||||||
public static final String EXTRA_POST_TITLE = "EPT";
|
public static final String EXTRA_POST = "EP";
|
||||||
public static final String EXTRA_PROGRESS_SECONDS = "EPS";
|
public static final String EXTRA_PROGRESS_SECONDS = "EPS";
|
||||||
public static final String EXTRA_VIDEO_TYPE = "EVT";
|
public static final String EXTRA_VIDEO_TYPE = "EVT";
|
||||||
public static final String EXTRA_GFYCAT_ID = "EGI";
|
public static final String EXTRA_GFYCAT_ID = "EGI";
|
||||||
@ -162,17 +161,19 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
@BindView(R.id.progress_bar_view_video_activity)
|
@BindView(R.id.progress_bar_view_video_activity)
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
@BindView(R.id.mute_exo_playback_control_view)
|
@BindView(R.id.mute_exo_playback_control_view)
|
||||||
ImageButton muteButton;
|
MaterialButton muteButton;
|
||||||
@BindView(R.id.hd_exo_playback_control_view)
|
@BindView(R.id.hd_exo_playback_control_view)
|
||||||
ImageButton hdButton;
|
MaterialButton hdButton;
|
||||||
@BindView(R.id.bottom_navigation_exo_playback_control_view)
|
@BindView(R.id.bottom_navigation_exo_playback_control_view)
|
||||||
BottomAppBar bottomAppBar;
|
BottomAppBar bottomAppBar;
|
||||||
@BindView(R.id.title_text_view_exo_playback_control_view)
|
@BindView(R.id.title_text_view_exo_playback_control_view)
|
||||||
TextView titleTextView;
|
TextView titleTextView;
|
||||||
|
@BindView(R.id.back_button_exo_playback_control_view)
|
||||||
|
MaterialButton backButton;
|
||||||
@BindView(R.id.download_image_view_exo_playback_control_view)
|
@BindView(R.id.download_image_view_exo_playback_control_view)
|
||||||
ImageView downloadImageView;
|
MaterialButton downloadButton;
|
||||||
@BindView(R.id.playback_speed_image_view_exo_playback_control_view)
|
@BindView(R.id.playback_speed_image_view_exo_playback_control_view)
|
||||||
ImageView playbackSpeedImageView;
|
MaterialButton playbackSpeedButton;
|
||||||
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
|
@BindView(R.id.lockable_nested_scroll_view_view_video_activity)
|
||||||
LockableNestedScrollView nestedScrollView;
|
LockableNestedScrollView nestedScrollView;
|
||||||
|
|
||||||
@ -222,10 +223,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
@Named("default")
|
@Named("default")
|
||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Named("current_account")
|
|
||||||
SharedPreferences mCurrentAccountSharedPreferences;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
@ -235,6 +232,9 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
@Inject
|
@Inject
|
||||||
SimpleCache mSimpleCache;
|
SimpleCache mSimpleCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
PostEnricher postEnricher;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -301,6 +301,12 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
|
setTitle(" ");
|
||||||
|
|
||||||
|
if (typeface != null) {
|
||||||
|
titleTextView.setTypeface(typeface);
|
||||||
|
}
|
||||||
|
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
|
|
||||||
getWindow().getDecorView().setSystemUiVisibility(
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
@ -312,7 +318,11 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
if (useBottomAppBar) {
|
if (useBottomAppBar) {
|
||||||
getSupportActionBar().hide();
|
getSupportActionBar().hide();
|
||||||
bottomAppBar.setVisibility(View.VISIBLE);
|
bottomAppBar.setVisibility(View.VISIBLE);
|
||||||
downloadImageView.setOnClickListener(view -> {
|
backButton.setOnClickListener(view -> {
|
||||||
|
finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
downloadButton.setOnClickListener(view -> {
|
||||||
if (isDownloading) {
|
if (isDownloading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -326,12 +336,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
requestPermissionAndDownload();
|
requestPermissionAndDownload();
|
||||||
});
|
});
|
||||||
|
|
||||||
playbackSpeedImageView.setOnClickListener(view -> {
|
playbackSpeedButton.setOnClickListener(view -> {
|
||||||
PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment();
|
changePlaybackSpeed();
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed);
|
|
||||||
playbackSpeedBottomSheetFragment.setArguments(bundle);
|
|
||||||
playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag());
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
@ -402,12 +408,15 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
};
|
};
|
||||||
orientationEventListener.enable();
|
orientationEventListener.enable();
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
|
Post post = intent.getParcelableExtra(EXTRA_POST);
|
||||||
setSmallTitle(postTitle);
|
if (post != null) {
|
||||||
|
titleTextView.setText(post.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
trackSelector = new DefaultTrackSelector(this);
|
trackSelector = new DefaultTrackSelector(this);
|
||||||
if (videoType == VIDEO_TYPE_NORMAL && isDataSavingMode && dataSavingModeDefaultResolution > 0) {
|
if (videoType == VIDEO_TYPE_NORMAL && isDataSavingMode && dataSavingModeDefaultResolution > 0) {
|
||||||
@ -598,20 +607,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSmallTitle(String title) {
|
|
||||||
if (title != null) {
|
|
||||||
if (useBottomAppBar) {
|
|
||||||
titleTextView.setText(Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title)));
|
|
||||||
} else {
|
|
||||||
setTitle(Utils.getTabTextWithCustomFont(typeface, Html.fromHtml(String.format("<font color=\"#FFFFFF\"><small>%s</small></font>", title))));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!useBottomAppBar) {
|
|
||||||
setTitle("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void preparePlayer(Bundle savedInstanceState) {
|
private void preparePlayer(Bundle savedInstanceState) {
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
|
||||||
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||||
@ -631,17 +626,17 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
isMute = savedInstanceState.getBoolean(IS_MUTE_STATE);
|
isMute = savedInstanceState.getBoolean(IS_MUTE_STATE);
|
||||||
if (isMute) {
|
if (isMute) {
|
||||||
player.setVolume(0f);
|
player.setVolume(0f);
|
||||||
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
muteButton.setIconResource(R.drawable.ic_mute_24dp);
|
||||||
} else {
|
} else {
|
||||||
player.setVolume(1f);
|
player.setVolume(1f);
|
||||||
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
muteButton.setIconResource(R.drawable.ic_unmute_24dp);
|
||||||
}
|
}
|
||||||
} else if (muteVideo) {
|
} else if (muteVideo) {
|
||||||
isMute = true;
|
isMute = true;
|
||||||
player.setVolume(0f);
|
player.setVolume(0f);
|
||||||
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
muteButton.setIconResource(R.drawable.ic_mute_24dp);
|
||||||
} else {
|
} else {
|
||||||
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
muteButton.setIconResource(R.drawable.ic_unmute_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.addListener(new Player.Listener() {
|
player.addListener(new Player.Listener() {
|
||||||
@ -685,11 +680,11 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
if (isMute) {
|
if (isMute) {
|
||||||
isMute = false;
|
isMute = false;
|
||||||
player.setVolume(1f);
|
player.setVolume(1f);
|
||||||
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
muteButton.setIconResource(R.drawable.ic_unmute_24dp);
|
||||||
} else {
|
} else {
|
||||||
isMute = true;
|
isMute = true;
|
||||||
player.setVolume(0f);
|
player.setVolume(0f);
|
||||||
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
muteButton.setIconResource(R.drawable.ic_mute_24dp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -702,6 +697,14 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void changePlaybackSpeed() {
|
||||||
|
PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed);
|
||||||
|
playbackSpeedBottomSheetFragment.setArguments(bundle);
|
||||||
|
playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag());
|
||||||
|
}
|
||||||
|
|
||||||
private int inferPrimaryTrackType(Format format) {
|
private int inferPrimaryTrackType(Format format) {
|
||||||
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
|
int trackType = MimeTypes.getTrackType(format.sampleMimeType);
|
||||||
if (trackType != C.TRACK_TYPE_UNKNOWN) {
|
if (trackType != C.TRACK_TYPE_UNKNOWN) {
|
||||||
@ -756,8 +759,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(this, mExecutor, new Handler(), redgifsRetrofit,
|
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit,
|
||||||
mCurrentAccountSharedPreferences, gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success(String webm, String mp4) {
|
public void success(String webm, String mp4) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
@ -791,7 +794,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
int commentsIndex = segments.lastIndexOf("comments");
|
int commentsIndex = segments.lastIndexOf("comments");
|
||||||
String postId = segments.get(commentsIndex + 1);
|
String postId = segments.get(commentsIndex + 1);
|
||||||
FetchPost.fetchPost(mExecutor, new Handler(), retrofit.getRetrofit(), postId, null,
|
FetchPost.fetchPost(mExecutor, new Handler(), retrofit.getRetrofit(), postId, null,
|
||||||
new FetchPost.FetchPostListener() {
|
postEnricher, new FetchPost.FetchPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchPostSuccess(Post post) {
|
public void fetchPostSuccess(Post post) {
|
||||||
if (post.isGfycat()) {
|
if (post.isGfycat()) {
|
||||||
@ -884,7 +887,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
Toast.makeText(ViewVideoActivity.this, R.string.fetch_streamable_video_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(ViewVideoActivity.this, R.string.fetch_streamable_video_failed, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setSmallTitle(streamableVideo.title);
|
titleTextView.setText(streamableVideo.title);
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
videoDownloadUrl = streamableVideo.mp4 == null ? streamableVideo.mp4Mobile.url : streamableVideo.mp4.url;
|
||||||
mVideoUri = Uri.parse(videoDownloadUrl);
|
mVideoUri = Uri.parse(videoDownloadUrl);
|
||||||
@ -939,11 +942,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
|
|||||||
requestPermissionAndDownload();
|
requestPermissionAndDownload();
|
||||||
return true;
|
return true;
|
||||||
} else if (itemId == R.id.action_playback_speed_view_video_activity) {
|
} else if (itemId == R.id.action_playback_speed_view_video_activity) {
|
||||||
PlaybackSpeedBottomSheetFragment playbackSpeedBottomSheetFragment = new PlaybackSpeedBottomSheetFragment();
|
changePlaybackSpeed();
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(PlaybackSpeedBottomSheetFragment.EXTRA_PLAYBACK_SPEED, playbackSpeed);
|
|
||||||
playbackSpeedBottomSheetFragment.setArguments(bundle);
|
|
||||||
playbackSpeedBottomSheetFragment.show(getSupportFragmentManager(), playbackSpeedBottomSheetFragment.getTag());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class WikiActivity extends BaseActivity {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
markwon = MarkdownUtils.createFullRedditMarkwon(this,
|
||||||
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener);
|
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener, mSharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
|
|
||||||
markwonAdapter = MarkdownUtils.createTablesAdapter();
|
markwonAdapter = MarkdownUtils.createTablesAdapter();
|
||||||
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemCommentFilterUsageEmbeddedBinding;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterUsageEmbeddedRecyclerViewAdapter extends RecyclerView.Adapter<CommentFilterUsageEmbeddedRecyclerViewAdapter.EntryViewHolder> {
|
||||||
|
private BaseActivity baseActivity;
|
||||||
|
private List<CommentFilterUsage> commentFilterUsageList;
|
||||||
|
|
||||||
|
public CommentFilterUsageEmbeddedRecyclerViewAdapter(BaseActivity baseActivity) {
|
||||||
|
this.baseActivity = baseActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public EntryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new EntryViewHolder(ItemCommentFilterUsageEmbeddedBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull EntryViewHolder holder, int position) {
|
||||||
|
if (commentFilterUsageList == null || commentFilterUsageList.isEmpty()) {
|
||||||
|
holder.textView.setText(R.string.comment_filter_applied_to_all_subreddits);
|
||||||
|
} else if (holder.getBindingAdapterPosition() > 4) {
|
||||||
|
holder.textView.setText(baseActivity.getString(R.string.comment_filter_usage_embedded_more_count, commentFilterUsageList.size() - 5));
|
||||||
|
} else {
|
||||||
|
CommentFilterUsage commentFilterUsage = commentFilterUsageList.get(holder.getBindingAdapterPosition());
|
||||||
|
switch (commentFilterUsage.usage) {
|
||||||
|
case CommentFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
holder.textView.setText("r/" + commentFilterUsage.nameOfUsage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return commentFilterUsageList == null || commentFilterUsageList.isEmpty() ? 1 : (commentFilterUsageList.size() > 5 ? 6 : commentFilterUsageList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentFilterUsageList(List<CommentFilterUsage> commentFilterUsageList) {
|
||||||
|
this.commentFilterUsageList = commentFilterUsageList;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
class EntryViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView textView;
|
||||||
|
|
||||||
|
public EntryViewHolder(@NonNull ItemCommentFilterUsageEmbeddedBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
textView = binding.getRoot();
|
||||||
|
textView.setTextColor(baseActivity.customThemeWrapper.getSecondaryTextColor());
|
||||||
|
|
||||||
|
if (baseActivity.typeface != null) {
|
||||||
|
textView.setTypeface(baseActivity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setOnClickListener(view -> {
|
||||||
|
Toast.makeText(baseActivity, textView.getText(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
private List<CommentFilterUsage> commentFilterUsages;
|
||||||
|
private BaseActivity activity;
|
||||||
|
private CustomThemeWrapper customThemeWrapper;
|
||||||
|
private CommentFilterUsageRecyclerViewAdapter.OnItemClickListener onItemClickListener;
|
||||||
|
|
||||||
|
public interface OnItemClickListener {
|
||||||
|
void onClick(CommentFilterUsage commentFilterUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommentFilterUsageRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
|
||||||
|
CommentFilterUsageRecyclerViewAdapter.OnItemClickListener onItemClickListener) {
|
||||||
|
this.activity = activity;
|
||||||
|
this.customThemeWrapper = customThemeWrapper;
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_filter_usage, parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
CommentFilterUsage commentFilterUsage = commentFilterUsages.get(position);
|
||||||
|
switch (commentFilterUsage.usage) {
|
||||||
|
case CommentFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
((CommentFilterUsageRecyclerViewAdapter.CommentFilterUsageViewHolder) holder).usageTextView.setText(activity.getString(R.string.post_filter_usage_community, commentFilterUsage.nameOfUsage));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return commentFilterUsages == null ? 0 : commentFilterUsages.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentFilterUsages(List<CommentFilterUsage> commentFilterUsages) {
|
||||||
|
this.commentFilterUsages = commentFilterUsages;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CommentFilterUsageViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView usageTextView;
|
||||||
|
|
||||||
|
public CommentFilterUsageViewHolder(@NonNull View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
usageTextView = (TextView) itemView;
|
||||||
|
|
||||||
|
usageTextView.setTextColor(customThemeWrapper.getPrimaryTextColor());
|
||||||
|
|
||||||
|
if (activity.typeface != null) {
|
||||||
|
usageTextView.setTypeface(activity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
usageTextView.setOnClickListener(view -> {
|
||||||
|
onItemClickListener.onClick(commentFilterUsages.get(getBindingAdapterPosition()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterWithUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemCommentFilterWithUsageBinding;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterWithUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
private BaseActivity activity;
|
||||||
|
private final OnItemClickListener onItemClickListener;
|
||||||
|
private List<CommentFilterWithUsage> commentFilterWithUsageList;
|
||||||
|
private RecyclerView.RecycledViewPool recycledViewPool;
|
||||||
|
|
||||||
|
public interface OnItemClickListener {
|
||||||
|
void onItemClick(CommentFilter commentFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommentFilterWithUsageRecyclerViewAdapter(BaseActivity activity, OnItemClickListener onItemClickListener) {
|
||||||
|
this.activity = activity;
|
||||||
|
this.recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new CommentFilterViewHolder(ItemCommentFilterWithUsageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
|
if (holder instanceof CommentFilterViewHolder) {
|
||||||
|
((CommentFilterViewHolder) holder).binding.commentFilterNameTextViewItemCommentFilter.setText(commentFilterWithUsageList.get(position).commentFilter.name);
|
||||||
|
((CommentFilterViewHolder) holder).adapter.setCommentFilterUsageList(commentFilterWithUsageList.get(position).commentFilterUsageList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return commentFilterWithUsageList == null ? 0 : commentFilterWithUsageList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentFilterWithUsageList(List<CommentFilterWithUsage> commentFilterWithUsageList) {
|
||||||
|
this.commentFilterWithUsageList = commentFilterWithUsageList;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CommentFilterViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
ItemCommentFilterWithUsageBinding binding;
|
||||||
|
CommentFilterUsageEmbeddedRecyclerViewAdapter adapter;
|
||||||
|
|
||||||
|
public CommentFilterViewHolder(@NonNull ItemCommentFilterWithUsageBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
binding.commentFilterNameTextViewItemCommentFilter.setTextColor(activity.customThemeWrapper.getPrimaryTextColor());
|
||||||
|
|
||||||
|
if (activity.typeface != null) {
|
||||||
|
binding.commentFilterNameTextViewItemCommentFilter.setTypeface(activity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.getRoot().setOnClickListener(view -> {
|
||||||
|
onItemClickListener.onItemClick(commentFilterWithUsageList.get(getBindingAdapterPosition()).commentFilter);
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.commentFilterUsageRecyclerViewItemCommentFilter.setRecycledViewPool(recycledViewPool);
|
||||||
|
binding.commentFilterUsageRecyclerViewItemCommentFilter.setLayoutManager(new LinearLayoutManagerBugFixed(activity));
|
||||||
|
adapter = new CommentFilterUsageEmbeddedRecyclerViewAdapter(activity);
|
||||||
|
binding.commentFilterUsageRecyclerViewItemCommentFilter.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ 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.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
@ -12,7 +11,6 @@ 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.Button;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -26,6 +24,8 @@ import androidx.recyclerview.widget.DiffUtil;
|
|||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
@ -49,6 +49,7 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
|||||||
import eu.toldi.infinityforlemmy.customviews.SpoilerOnClickTextView;
|
import eu.toldi.infinityforlemmy.customviews.SpoilerOnClickTextView;
|
||||||
import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
|
import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
|
||||||
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
|
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemCommentBinding;
|
||||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
@ -169,7 +170,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
mMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
||||||
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
miscPlugin, mCommentColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +178,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if (viewType == VIEW_TYPE_DATA) {
|
if (viewType == VIEW_TYPE_DATA) {
|
||||||
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
return new CommentViewHolder(ItemCommentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
} else if (viewType == VIEW_TYPE_ERROR) {
|
} else if (viewType == VIEW_TYPE_ERROR) {
|
||||||
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
||||||
} else {
|
} else {
|
||||||
@ -187,24 +188,24 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentBaseViewHolder) {
|
||||||
Comment comment = getItem(holder.getBindingAdapterPosition());
|
Comment comment = getItem(holder.getBindingAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
String name = comment.getCommunityQualifiedName();
|
String name = comment.getCommunityQualifiedName();
|
||||||
((CommentViewHolder) holder).authorTextView.setText(name);
|
((CommentBaseViewHolder) holder).authorTextView.setText(name);
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
||||||
|
|
||||||
|
|
||||||
if (mShowElapsedTime) {
|
if (mShowElapsedTime) {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(
|
((CommentBaseViewHolder) holder).commentTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
((CommentBaseViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
((CommentViewHolder) holder).markwonAdapter.setMarkdown(mMarkwon, comment.getCommentMarkdown());
|
((CommentViewHolder) holder).markwonAdapter.setMarkdown(mMarkwon, comment.getCommentMarkdown());
|
||||||
// noinspection NotifyDataSetChanged
|
// noinspection NotifyDataSetChanged
|
||||||
((CommentViewHolder) holder).markwonAdapter.notifyDataSetChanged();
|
((CommentBaseViewHolder) holder).markwonAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
String commentText = Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
String commentText = Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType());
|
comment.getScore() + comment.getVoteType());
|
||||||
@ -213,21 +214,21 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case Comment.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentBaseViewHolder) holder).downvoteButton.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
((CommentBaseViewHolder) holder).saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentBaseViewHolder) holder).saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,14 +250,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentBaseViewHolder) {
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setText("");
|
((CommentBaseViewHolder) holder).authorFlairTextView.setText("");
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).awardsTextView.setText("");
|
((CommentBaseViewHolder) holder).awardsTextView.setText("");
|
||||||
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
((CommentBaseViewHolder) holder).downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,18 +292,18 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onItemSwipe(RecyclerView.ViewHolder viewHolder, int direction, int swipeLeftAction, int swipeRightAction) {
|
public void onItemSwipe(RecyclerView.ViewHolder viewHolder, int direction, int swipeLeftAction, int swipeRightAction) {
|
||||||
if (viewHolder instanceof CommentViewHolder) {
|
if (viewHolder instanceof CommentBaseViewHolder) {
|
||||||
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.START) {
|
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.START) {
|
||||||
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
||||||
((CommentViewHolder) viewHolder).upvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).upvoteButton.performClick();
|
||||||
} else if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
} else if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
||||||
((CommentViewHolder) viewHolder).downvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
||||||
((CommentViewHolder) viewHolder).upvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).upvoteButton.performClick();
|
||||||
} else if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
} else if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
||||||
((CommentViewHolder) viewHolder).downvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,46 +321,60 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommentViewHolder extends RecyclerView.ViewHolder {
|
public class CommentBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.vertical_block_indentation_item_comment)
|
|
||||||
CommentIndentationView commentIndentationView;
|
|
||||||
@BindView(R.id.linear_layout_item_comment)
|
|
||||||
LinearLayout linearLayout;
|
LinearLayout linearLayout;
|
||||||
@BindView(R.id.author_text_view_item_post_comment)
|
|
||||||
TextView authorTextView;
|
TextView authorTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_comment)
|
|
||||||
TextView authorFlairTextView;
|
TextView authorFlairTextView;
|
||||||
@BindView(R.id.comment_time_text_view_item_post_comment)
|
|
||||||
TextView commentTimeTextView;
|
TextView commentTimeTextView;
|
||||||
@BindView(R.id.awards_text_view_item_comment)
|
|
||||||
TextView awardsTextView;
|
TextView awardsTextView;
|
||||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
|
||||||
RecyclerView commentMarkdownView;
|
RecyclerView commentMarkdownView;
|
||||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
|
||||||
ConstraintLayout bottomConstraintLayout;
|
ConstraintLayout bottomConstraintLayout;
|
||||||
@BindView(R.id.up_vote_button_item_post_comment)
|
MaterialButton upvoteButton;
|
||||||
ImageView upvoteButton;
|
|
||||||
@BindView(R.id.score_text_view_item_post_comment)
|
|
||||||
TextView scoreTextView;
|
TextView scoreTextView;
|
||||||
@BindView(R.id.down_vote_button_item_post_comment)
|
MaterialButton downvoteButton;
|
||||||
ImageView downvoteButton;
|
|
||||||
@BindView(R.id.placeholder_item_post_comment)
|
|
||||||
View placeholder;
|
View placeholder;
|
||||||
@BindView(R.id.more_button_item_post_comment)
|
MaterialButton moreButton;
|
||||||
ImageView moreButton;
|
MaterialButton saveButton;
|
||||||
@BindView(R.id.save_button_item_post_comment)
|
MaterialButton replyButton;
|
||||||
ImageView saveButton;
|
|
||||||
@BindView(R.id.expand_button_item_post_comment)
|
|
||||||
TextView expandButton;
|
|
||||||
@BindView(R.id.reply_button_item_post_comment)
|
|
||||||
ImageView replyButton;
|
|
||||||
@BindView(R.id.divider_item_comment)
|
|
||||||
View commentDivider;
|
View commentDivider;
|
||||||
CustomMarkwonAdapter markwonAdapter;
|
CustomMarkwonAdapter markwonAdapter;
|
||||||
|
|
||||||
CommentViewHolder(View itemView) {
|
CommentBaseViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
}
|
||||||
|
|
||||||
|
void setBaseView(LinearLayout linearLayout,
|
||||||
|
TextView authorTextView,
|
||||||
|
TextView authorFlairTextView,
|
||||||
|
TextView commentTimeTextView,
|
||||||
|
TextView awardsTextView,
|
||||||
|
RecyclerView commentMarkdownView,
|
||||||
|
ConstraintLayout bottomConstraintLayout,
|
||||||
|
MaterialButton upvoteButton,
|
||||||
|
TextView scoreTextView,
|
||||||
|
MaterialButton downvoteButton,
|
||||||
|
View placeholder,
|
||||||
|
MaterialButton moreButton,
|
||||||
|
MaterialButton saveButton,
|
||||||
|
TextView expandButton,
|
||||||
|
MaterialButton replyButton,
|
||||||
|
CommentIndentationView commentIndentationView,
|
||||||
|
View commentDivider) {
|
||||||
|
this.linearLayout = linearLayout;
|
||||||
|
this.authorTextView = authorTextView;
|
||||||
|
this.authorFlairTextView = authorFlairTextView;
|
||||||
|
this.commentTimeTextView = commentTimeTextView;
|
||||||
|
this.awardsTextView = awardsTextView;
|
||||||
|
this.commentMarkdownView = commentMarkdownView;
|
||||||
|
this.bottomConstraintLayout = bottomConstraintLayout;
|
||||||
|
this.upvoteButton = upvoteButton;
|
||||||
|
this.scoreTextView = scoreTextView;
|
||||||
|
this.downvoteButton = downvoteButton;
|
||||||
|
this.placeholder = placeholder;
|
||||||
|
this.moreButton = moreButton;
|
||||||
|
this.saveButton = saveButton;
|
||||||
|
this.replyButton = replyButton;
|
||||||
|
this.commentDivider = commentDivider;
|
||||||
|
|
||||||
replyButton.setVisibility(View.GONE);
|
replyButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
@ -413,19 +430,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
authorFlairTextView.setTypeface(mActivity.typeface);
|
authorFlairTextView.setTypeface(mActivity.typeface);
|
||||||
commentTimeTextView.setTypeface(mActivity.typeface);
|
commentTimeTextView.setTypeface(mActivity.typeface);
|
||||||
awardsTextView.setTypeface(mActivity.typeface);
|
awardsTextView.setTypeface(mActivity.typeface);
|
||||||
scoreTextView.setTypeface(mActivity.typeface);
|
upvoteButton.setTypeface(mActivity.typeface);
|
||||||
}
|
}
|
||||||
itemView.setBackgroundColor(mCommentBackgroundColor);
|
itemView.setBackgroundColor(mCommentBackgroundColor);
|
||||||
authorTextView.setTextColor(mUsernameColor);
|
authorTextView.setTextColor(mUsernameColor);
|
||||||
authorFlairTextView.setTextColor(mAuthorFlairColor);
|
authorFlairTextView.setTextColor(mAuthorFlairColor);
|
||||||
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
awardsTextView.setTextColor(mSecondaryTextColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
moreButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
saveButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
replyButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
|
|
||||||
authorTextView.setOnClickListener(view -> {
|
authorTextView.setOnClickListener(view -> {
|
||||||
@ -517,20 +534,22 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_UPVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_UPVOTE);
|
||||||
upvoteButton
|
upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted 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);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,23 +565,25 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,6 +594,10 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scoreTextView.setOnClickListener(view -> {
|
||||||
|
upvoteButton.performClick();
|
||||||
|
});
|
||||||
|
|
||||||
downvoteButton.setOnClickListener(view -> {
|
downvoteButton.setOnClickListener(view -> {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
@ -588,19 +613,22 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
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.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.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.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,22 +644,24 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
||||||
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.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,7 +687,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -666,7 +696,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -678,7 +708,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -687,7 +717,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -698,6 +728,32 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CommentViewHolder extends CommentBaseViewHolder {
|
||||||
|
ItemCommentBinding binding;
|
||||||
|
|
||||||
|
CommentViewHolder(ItemCommentBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
setBaseView(binding.linearLayoutItemComment,
|
||||||
|
binding.authorTextViewItemPostComment,
|
||||||
|
binding.authorFlairTextViewItemPostComment,
|
||||||
|
binding.commentTimeTextViewItemPostComment,
|
||||||
|
binding.awardsTextViewItemComment,
|
||||||
|
binding.commentMarkdownViewItemPostComment,
|
||||||
|
binding.bottomConstraintLayoutItemPostComment,
|
||||||
|
binding.upvoteButtonItemPostComment,
|
||||||
|
binding.scoreTextViewItemPostComment,
|
||||||
|
binding.downvoteButtonItemPostComment,
|
||||||
|
binding.placeholderItemPostComment,
|
||||||
|
binding.moreButtonItemPostComment,
|
||||||
|
binding.saveButtonItemPostComment,
|
||||||
|
binding.expandButtonItemPostComment,
|
||||||
|
binding.replyButtonItemPostComment,
|
||||||
|
binding.verticalBlockIndentationItemComment,
|
||||||
|
binding.dividerItemComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ErrorViewHolder extends RecyclerView.ViewHolder {
|
class ErrorViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.error_text_view_item_footer_error)
|
@BindView(R.id.error_text_view_item_footer_error)
|
||||||
TextView errorTextView;
|
TextView errorTextView;
|
||||||
|
@ -4,7 +4,6 @@ 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.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -31,6 +30,7 @@ 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;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -58,6 +58,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.CommentMoreBottomSheetFrag
|
|||||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.CommentIndentationView;
|
import eu.toldi.infinityforlemmy.customviews.CommentIndentationView;
|
||||||
import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
|
import eu.toldi.infinityforlemmy.customviews.CustomMarkwonAdapter;
|
||||||
@ -65,6 +66,7 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
|||||||
import eu.toldi.infinityforlemmy.customviews.SpoilerOnClickTextView;
|
import eu.toldi.infinityforlemmy.customviews.SpoilerOnClickTextView;
|
||||||
import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
|
import eu.toldi.infinityforlemmy.customviews.SwipeLockInterface;
|
||||||
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
|
import eu.toldi.infinityforlemmy.customviews.SwipeLockLinearLayoutManager;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemCommentBinding;
|
||||||
import eu.toldi.infinityforlemmy.fragments.ViewPostDetailFragment;
|
import eu.toldi.infinityforlemmy.fragments.ViewPostDetailFragment;
|
||||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
@ -160,7 +162,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
private int mSingleCommentThreadBackgroundColor;
|
private int mSingleCommentThreadBackgroundColor;
|
||||||
private int mVoteAndReplyUnavailableVoteButtonColor;
|
private int mVoteAndReplyUnavailableVoteButtonColor;
|
||||||
private int mButtonTextColor;
|
private int mButtonTextColor;
|
||||||
private int mPostIconAndInfoColor;
|
|
||||||
private int mCommentIconAndInfoColor;
|
private int mCommentIconAndInfoColor;
|
||||||
private int mFullyCollapsedCommentBackgroundColor;
|
private int mFullyCollapsedCommentBackgroundColor;
|
||||||
private int mAwardedCommentBackgroundColor;
|
private int mAwardedCommentBackgroundColor;
|
||||||
@ -220,7 +221,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
mCommentMarkwon = MarkdownUtils.createFullRedditMarkwon(mActivity,
|
||||||
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener);
|
miscPlugin, mCommentTextColor, commentSpoilerBackgroundColor, onLinkLongClickListener, sharedPreferences.getBoolean(SharedPreferencesUtils.DISABLE_IMAGE_PREVIEW, false));
|
||||||
recycledViewPool = new RecyclerView.RecycledViewPool();
|
recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
mAccountQualifiedName = accountName;
|
mAccountQualifiedName = accountName;
|
||||||
@ -278,7 +279,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
mSingleCommentThreadBackgroundColor = customThemeWrapper.getSingleCommentThreadBackgroundColor();
|
mSingleCommentThreadBackgroundColor = customThemeWrapper.getSingleCommentThreadBackgroundColor();
|
||||||
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
|
mVoteAndReplyUnavailableVoteButtonColor = customThemeWrapper.getVoteAndReplyUnavailableButtonColor();
|
||||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
mPostIconAndInfoColor = customThemeWrapper.getPostIconAndInfoColor();
|
|
||||||
mCommentIconAndInfoColor = customThemeWrapper.getCommentIconAndInfoColor();
|
mCommentIconAndInfoColor = customThemeWrapper.getCommentIconAndInfoColor();
|
||||||
mFullyCollapsedCommentBackgroundColor = customThemeWrapper.getFullyCollapsedCommentBackgroundColor();
|
mFullyCollapsedCommentBackgroundColor = customThemeWrapper.getFullyCollapsedCommentBackgroundColor();
|
||||||
mAwardedCommentBackgroundColor = customThemeWrapper.getAwardedCommentBackgroundColor();
|
mAwardedCommentBackgroundColor = customThemeWrapper.getAwardedCommentBackgroundColor();
|
||||||
@ -360,7 +360,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
case VIEW_TYPE_NO_COMMENT_PLACEHOLDER:
|
case VIEW_TYPE_NO_COMMENT_PLACEHOLDER:
|
||||||
return new NoCommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_no_comment_placeholder, parent, false));
|
return new NoCommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_no_comment_placeholder, parent, false));
|
||||||
case VIEW_TYPE_COMMENT:
|
case VIEW_TYPE_COMMENT:
|
||||||
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
return new CommentViewHolder(ItemCommentBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
case VIEW_TYPE_COMMENT_FULLY_COLLAPSED:
|
case VIEW_TYPE_COMMENT_FULLY_COLLAPSED:
|
||||||
return new CommentFullyCollapsedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_fully_collapsed, parent, false));
|
return new CommentFullyCollapsedViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment_fully_collapsed, parent, false));
|
||||||
case VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS:
|
case VIEW_TYPE_LOAD_MORE_CHILD_COMMENTS:
|
||||||
@ -376,7 +376,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentBaseViewHolder) {
|
||||||
Comment comment = getCurrentComment(position);
|
Comment comment = getCurrentComment(position);
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
if (mIsSingleCommentThreadMode && comment.getId() == mSingleCommentId) {
|
if (mIsSingleCommentThreadMode && comment.getId() == mSingleCommentId) {
|
||||||
@ -384,23 +384,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
String authorDisplayName = (mShowUserDisplayName) ? comment.getAuthorName() : comment.getAuthor().getUsername();
|
String authorDisplayName = (mShowUserDisplayName) ? comment.getAuthorName() : comment.getAuthor().getUsername();
|
||||||
String authorInstance = (mHideUserInstance) ? "" : "@" + comment.getAuthor().getQualifiedName().split(Pattern.quote("@"))[1];
|
String authorInstance = (mHideUserInstance) ? "" : "@" + comment.getAuthor().getQualifiedName().split(Pattern.quote("@"))[1];
|
||||||
((CommentViewHolder) holder).authorTextView.setText(authorDisplayName + authorInstance);
|
((CommentBaseViewHolder) holder).authorTextView.setText(authorDisplayName + authorInstance);
|
||||||
|
|
||||||
|
|
||||||
if (comment.isSubmitter()) {
|
if (comment.isSubmitter()) {
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mSubmitterColor);
|
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mSubmitterColor);
|
||||||
Drawable submitterDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_mic_14dp, mSubmitterColor);
|
Drawable submitterDrawable = Utils.getTintedDrawable(mActivity, R.drawable.ic_mic_14dp, mSubmitterColor);
|
||||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
submitterDrawable, null, null, null);
|
submitterDrawable, null, null, null);
|
||||||
} else if (comment.isModerator()) {
|
} else if (comment.isModerator()) {
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mModeratorColor);
|
((CommentBaseViewHolder) holder).authorTextView.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);
|
||||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
moderatorDrawable, null, null, null);
|
moderatorDrawable, null, null, null);
|
||||||
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
} else if (comment.getAuthorQualifiedName().equals(mAccountQualifiedName)) {
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mCurrentUserColor);
|
((CommentBaseViewHolder) 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(
|
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
currentUserDrawable, null, null, null);
|
currentUserDrawable, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
.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)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
.into(((CommentViewHolder) holder).authorIconImageView);
|
.into(((CommentBaseViewHolder) holder).authorIconImageView);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -424,33 +424,33 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
.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)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
.into(((CommentViewHolder) holder).authorIconImageView);
|
.into(((CommentBaseViewHolder) holder).authorIconImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowElapsedTime) {
|
if (mShowElapsedTime) {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(
|
((CommentBaseViewHolder) holder).commentTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
((CommentBaseViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCommentToolbarHidden) {
|
if (mCommentToolbarHidden) {
|
||||||
((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
|
((CommentBaseViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
((CommentBaseViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||||
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
((CommentViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
|
((CommentBaseViewHolder) holder).mMarkwonAdapter.setMarkdown(mCommentMarkwon, comment.getCommentMarkdown());
|
||||||
// noinspection NotifyDataSetChanged
|
// noinspection NotifyDataSetChanged
|
||||||
((CommentViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
|
((CommentBaseViewHolder) holder).mMarkwonAdapter.notifyDataSetChanged();
|
||||||
if (mHideDownvotes) {
|
if (mHideDownvotes) {
|
||||||
((CommentViewHolder) holder).downvoteButton.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).downvoteButton.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).downvoteTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
@ -466,96 +466,89 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (mSeperateUpandDownvote) {
|
if (mSeperateUpandDownvote) {
|
||||||
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||||
((CommentViewHolder) holder).downvoteTextView.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).downvoteTextView.setVisibility(View.VISIBLE);
|
||||||
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
((CommentBaseViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, upvotes));
|
||||||
((CommentViewHolder) holder).downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
((CommentBaseViewHolder) holder).downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
((CommentViewHolder) holder).scoreTextView.setGravity(Gravity.START);
|
((CommentBaseViewHolder) holder).scoreTextView.setGravity(Gravity.START);
|
||||||
((CommentViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
((CommentBaseViewHolder) holder).scoreTextView.getLayoutParams().width = (int) (32 * mActivity.getResources().getDisplayMetrics().density);
|
||||||
|
|
||||||
((CommentViewHolder) holder).scoreTextView.setPadding(0, 0, 6, 0);
|
((CommentBaseViewHolder) holder).scoreTextView.setPadding(0, 0, 6, 0);
|
||||||
((CommentViewHolder) holder).downvoteButton.setPadding(24, 0, 12, 0);
|
((CommentBaseViewHolder) holder).downvoteButton.setPadding(24, 0, 12, 0);
|
||||||
((CommentViewHolder) holder).upvoteButton.setPadding(24, 0, 12, 0);
|
((CommentBaseViewHolder) holder).upvoteButton.setPadding(24, 0, 12, 0);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).scoreTextView.setText(commentText);
|
((CommentBaseViewHolder) holder).scoreTextView.setText(commentText);
|
||||||
}
|
}
|
||||||
((CommentViewHolder) holder).topScoreTextView.setText(topScoreText);
|
((CommentBaseViewHolder) holder).topScoreTextView.setText(topScoreText);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
((CommentBaseViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.vote));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.isEdited()) {
|
if (comment.isEdited()) {
|
||||||
((CommentViewHolder) holder).editedTextView.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).editedTextView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).editedTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).editedTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
((CommentViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
|
((CommentBaseViewHolder) holder).commentIndentationView.setShowOnlyOneDivider(mShowOnlyOneCommentLevelIndicator);
|
||||||
((CommentViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
|
((CommentBaseViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
|
||||||
if (comment.getDepth() >= mDepthThreshold) {
|
if (comment.getDepth() >= mDepthThreshold) {
|
||||||
((CommentViewHolder) holder).saveButton.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).saveButton.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).replyButton.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).replyButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).saveButton.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).saveButton.setVisibility(View.VISIBLE);
|
||||||
((CommentViewHolder) holder).replyButton.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).replyButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.hasReply()) {
|
if (comment.hasReply()) {
|
||||||
if (comment.getChildCount() > 0 && (mAlwaysShowChildCommentCount || !comment.isExpanded())) {
|
if (comment.getChildCount() > 0 && (mAlwaysShowChildCommentCount || !comment.isExpanded())) {
|
||||||
((CommentViewHolder) holder).expandButton.setText("+" + comment.getChildCount());
|
((CommentBaseViewHolder) holder).expandButton.setText("+" + comment.getChildCount());
|
||||||
}
|
}
|
||||||
if (comment.isExpanded()) {
|
if (comment.isExpanded()) {
|
||||||
((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null);
|
((CommentBaseViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(collapseDrawable, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null);
|
((CommentBaseViewHolder) holder).expandButton.setCompoundDrawablesWithIntrinsicBounds(expandDrawable, null, null, null);
|
||||||
}
|
}
|
||||||
((CommentViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
|
((CommentBaseViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case Comment.VOTE_TYPE_UPVOTE:
|
case Comment.VOTE_TYPE_UPVOTE:
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentBaseViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
break;
|
break;
|
||||||
case Comment.VOTE_TYPE_DOWNVOTE:
|
case Comment.VOTE_TYPE_DOWNVOTE:
|
||||||
((CommentViewHolder) holder).downvoteButton
|
((CommentBaseViewHolder) holder).downvoteButton.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
if(mSeperateUpandDownvote) {
|
if (mSeperateUpandDownvote) {
|
||||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mDownvotedColor);
|
((CommentBaseViewHolder) holder).downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
((CommentViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentBaseViewHolder) holder).downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
((CommentViewHolder) holder).replyButton
|
((CommentBaseViewHolder) holder).replyButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor));
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor));
|
||||||
PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mVoteAndReplyUnavailableVoteButtonColor);
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor));
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
((CommentViewHolder) holder).downvoteButton
|
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isLocked()) {
|
if (mPost.isLocked()) {
|
||||||
((CommentViewHolder) holder).replyButton
|
((CommentBaseViewHolder) holder).replyButton.setIconTint(ColorStateList.valueOf(mVoteAndReplyUnavailableVoteButtonColor));
|
||||||
.setColorFilter(mVoteAndReplyUnavailableVoteButtonColor,
|
|
||||||
PorterDuff.Mode.SRC_IN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
((CommentBaseViewHolder) holder).saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentBaseViewHolder) holder).saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position == mSearchCommentIndex) {
|
if (position == mSearchCommentIndex) {
|
||||||
@ -661,7 +654,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
SortType.Type sortType = mCommentRecyclerViewAdapterCallback.getSortType();
|
SortType.Type sortType = mCommentRecyclerViewAdapterCallback.getSortType();
|
||||||
FetchComment.fetchComments(mExecutor, new Handler(), retrofit, mAccessToken,
|
FetchComment.fetchComments(mExecutor, new Handler(), retrofit, mAccessToken,
|
||||||
mPost.getId(), parentComment.getId(), sortType,
|
mPost.getId(), parentComment.getId(), sortType,
|
||||||
mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
mExpandChildren, 1, new CommentFilter(), new FetchComment.FetchCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||||
if (parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
|
if (parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
|
||||||
@ -818,7 +811,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
/**
|
/**
|
||||||
* Find position of comment with given {@code fullName} and
|
* Find position of comment with given {@code fullName} and
|
||||||
* {@link Comment#NOT_PLACEHOLDER} placeholder type
|
* {@link Comment#NOT_PLACEHOLDER} placeholder type
|
||||||
*
|
|
||||||
* @return position of the placeholder or -1 if not found
|
* @return position of the placeholder or -1 if not found
|
||||||
*/
|
*/
|
||||||
private int findCommentPosition(int fullName, int positionHint) {
|
private int findCommentPosition(int fullName, int positionHint) {
|
||||||
@ -828,7 +820,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
/**
|
/**
|
||||||
* Find position of comment with given {@code fullName} and
|
* Find position of comment with given {@code fullName} and
|
||||||
* {@link Comment#PLACEHOLDER_LOAD_MORE_COMMENTS} placeholder type
|
* {@link Comment#PLACEHOLDER_LOAD_MORE_COMMENTS} placeholder type
|
||||||
*
|
|
||||||
* @return position of the placeholder or -1 if not found
|
* @return position of the placeholder or -1 if not found
|
||||||
*/
|
*/
|
||||||
private int findLoadMoreCommentsPlaceholderPosition(int id, int positionHint) {
|
private int findLoadMoreCommentsPlaceholderPosition(int id, int positionHint) {
|
||||||
@ -1123,18 +1114,18 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onItemSwipe(RecyclerView.ViewHolder viewHolder, int direction, int swipeLeftAction, int swipeRightAction) {
|
public void onItemSwipe(RecyclerView.ViewHolder viewHolder, int direction, int swipeLeftAction, int swipeRightAction) {
|
||||||
if (viewHolder instanceof CommentViewHolder) {
|
if (viewHolder instanceof CommentBaseViewHolder) {
|
||||||
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.START) {
|
if (direction == ItemTouchHelper.LEFT || direction == ItemTouchHelper.START) {
|
||||||
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
||||||
((CommentViewHolder) viewHolder).upvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).upvoteButton.performClick();
|
||||||
} else if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
} else if (swipeLeftAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
||||||
((CommentViewHolder) viewHolder).downvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_UPVOTE) {
|
||||||
((CommentViewHolder) viewHolder).upvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).upvoteButton.performClick();
|
||||||
} else if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
} else if (swipeRightAction == SharedPreferencesUtils.SWIPE_ACITON_DOWNVOTE) {
|
||||||
((CommentViewHolder) viewHolder).downvoteButton.performClick();
|
((CommentBaseViewHolder) viewHolder).downvoteButton.performClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1161,21 +1152,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
if (holder instanceof CommentViewHolder) {
|
if (holder instanceof CommentBaseViewHolder) {
|
||||||
holder.itemView.setBackgroundColor(mCommentBackgroundColor);
|
holder.itemView.setBackgroundColor(mCommentBackgroundColor);
|
||||||
((CommentViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
|
((CommentBaseViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
((CommentBaseViewHolder) holder).authorTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
||||||
mGlide.clear(((CommentViewHolder) holder).authorIconImageView);
|
mGlide.clear(((CommentBaseViewHolder) holder).authorIconImageView);
|
||||||
((CommentViewHolder) holder).topScoreTextView.setTextColor(mSecondaryTextColor);
|
((CommentBaseViewHolder) holder).topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
((CommentViewHolder) holder).awardsTextView.setText("");
|
((CommentBaseViewHolder) holder).awardsTextView.setText("");
|
||||||
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).expandButton.setVisibility(View.GONE);
|
((CommentBaseViewHolder) holder).expandButton.setVisibility(View.GONE);
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentBaseViewHolder) holder).upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
((CommentViewHolder) holder).expandButton.setText("");
|
((CommentBaseViewHolder) holder).downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
((CommentViewHolder) holder).replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
((CommentBaseViewHolder) holder).downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
((CommentBaseViewHolder) holder).expandButton.setText("");
|
||||||
|
((CommentBaseViewHolder) holder).replyButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
|
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
|
||||||
params.setMargins(0, 0, 0, 0);
|
params.setMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -1210,55 +1203,76 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
SortType.Type getSortType();
|
SortType.Type getSortType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CommentViewHolder extends RecyclerView.ViewHolder {
|
public class CommentBaseViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.linear_layout_item_comment)
|
|
||||||
LinearLayout linearLayout;
|
LinearLayout linearLayout;
|
||||||
@BindView(R.id.author_icon_image_view_item_post_comment)
|
|
||||||
ImageView authorIconImageView;
|
ImageView authorIconImageView;
|
||||||
@BindView(R.id.author_text_view_item_post_comment)
|
|
||||||
TextView authorTextView;
|
TextView authorTextView;
|
||||||
@BindView(R.id.author_flair_text_view_item_post_comment)
|
|
||||||
TextView authorFlairTextView;
|
TextView authorFlairTextView;
|
||||||
@BindView(R.id.comment_time_text_view_item_post_comment)
|
|
||||||
TextView commentTimeTextView;
|
TextView commentTimeTextView;
|
||||||
@BindView(R.id.top_score_text_view_item_post_comment)
|
|
||||||
TextView topScoreTextView;
|
TextView topScoreTextView;
|
||||||
@BindView(R.id.awards_text_view_item_comment)
|
|
||||||
TextView awardsTextView;
|
TextView awardsTextView;
|
||||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
|
||||||
RecyclerView commentMarkdownView;
|
RecyclerView commentMarkdownView;
|
||||||
@BindView(R.id.edited_text_view_item_post_comment)
|
|
||||||
TextView editedTextView;
|
TextView editedTextView;
|
||||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
|
||||||
ConstraintLayout bottomConstraintLayout;
|
ConstraintLayout bottomConstraintLayout;
|
||||||
@BindView(R.id.up_vote_button_item_post_comment)
|
MaterialButton upvoteButton;
|
||||||
ImageView upvoteButton;
|
|
||||||
@BindView(R.id.score_text_view_item_post_comment)
|
|
||||||
TextView scoreTextView;
|
TextView scoreTextView;
|
||||||
|
|
||||||
@BindView(R.id.downvote_text_view_item_post_comment)
|
|
||||||
TextView downvoteTextView;
|
TextView downvoteTextView;
|
||||||
@BindView(R.id.down_vote_button_item_post_comment)
|
MaterialButton downvoteButton;
|
||||||
ImageView downvoteButton;
|
|
||||||
@BindView(R.id.placeholder_item_post_comment)
|
|
||||||
View placeholder;
|
View placeholder;
|
||||||
@BindView(R.id.more_button_item_post_comment)
|
MaterialButton moreButton;
|
||||||
ImageView moreButton;
|
MaterialButton saveButton;
|
||||||
@BindView(R.id.save_button_item_post_comment)
|
|
||||||
ImageView saveButton;
|
|
||||||
@BindView(R.id.expand_button_item_post_comment)
|
|
||||||
TextView expandButton;
|
TextView expandButton;
|
||||||
@BindView(R.id.reply_button_item_post_comment)
|
MaterialButton replyButton;
|
||||||
ImageView replyButton;
|
|
||||||
@BindView(R.id.vertical_block_indentation_item_comment)
|
|
||||||
CommentIndentationView commentIndentationView;
|
CommentIndentationView commentIndentationView;
|
||||||
@BindView(R.id.divider_item_comment)
|
|
||||||
View commentDivider;
|
View commentDivider;
|
||||||
CustomMarkwonAdapter mMarkwonAdapter;
|
CustomMarkwonAdapter mMarkwonAdapter;
|
||||||
|
|
||||||
CommentViewHolder(View itemView) {
|
CommentBaseViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
}
|
||||||
|
|
||||||
|
void setBaseView(LinearLayout linearLayout,
|
||||||
|
ImageView authorIconImageView,
|
||||||
|
TextView authorTextView,
|
||||||
|
TextView authorFlairTextView,
|
||||||
|
TextView commentTimeTextView,
|
||||||
|
TextView topScoreTextView,
|
||||||
|
TextView awardsTextView,
|
||||||
|
RecyclerView commentMarkdownView,
|
||||||
|
TextView editedTextView,
|
||||||
|
ConstraintLayout bottomConstraintLayout,
|
||||||
|
MaterialButton upvoteButton,
|
||||||
|
TextView scoreTextView,
|
||||||
|
MaterialButton downvoteButton,
|
||||||
|
TextView downvoteTextView,
|
||||||
|
View placeholder,
|
||||||
|
MaterialButton moreButton,
|
||||||
|
MaterialButton saveButton,
|
||||||
|
TextView expandButton,
|
||||||
|
MaterialButton replyButton,
|
||||||
|
CommentIndentationView commentIndentationView,
|
||||||
|
View commentDivider) {
|
||||||
|
this.linearLayout = linearLayout;
|
||||||
|
this.authorIconImageView = authorIconImageView;
|
||||||
|
this.authorTextView = authorTextView;
|
||||||
|
this.authorFlairTextView = authorFlairTextView;
|
||||||
|
this.commentTimeTextView = commentTimeTextView;
|
||||||
|
this.topScoreTextView = topScoreTextView;
|
||||||
|
this.awardsTextView = awardsTextView;
|
||||||
|
this.commentMarkdownView = commentMarkdownView;
|
||||||
|
this.editedTextView = editedTextView;
|
||||||
|
this.bottomConstraintLayout = bottomConstraintLayout;
|
||||||
|
this.upvoteButton = upvoteButton;
|
||||||
|
this.scoreTextView = scoreTextView;
|
||||||
|
this.downvoteButton = downvoteButton;
|
||||||
|
this.downvoteTextView = downvoteTextView;
|
||||||
|
this.placeholder = placeholder;
|
||||||
|
this.moreButton = moreButton;
|
||||||
|
this.saveButton = saveButton;
|
||||||
|
this.expandButton = expandButton;
|
||||||
|
this.replyButton = replyButton;
|
||||||
|
this.commentIndentationView = commentIndentationView;
|
||||||
|
this.commentDivider = commentDivider;
|
||||||
|
|
||||||
if (mVoteButtonsOnTheRight) {
|
if (mVoteButtonsOnTheRight) {
|
||||||
ConstraintSet constraintSet = new ConstraintSet();
|
ConstraintSet constraintSet = new ConstraintSet();
|
||||||
@ -1360,14 +1374,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
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.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
moreButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
moreButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
expandButton.setTextColor(mCommentIconAndInfoColor);
|
expandButton.setTextColor(mCommentIconAndInfoColor);
|
||||||
saveButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
saveButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
replyButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
replyButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
authorFlairTextView.setOnClickListener(view -> authorTextView.performClick());
|
||||||
|
|
||||||
@ -1454,20 +1468,23 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = Integer.parseInt(APIUtils.DIR_UPVOTE);
|
newVoteType = Integer.parseInt(APIUtils.DIR_UPVOTE);
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted 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);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
@ -1497,7 +1514,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
|
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_filled_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mUpvotedColor));
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
topScoreTextView.setTextColor(mUpvotedColor);
|
topScoreTextView.setTextColor(mUpvotedColor);
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -1505,7 +1523,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
@ -1513,9 +1532,10 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
if(mSeperateUpandDownvote){
|
if (mSeperateUpandDownvote) {
|
||||||
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
int upvoteCount = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
upvoteCount));
|
upvoteCount));
|
||||||
@ -1540,6 +1560,14 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
scoreTextView.setOnClickListener(view -> {
|
||||||
|
upvoteButton.performClick();
|
||||||
|
});
|
||||||
|
|
||||||
|
downvoteTextView.setOnClickListener(view -> {
|
||||||
|
downvoteButton.performClick();
|
||||||
|
});
|
||||||
|
|
||||||
downvoteButton.setOnClickListener(view -> {
|
downvoteButton.setOnClickListener(view -> {
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
||||||
@ -1556,17 +1584,19 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
int newVoteType;
|
int newVoteType;
|
||||||
|
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
|
|
||||||
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != Comment.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
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.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
if(mSeperateUpandDownvote){
|
downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
|
if (mSeperateUpandDownvote) {
|
||||||
downvoteTextView.setTextColor(mDownvotedColor);
|
downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}else {
|
} else {
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
}
|
}
|
||||||
topScoreTextView.setTextColor(mDownvotedColor);
|
topScoreTextView.setTextColor(mDownvotedColor);
|
||||||
@ -1574,7 +1604,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
//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.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
@ -1604,7 +1635,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
|
||||||
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.setIconResource(R.drawable.ic_downvote_filled_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mDownvotedColor));
|
||||||
if (mSeperateUpandDownvote) {
|
if (mSeperateUpandDownvote) {
|
||||||
downvoteTextView.setTextColor(mDownvotedColor);
|
downvoteTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
@ -1615,7 +1647,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
} else {
|
} else {
|
||||||
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(Comment.VOTE_TYPE_NO_VOTE);
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
downvoteButton.setIconResource(R.drawable.ic_downvote_24dp);
|
||||||
|
downvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
downvoteTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
@ -1623,11 +1656,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosition == position) {
|
if (currentPosition == position) {
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, PorterDuff.Mode.SRC_IN);
|
upvoteButton.setIconResource(R.drawable.ic_upvote_24dp);
|
||||||
|
upvoteButton.setIconTint(ColorStateList.valueOf(mCommentIconAndInfoColor));
|
||||||
if (!mHideTheNumberOfVotes) {
|
if (!mHideTheNumberOfVotes) {
|
||||||
if(mSeperateUpandDownvote){
|
if (mSeperateUpandDownvote) {
|
||||||
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() +1 : comment.getDownvotes();
|
int downvotes = (comment.getVoteType() == -1) ? comment.getDownvotes() + 1 : comment.getDownvotes();
|
||||||
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() +1 : comment.getUpvotes();
|
int upvotes = (comment.getVoteType() == 1) ? comment.getUpvotes() + 1 : comment.getUpvotes();
|
||||||
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
downvoteTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, downvotes));
|
||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
upvotes));
|
upvotes));
|
||||||
@ -1635,7 +1669,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
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())));
|
||||||
@ -1662,7 +1695,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -1671,7 +1704,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -1683,7 +1716,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -1692,7 +1725,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
if (getBindingAdapterPosition() == position) {
|
if (getBindingAdapterPosition() == position) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setIconResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -1830,6 +1863,36 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CommentViewHolder extends CommentBaseViewHolder {
|
||||||
|
ItemCommentBinding binding;
|
||||||
|
|
||||||
|
CommentViewHolder(ItemCommentBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
setBaseView(binding.linearLayoutItemComment,
|
||||||
|
binding.authorIconImageViewItemPostComment,
|
||||||
|
binding.authorTextViewItemPostComment,
|
||||||
|
binding.authorFlairTextViewItemPostComment,
|
||||||
|
binding.commentTimeTextViewItemPostComment,
|
||||||
|
binding.topScoreTextViewItemPostComment,
|
||||||
|
binding.awardsTextViewItemComment,
|
||||||
|
binding.commentMarkdownViewItemPostComment,
|
||||||
|
binding.editedTextViewItemPostComment,
|
||||||
|
binding.bottomConstraintLayoutItemPostComment,
|
||||||
|
binding.upvoteButtonItemPostComment,
|
||||||
|
binding.scoreTextViewItemPostComment,
|
||||||
|
binding.downvoteButtonItemPostComment,
|
||||||
|
binding.downvoteTextViewItemPostComment,
|
||||||
|
binding.placeholderItemPostComment,
|
||||||
|
binding.moreButtonItemPostComment,
|
||||||
|
binding.saveButtonItemPostComment,
|
||||||
|
binding.expandButtonItemPostComment,
|
||||||
|
binding.replyButtonItemPostComment,
|
||||||
|
binding.verticalBlockIndentationItemComment,
|
||||||
|
binding.dividerItemComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Comment getCurrentComment(RecyclerView.ViewHolder holder) {
|
private Comment getCurrentComment(RecyclerView.ViewHolder holder) {
|
||||||
return getCurrentComment(holder.getBindingAdapterPosition());
|
return getCurrentComment(holder.getBindingAdapterPosition());
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
|
||||||
|
public class CustomArrayAdapter extends ArrayAdapter<String> {
|
||||||
|
|
||||||
|
CustomThemeWrapper customThemeWrapper;
|
||||||
|
|
||||||
|
public CustomArrayAdapter(@NonNull Context context, int textViewResourceId, @NonNull List<String> objects, CustomThemeWrapper customThemeWrapper) {
|
||||||
|
super(context, textViewResourceId, objects);
|
||||||
|
this.customThemeWrapper = customThemeWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
TextView itemView = (TextView) super.getView(position, convertView, parent);
|
||||||
|
itemView.setTextColor(customThemeWrapper.getPrimaryTextColor()); // Set the text color
|
||||||
|
itemView.setBackgroundColor(customThemeWrapper.getBackgroundColor()); // Set the background color
|
||||||
|
// Apply any other styling as needed
|
||||||
|
return itemView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||||
|
TextView itemView = (TextView) super.getDropDownView(position, convertView, parent);
|
||||||
|
itemView.setTextColor(customThemeWrapper.getPrimaryTextColor()); // Set the text color
|
||||||
|
itemView.setBackgroundColor(customThemeWrapper.getBackgroundColor()); // Set the background color
|
||||||
|
// Apply any other styling as needed
|
||||||
|
return itemView;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,6 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
@ -20,19 +19,18 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|
||||||
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.InsertMultireddit;
|
import eu.toldi.infinityforlemmy.asynctasks.InsertMultireddit;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.multireddit.FavoriteMultiReddit;
|
|
||||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
|
import me.zhanghai.android.fastscroll.PopupTextProvider;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements PopupTextProvider {
|
||||||
|
|
||||||
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT_DIVIDER = 0;
|
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT_DIVIDER = 0;
|
||||||
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT = 1;
|
private static final int VIEW_TYPE_FAVORITE_MULTI_REDDIT = 1;
|
||||||
@ -54,6 +52,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
|
|
||||||
public interface OnItemClickListener {
|
public interface OnItemClickListener {
|
||||||
void onClick(MultiReddit multiReddit);
|
void onClick(MultiReddit multiReddit);
|
||||||
|
|
||||||
void onLongClick(MultiReddit multiReddit);
|
void onLongClick(MultiReddit multiReddit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,80 +119,31 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
MultiReddit multiReddit = mMultiReddits.get(holder.getBindingAdapterPosition() - offset);
|
MultiReddit multiReddit = mMultiReddits.get(holder.getBindingAdapterPosition() - offset);
|
||||||
name = multiReddit.getDisplayName();
|
name = multiReddit.getDisplayName();
|
||||||
iconUrl = multiReddit.getIconUrl();
|
iconUrl = multiReddit.getIconUrl();
|
||||||
if(multiReddit.isFavorite()) {
|
if (multiReddit.isFavorite()) {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
} else {
|
} else {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
|
((MultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
|
||||||
if(multiReddit.isFavorite()) {
|
if (multiReddit.isFavorite()) {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
multiReddit.setFavorite(false);
|
multiReddit.setFavorite(false);
|
||||||
if (mAccessToken == null) {
|
|
||||||
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
|
||||||
() -> {
|
|
||||||
//Do nothing
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, false, multiReddit,
|
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
int position = holder.getBindingAdapterPosition() - offset;
|
|
||||||
if(position >= 0 && mMultiReddits.size() > position) {
|
|
||||||
mMultiReddits.get(position).setFavorite(false);
|
|
||||||
}
|
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
public void failed() {
|
() -> {
|
||||||
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
|
//Do nothing
|
||||||
int position = holder.getBindingAdapterPosition() - offset;
|
});
|
||||||
if(position >= 0 && mMultiReddits.size() > position) {
|
|
||||||
mMultiReddits.get(position).setFavorite(true);
|
|
||||||
}
|
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
multiReddit.setFavorite(true);
|
multiReddit.setFavorite(true);
|
||||||
if (mAccessToken == null) {
|
|
||||||
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
|
||||||
() -> {
|
|
||||||
//Do nothing
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, true, multiReddit,
|
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
int position = holder.getBindingAdapterPosition() - offset;
|
|
||||||
if(position >= 0 && mMultiReddits.size() > position) {
|
|
||||||
mMultiReddits.get(position).setFavorite(true);
|
|
||||||
}
|
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
public void failed() {
|
() -> {
|
||||||
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
|
//Do nothing
|
||||||
int position = holder.getBindingAdapterPosition() - offset;
|
});
|
||||||
if(position >= 0 && mMultiReddits.size() > position) {
|
|
||||||
mMultiReddits.get(position).setFavorite(false);
|
|
||||||
}
|
|
||||||
((MultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
mOnItemClickListener.onClick(multiReddit);
|
mOnItemClickListener.onClick(multiReddit);
|
||||||
@ -220,79 +170,29 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1);
|
MultiReddit multiReddit = mFavoriteMultiReddits.get(holder.getBindingAdapterPosition() - 1);
|
||||||
String name = multiReddit.getDisplayName();
|
String name = multiReddit.getDisplayName();
|
||||||
String iconUrl = multiReddit.getIconUrl();
|
String iconUrl = multiReddit.getIconUrl();
|
||||||
if(multiReddit.isFavorite()) {
|
if (multiReddit.isFavorite()) {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
} else {
|
} else {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setOnClickListener(view -> {
|
||||||
if(multiReddit.isFavorite()) {
|
if (multiReddit.isFavorite()) {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
||||||
multiReddit.setFavorite(false);
|
multiReddit.setFavorite(false);
|
||||||
if (mAccessToken == null) {
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
() -> {
|
||||||
() -> {
|
//Do nothing
|
||||||
//Do nothing
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, false, multiReddit,
|
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
int position = holder.getBindingAdapterPosition() - 1;
|
|
||||||
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
|
|
||||||
mFavoriteMultiReddits.get(position).setFavorite(false);
|
|
||||||
}
|
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void failed() {
|
|
||||||
Toast.makeText(mActivity, R.string.thing_unfavorite_failed, Toast.LENGTH_SHORT).show();
|
|
||||||
int position = holder.getBindingAdapterPosition() - 1;
|
|
||||||
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
|
|
||||||
mFavoriteMultiReddits.get(position).setFavorite(true);
|
|
||||||
}
|
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
||||||
multiReddit.setFavorite(true);
|
multiReddit.setFavorite(true);
|
||||||
if (mAccessToken == null) {
|
|
||||||
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
|
||||||
() -> {
|
|
||||||
//Do nothing
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
FavoriteMultiReddit.favoriteMultiReddit(mExecutor, new Handler(), mOauthRetrofit, mRedditDataRoomDatabase,
|
|
||||||
mAccessToken, true, multiReddit,
|
|
||||||
new FavoriteMultiReddit.FavoriteMultiRedditListener() {
|
|
||||||
@Override
|
|
||||||
public void success() {
|
|
||||||
int position = holder.getBindingAdapterPosition() - 1;
|
|
||||||
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
|
|
||||||
mFavoriteMultiReddits.get(position).setFavorite(true);
|
|
||||||
}
|
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_24dp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
InsertMultireddit.insertMultireddit(mExecutor, new Handler(), mRedditDataRoomDatabase, multiReddit,
|
||||||
public void failed() {
|
() -> {
|
||||||
Toast.makeText(mActivity, R.string.thing_favorite_failed, Toast.LENGTH_SHORT).show();
|
//Do nothing
|
||||||
int position = holder.getBindingAdapterPosition() - 1;
|
});
|
||||||
if(position >= 0 && mFavoriteMultiReddits.size() > position) {
|
|
||||||
mFavoriteMultiReddits.get(position).setFavorite(false);
|
|
||||||
}
|
|
||||||
((FavoriteMultiRedditViewHolder) holder).favoriteImageView.setImageResource(R.drawable.ic_favorite_border_24dp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
@ -322,7 +222,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (mMultiReddits != null) {
|
if (mMultiReddits != null) {
|
||||||
if(mFavoriteMultiReddits != null && mFavoriteMultiReddits.size() > 0) {
|
if (mFavoriteMultiReddits != null && mFavoriteMultiReddits.size() > 0) {
|
||||||
return mMultiReddits.size() > 0 ?
|
return mMultiReddits.size() > 0 ?
|
||||||
mFavoriteMultiReddits.size() + mMultiReddits.size() + 2 : 0;
|
mFavoriteMultiReddits.size() + mMultiReddits.size() + 2 : 0;
|
||||||
}
|
}
|
||||||
@ -334,7 +234,7 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
if(holder instanceof MultiRedditViewHolder) {
|
if (holder instanceof MultiRedditViewHolder) {
|
||||||
mGlide.clear(((MultiRedditViewHolder) holder).iconImageView);
|
mGlide.clear(((MultiRedditViewHolder) holder).iconImageView);
|
||||||
} else if (holder instanceof FavoriteMultiRedditViewHolder) {
|
} else if (holder instanceof FavoriteMultiRedditViewHolder) {
|
||||||
mGlide.clear(((FavoriteMultiRedditViewHolder) holder).iconImageView);
|
mGlide.clear(((FavoriteMultiRedditViewHolder) holder).iconImageView);
|
||||||
@ -403,7 +303,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FavoriteMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
|
class FavoriteMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) {
|
FavoriteMultiRedditsDividerViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -417,7 +318,8 @@ public class MultiRedditListingRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AllMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
|
class AllMultiRedditsDividerViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.divider_text_view_item_favorite_thing_divider) TextView dividerTextView;
|
@BindView(R.id.divider_text_view_item_favorite_thing_divider)
|
||||||
|
TextView dividerTextView;
|
||||||
|
|
||||||
AllMultiRedditsDividerViewHolder(@NonNull View itemView) {
|
AllMultiRedditsDividerViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,11 +12,15 @@ import java.util.List;
|
|||||||
|
|
||||||
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.adapters.navigationdrawer.PostFilterUsageEmbeddedRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemPostFilterWithUsageBinding;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterWithUsage;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PostFilterWithUsageRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
private static final int VIEW_TYPE_HEADER = 1;
|
private static final int VIEW_TYPE_HEADER = 1;
|
||||||
private static final int VIEW_TYPE_POST_FILTER = 2;
|
private static final int VIEW_TYPE_POST_FILTER = 2;
|
||||||
@ -24,16 +28,18 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
private CustomThemeWrapper customThemeWrapper;
|
private CustomThemeWrapper customThemeWrapper;
|
||||||
private final OnItemClickListener onItemClickListener;
|
private final OnItemClickListener onItemClickListener;
|
||||||
private List<PostFilter> postFilterList;
|
private List<PostFilterWithUsage> postFilterWithUsageList;
|
||||||
|
private RecyclerView.RecycledViewPool recycledViewPool;
|
||||||
|
|
||||||
public interface OnItemClickListener {
|
public interface OnItemClickListener {
|
||||||
void onItemClick(PostFilter postFilter);
|
void onItemClick(PostFilter postFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PostFilterRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
|
public PostFilterWithUsageRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper,
|
||||||
OnItemClickListener onItemClickListener) {
|
OnItemClickListener onItemClickListener) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.customThemeWrapper = customThemeWrapper;
|
this.customThemeWrapper = customThemeWrapper;
|
||||||
|
this.recycledViewPool = new RecyclerView.RecycledViewPool();
|
||||||
this.onItemClickListener = onItemClickListener;
|
this.onItemClickListener = onItemClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,43 +57,49 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
if (viewType == VIEW_TYPE_HEADER) {
|
if (viewType == VIEW_TYPE_HEADER) {
|
||||||
return new HeaderViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_filter_fragment_header, parent, false));
|
return new HeaderViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_filter_fragment_header, parent, false));
|
||||||
} else {
|
} else {
|
||||||
return new PostFilterViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_filter, parent, false));
|
return new PostFilterViewHolder(ItemPostFilterWithUsageBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof PostFilterViewHolder) {
|
if (holder instanceof PostFilterViewHolder) {
|
||||||
((PostFilterViewHolder) holder).textView.setText(postFilterList.get(position - 1).name);
|
((PostFilterViewHolder) holder).binding.postFilterNameTextViewItemPostFilter.setText(postFilterWithUsageList.get(position - 1).postFilter.name);
|
||||||
|
((PostFilterViewHolder) holder).adapter.setPostFilterUsageList(postFilterWithUsageList.get(position - 1).postFilterUsages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return postFilterList == null ? 1 : 1 + postFilterList.size();
|
return postFilterWithUsageList == null ? 1 : 1 + postFilterWithUsageList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPostFilterList(List<PostFilter> postFilterList) {
|
public void setPostFilterWithUsageList(List<PostFilterWithUsage> postFilterWithUsageList) {
|
||||||
this.postFilterList = postFilterList;
|
this.postFilterWithUsageList = postFilterWithUsageList;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PostFilterViewHolder extends RecyclerView.ViewHolder {
|
private class PostFilterViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView textView;
|
ItemPostFilterWithUsageBinding binding;
|
||||||
|
PostFilterUsageEmbeddedRecyclerViewAdapter adapter;
|
||||||
|
|
||||||
public PostFilterViewHolder(@NonNull View itemView) {
|
public PostFilterViewHolder(@NonNull ItemPostFilterWithUsageBinding binding) {
|
||||||
super(itemView);
|
super(binding.getRoot());
|
||||||
textView = (TextView) itemView;
|
this.binding = binding;
|
||||||
|
binding.postFilterNameTextViewItemPostFilter.setTextColor(customThemeWrapper.getPrimaryTextColor());
|
||||||
textView.setTextColor(customThemeWrapper.getPrimaryTextColor());
|
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
textView.setTypeface(activity.typeface);
|
binding.postFilterNameTextViewItemPostFilter.setTypeface(activity.typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnClickListener(view -> {
|
binding.getRoot().setOnClickListener(view -> {
|
||||||
onItemClickListener.onItemClick(postFilterList.get(getBindingAdapterPosition() - 1));
|
onItemClickListener.onItemClick(postFilterWithUsageList.get(getBindingAdapterPosition() - 1).postFilter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
binding.postFilterUsageRecyclerViewItemPostFilter.setRecycledViewPool(recycledViewPool);
|
||||||
|
binding.postFilterUsageRecyclerViewItemPostFilter.setLayoutManager(new LinearLayoutManagerBugFixed(activity));
|
||||||
|
adapter = new PostFilterUsageEmbeddedRecyclerViewAdapter(activity);
|
||||||
|
binding.postFilterUsageRecyclerViewItemPostFilter.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,4 +112,4 @@ public class PostFilterRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
infoTextView.setCompoundDrawablesWithIntrinsicBounds(Utils.getTintedDrawable(activity, R.drawable.ic_info_preference_24dp, activity.customThemeWrapper.getPrimaryIconColor()), null, null, null);
|
infoTextView.setCompoundDrawablesWithIntrinsicBounds(Utils.getTintedDrawable(activity, R.drawable.ic_info_preference_24dp, activity.customThemeWrapper.getPrimaryIconColor()), null, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -37,6 +37,7 @@ import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
|||||||
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
|
public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecyclerViewAdapter.RuleViewHolder> {
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
private Markwon markwon;
|
private Markwon markwon;
|
||||||
|
private boolean mDisableImagePreview;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final SliderPanel sliderPanel;
|
private final SliderPanel sliderPanel;
|
||||||
private ArrayList<Rule> rules;
|
private ArrayList<Rule> rules;
|
||||||
@ -44,10 +45,11 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
|
|
||||||
public RulesRecyclerViewAdapter(@NonNull BaseActivity activity,
|
public RulesRecyclerViewAdapter(@NonNull BaseActivity activity,
|
||||||
@NonNull CustomThemeWrapper customThemeWrapper,
|
@NonNull CustomThemeWrapper customThemeWrapper,
|
||||||
@Nullable SliderPanel sliderPanel) {
|
@Nullable SliderPanel sliderPanel, boolean disableImagePreview) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.sliderPanel = sliderPanel;
|
this.sliderPanel = sliderPanel;
|
||||||
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
mPrimaryTextColor = customThemeWrapper.getPrimaryTextColor();
|
||||||
|
mDisableImagePreview = disableImagePreview;
|
||||||
int spoilerBackgroundColor = mPrimaryTextColor | 0xFF000000;
|
int spoilerBackgroundColor = mPrimaryTextColor | 0xFF000000;
|
||||||
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
|
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
|
||||||
@Override
|
@Override
|
||||||
@ -82,7 +84,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
|
markwon = MarkdownUtils.createFullRedditMarkwon(activity,
|
||||||
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener);
|
miscPlugin, mPrimaryTextColor, spoilerBackgroundColor, onLinkLongClickListener, mDisableImagePreview);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -2,21 +2,17 @@ package eu.toldi.infinityforlemmy.adapters;
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
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.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemRecentSearchQueryBinding;
|
||||||
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
|
import eu.toldi.infinityforlemmy.recentsearchquery.RecentSearchQuery;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
@ -45,14 +41,14 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return new RecentSearchQueryViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recent_search_query, parent, false));
|
return new RecentSearchQueryViewHolder(ItemRecentSearchQueryBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof RecentSearchQueryViewHolder) {
|
if (holder instanceof RecentSearchQueryViewHolder) {
|
||||||
if (recentSearchQueries != null && !recentSearchQueries.isEmpty() && position < recentSearchQueries.size()) {
|
if (recentSearchQueries != null && !recentSearchQueries.isEmpty() && position < recentSearchQueries.size()) {
|
||||||
((RecentSearchQueryViewHolder) holder).recentSearchQueryTextView.setText(recentSearchQueries.get(position).getSearchQuery());
|
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryTextViewItemRecentSearchQuery.setText(recentSearchQueries.get(position).getSearchQuery());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,22 +64,18 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RecentSearchQueryViewHolder extends RecyclerView.ViewHolder {
|
class RecentSearchQueryViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.recent_search_query_text_view_item_recent_search_query)
|
ItemRecentSearchQueryBinding binding;
|
||||||
TextView recentSearchQueryTextView;
|
|
||||||
@BindView(R.id.delete_image_view_item_recent_search_query)
|
|
||||||
ImageView deleteImageView;
|
|
||||||
|
|
||||||
public RecentSearchQueryViewHolder(@NonNull View itemView) {
|
public RecentSearchQueryViewHolder(@NonNull ItemRecentSearchQueryBinding binding) {
|
||||||
super(itemView);
|
super(binding.getRoot());
|
||||||
|
this.binding = binding;
|
||||||
|
|
||||||
ButterKnife.bind(this, itemView);
|
binding.recentSearchQueryTextViewItemRecentSearchQuery.setTextColor(primaryTextColor);
|
||||||
|
binding.recentSearchQueryTextViewItemRecentSearchQuery.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null);
|
||||||
recentSearchQueryTextView.setTextColor(primaryTextColor);
|
binding.deleteButtonItemRecentSearchQuery.setIcon(deleteIcon);
|
||||||
recentSearchQueryTextView.setCompoundDrawablesWithIntrinsicBounds(historyIcon, null, null, null);
|
|
||||||
deleteImageView.setImageDrawable(deleteIcon);
|
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
recentSearchQueryTextView.setTypeface(activity.typeface);
|
binding.recentSearchQueryTextViewItemRecentSearchQuery.setTypeface(activity.typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.setOnClickListener(view -> {
|
itemView.setOnClickListener(view -> {
|
||||||
@ -92,7 +84,7 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteImageView.setOnClickListener(view -> {
|
binding.deleteButtonItemRecentSearchQuery.setOnClickListener(view -> {
|
||||||
itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition()));
|
itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,14 @@ import butterknife.ButterKnife;
|
|||||||
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.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
|
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
|
||||||
|
|
||||||
public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
private CustomThemeWrapper customThemeWrapper;
|
private CustomThemeWrapper customThemeWrapper;
|
||||||
private ArrayList<String> subreddits;
|
private ArrayList<SubredditWithSelection> subreddits;
|
||||||
|
|
||||||
public SelectedSubredditsRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<String> subreddits) {
|
public SelectedSubredditsRecyclerViewAdapter(BaseActivity activity, CustomThemeWrapper customThemeWrapper, ArrayList<SubredditWithSelection> subreddits) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.customThemeWrapper = customThemeWrapper;
|
this.customThemeWrapper = customThemeWrapper;
|
||||||
if (subreddits == null) {
|
if (subreddits == null) {
|
||||||
@ -42,7 +43,7 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof SubredditViewHolder) {
|
if (holder instanceof SubredditViewHolder) {
|
||||||
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()));
|
((SubredditViewHolder) holder).subredditNameTextView.setText(subreddits.get(holder.getBindingAdapterPosition()).getName());
|
||||||
((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> {
|
((SubredditViewHolder) holder).deleteButton.setOnClickListener(view -> {
|
||||||
subreddits.remove(holder.getBindingAdapterPosition());
|
subreddits.remove(holder.getBindingAdapterPosition());
|
||||||
notifyItemRemoved(holder.getBindingAdapterPosition());
|
notifyItemRemoved(holder.getBindingAdapterPosition());
|
||||||
@ -55,18 +56,18 @@ public class SelectedSubredditsRecyclerViewAdapter extends RecyclerView.Adapter<
|
|||||||
return subreddits.size();
|
return subreddits.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSubreddits(ArrayList<String> newSubreddits) {
|
public void addSubreddits(ArrayList<SubredditWithSelection> newSubreddits) {
|
||||||
int oldSize = subreddits.size();
|
int oldSize = subreddits.size();
|
||||||
subreddits.addAll(newSubreddits);
|
subreddits.addAll(newSubreddits);
|
||||||
notifyItemRangeInserted(oldSize, newSubreddits.size());
|
notifyItemRangeInserted(oldSize, newSubreddits.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUserInSubredditType(String username) {
|
public void addUserInSubredditType(String username) {
|
||||||
subreddits.add(username);
|
/*subreddits.add(username);
|
||||||
notifyItemInserted(subreddits.size());
|
notifyItemInserted(subreddits.size());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getSubreddits() {
|
public ArrayList<SubredditWithSelection> getSubreddits() {
|
||||||
return subreddits;
|
return subreddits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,12 @@ import java.util.List;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|
||||||
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.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
|
import eu.toldi.infinityforlemmy.subreddit.SubredditWithSelection;
|
||||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||||
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
|
||||||
public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
@ -91,11 +91,11 @@ public class SubredditMultiselectionRecyclerViewAdapter extends RecyclerView.Ada
|
|||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getAllSelectedSubreddits() {
|
public ArrayList<SubredditWithSelection> getAllSelectedSubreddits() {
|
||||||
ArrayList<String> selectedSubreddits = new ArrayList<>();
|
ArrayList<SubredditWithSelection> selectedSubreddits = new ArrayList<>();
|
||||||
for (SubredditWithSelection s : subscribedSubreddits) {
|
for (SubredditWithSelection s : subscribedSubreddits) {
|
||||||
if (s.isSelected()) {
|
if (s.isSelected()) {
|
||||||
selectedSubreddits.add(s.getName());
|
selectedSubreddits.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectedSubreddits;
|
return selectedSubreddits;
|
||||||
|
@ -158,7 +158,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
mFavoriteSubscribedSubredditData.size() + 3 : 1;
|
mFavoriteSubscribedSubredditData.size() + 3 : 1;
|
||||||
} else {
|
} else {
|
||||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||||
mFavoriteSubscribedSubredditData.size() + 2 : 1;
|
mFavoriteSubscribedSubredditData.size() + 2 : 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
|
||||||
@ -301,7 +301,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (itemClickListener != null) {
|
if (itemClickListener != null) {
|
||||||
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + 1 : 0;
|
return (hasClearSelectionRow) ? mSubscribedSubredditData.size() + 1 : mSubscribedSubredditData.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mSubscribedSubredditData.size();
|
return mSubscribedSubredditData.size();
|
||||||
|
@ -0,0 +1,102 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.adapters.navigationdrawer;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.R;
|
||||||
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.ItemPostFilterUsageEmbeddedBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
|
||||||
|
|
||||||
|
|
||||||
|
public class PostFilterUsageEmbeddedRecyclerViewAdapter extends RecyclerView.Adapter<PostFilterUsageEmbeddedRecyclerViewAdapter.EntryViewHolder> {
|
||||||
|
|
||||||
|
private BaseActivity baseActivity;
|
||||||
|
private List<PostFilterUsage> postFilterUsageList;
|
||||||
|
|
||||||
|
public PostFilterUsageEmbeddedRecyclerViewAdapter(BaseActivity baseActivity) {
|
||||||
|
this.baseActivity = baseActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public EntryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
return new EntryViewHolder(ItemPostFilterUsageEmbeddedBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull EntryViewHolder holder, int position) {
|
||||||
|
if (postFilterUsageList == null || postFilterUsageList.isEmpty()) {
|
||||||
|
holder.textView.setText(R.string.click_to_apply_post_filter);
|
||||||
|
} else if (holder.getBindingAdapterPosition() > 4) {
|
||||||
|
holder.textView.setText(baseActivity.getString(R.string.post_filter_usage_embedded_more_count, postFilterUsageList.size() - 5));
|
||||||
|
} else {
|
||||||
|
PostFilterUsage postFilterUsage = postFilterUsageList.get(holder.getBindingAdapterPosition());
|
||||||
|
switch (postFilterUsage.usage) {
|
||||||
|
case PostFilterUsage.HOME_TYPE:
|
||||||
|
holder.textView.setText(R.string.post_filter_usage_home);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.SUBREDDIT_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
holder.textView.setText(R.string.post_filter_usage_embedded_subreddit_all);
|
||||||
|
} else {
|
||||||
|
holder.textView.setText("r/" + postFilterUsage.nameOfUsage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.USER_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
holder.textView.setText(R.string.post_filter_usage_embedded_user_all);
|
||||||
|
} else {
|
||||||
|
holder.textView.setText("u/" + postFilterUsage.nameOfUsage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.SEARCH_TYPE:
|
||||||
|
holder.textView.setText(R.string.post_filter_usage_search);
|
||||||
|
break;
|
||||||
|
case PostFilterUsage.MULTIREDDIT_TYPE:
|
||||||
|
if (postFilterUsage.nameOfUsage.equals(PostFilterUsage.NO_USAGE)) {
|
||||||
|
holder.textView.setText(R.string.post_filter_usage_embedded_multireddit_all);
|
||||||
|
} else {
|
||||||
|
holder.textView.setText(postFilterUsage.nameOfUsage);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return postFilterUsageList == null || postFilterUsageList.isEmpty() ? 1 : (postFilterUsageList.size() > 5 ? 6 : postFilterUsageList.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPostFilterUsageList(List<PostFilterUsage> postFilterUsageList) {
|
||||||
|
this.postFilterUsageList = postFilterUsageList;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
class EntryViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
TextView textView;
|
||||||
|
|
||||||
|
public EntryViewHolder(@NonNull ItemPostFilterUsageEmbeddedBinding binding) {
|
||||||
|
super(binding.getRoot());
|
||||||
|
textView = binding.getRoot();
|
||||||
|
|
||||||
|
textView.setTextColor(baseActivity.customThemeWrapper.getSecondaryTextColor());
|
||||||
|
|
||||||
|
if (baseActivity.typeface != null) {
|
||||||
|
textView.setTypeface(baseActivity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
textView.setOnClickListener(view -> {
|
||||||
|
Toast.makeText(baseActivity, textView.getText(), Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -101,7 +101,16 @@ public interface LemmyAPI {
|
|||||||
Call<String> postDelete(@Body DeletePostDTO params);
|
Call<String> postDelete(@Body DeletePostDTO params);
|
||||||
|
|
||||||
@GET("api/v3/user")
|
@GET("api/v3/user")
|
||||||
ListenableFuture<Response<String>> getUserPosts(
|
ListenableFuture<Response<String>> getUserPostsListenableFuture(
|
||||||
|
@Query("username") String username,
|
||||||
|
@Query("sort") String sort,
|
||||||
|
@Query("page") Integer page,
|
||||||
|
@Query("limit") Integer limit,
|
||||||
|
@Query("saved_only") Boolean saved_only,
|
||||||
|
@Query("auth") String access_token);
|
||||||
|
|
||||||
|
@GET("api/v3/user")
|
||||||
|
Call<String> getUserPosts(
|
||||||
@Query("username") String username,
|
@Query("username") String username,
|
||||||
@Query("sort") String sort,
|
@Query("sort") String sort,
|
||||||
@Query("page") Integer page,
|
@Query("page") Integer page,
|
||||||
@ -129,7 +138,19 @@ public interface LemmyAPI {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@GET("api/v3/post/list")
|
@GET("api/v3/post/list")
|
||||||
ListenableFuture<Response<String>> getPosts(
|
ListenableFuture<Response<String>> getPostsListenableFuture(
|
||||||
|
@Query("type_") String type_,
|
||||||
|
@Query("sort") String sort,
|
||||||
|
@Query("page") Integer page,
|
||||||
|
@Query("limit") Integer limit,
|
||||||
|
@Query("community_id") Integer community_id,
|
||||||
|
@Query("community_name") String community_name,
|
||||||
|
@Query("saved_only") Boolean saved_only,
|
||||||
|
@Query("auth") String auth
|
||||||
|
);
|
||||||
|
|
||||||
|
@GET("api/v3/post/list")
|
||||||
|
Call<String> getPosts(
|
||||||
@Query("type_") String type_,
|
@Query("type_") String type_,
|
||||||
@Query("sort") String sort,
|
@Query("sort") String sort,
|
||||||
@Query("page") Integer page,
|
@Query("page") Integer page,
|
||||||
|
@ -54,19 +54,19 @@ public interface RedditAPI {
|
|||||||
@GET("user/{username}/about.json?raw_json=1")
|
@GET("user/{username}/about.json?raw_json=1")
|
||||||
Call<String> getUserData(@Path("username") String username);
|
Call<String> getUserData(@Path("username") String username);
|
||||||
|
|
||||||
@GET("user/{username}/about.json?raw_json=1")
|
@GET("user/{username}/about.json?raw_json=1&limit=100")
|
||||||
Call<String> getUserDataOauth(@HeaderMap Map<String, String> headers, @Path("username") String username);
|
Call<String> getUserDataOauth(@HeaderMap Map<String, String> headers, @Path("username") String username);
|
||||||
|
|
||||||
@GET("user/{username}/comments.json?raw_json=1")
|
@GET("user/{username}/comments.json?raw_json=1&limit=100")
|
||||||
Call<String> getUserComments(@Path("username") String username, @Query("after") String after,
|
Call<String> getUserComments(@Path("username") String username, @Query("after") String after,
|
||||||
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("user/{username}/comments.json?raw_json=1")
|
@GET("user/{username}/comments.json?raw_json=1&limit=100")
|
||||||
Call<String> getUserCommentsOauth(@HeaderMap Map<String, String> headers, @Path("username") String username,
|
Call<String> getUserCommentsOauth(@HeaderMap Map<String, String> headers, @Path("username") String username,
|
||||||
@Query("after") String after, @Query("sort") SortType.Type sortType,
|
@Query("after") String after, @Query("sort") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime);
|
@Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("user/{username}/{where}.json?&type=comments&raw_json=1&limit=25")
|
@GET("user/{username}/{where}.json?&type=comments&raw_json=1&limit=100")
|
||||||
Call<String> getUserSavedCommentsOauth(@Path("username") String username, @Path("where") String where,
|
Call<String> getUserSavedCommentsOauth(@Path("username") String username, @Path("where") String where,
|
||||||
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
||||||
@ -273,108 +273,108 @@ public interface RedditAPI {
|
|||||||
@GET("/r/{subredditName}/wiki/{wikiPage}.json?raw_json=1")
|
@GET("/r/{subredditName}/wiki/{wikiPage}.json?raw_json=1")
|
||||||
Call<String> getWikiPage(@Path("subredditName") String subredditName, @Path("wikiPage") String wikiPage);
|
Call<String> getWikiPage(@Path("subredditName") String subredditName, @Path("wikiPage") String wikiPage);
|
||||||
|
|
||||||
@GET("{sortType}?raw_json=1")
|
@GET("{sortType}?raw_json=1&limit=100")
|
||||||
ListenableFuture<Response<String>> getBestPostsListenableFuture(@Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime,
|
ListenableFuture<Response<String>> getBestPostsListenableFuture(@Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime,
|
||||||
@Query("after") String lastItem, @HeaderMap Map<String, String> headers);
|
@Query("after") String lastItem, @HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25&always_show_media=1")
|
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=100&always_show_media=1")
|
||||||
ListenableFuture<Response<String>> getSubredditBestPostsOauthListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
ListenableFuture<Response<String>> getSubredditBestPostsOauthListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String lastItem,
|
@Query("t") SortType.Time sortTime, @Query("after") String lastItem,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25&always_show_media=1")
|
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=100&always_show_media=1")
|
||||||
ListenableFuture<Response<String>> getSubredditBestPostsListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
ListenableFuture<Response<String>> getSubredditBestPostsListenableFuture(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String lastItem);
|
@Query("t") SortType.Time sortTime, @Query("after") String lastItem);
|
||||||
|
|
||||||
@GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=25")
|
@GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=100")
|
||||||
ListenableFuture<Response<String>> getUserPostsOauthListenableFuture(@Path("username") String username, @Path("where") String where,
|
ListenableFuture<Response<String>> getUserPostsOauthListenableFuture(@Path("username") String username, @Path("where") String where,
|
||||||
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("user/{username}/submitted.json?raw_json=1&limit=25")
|
@GET("user/{username}/submitted.json?raw_json=1&limit=100")
|
||||||
ListenableFuture<Response<String>> getUserPostsListenableFuture(@Path("username") String username, @Query("after") String lastItem,
|
ListenableFuture<Response<String>> getUserPostsListenableFuture(@Path("username") String username, @Query("after") String lastItem,
|
||||||
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("search.json?include_over_18=1&raw_json=1&type=link")
|
@GET("search.json?include_over_18=1&raw_json=1&limit=100&type=link")
|
||||||
ListenableFuture<Response<String>> searchPostsOauthListenableFuture(@Query("q") String query, @Query("after") String after,
|
ListenableFuture<Response<String>> searchPostsOauthListenableFuture(@Query("q") String query, @Query("after") String after,
|
||||||
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
||||||
@Query("source") String source,
|
@Query("source") String source,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("search.json?include_over_18=1&raw_json=1&type=link")
|
@GET("search.json?include_over_18=1&raw_json=1&limit=100&type=link")
|
||||||
ListenableFuture<Response<String>> searchPostsListenableFuture(@Query("q") String query, @Query("after") String after,
|
ListenableFuture<Response<String>> searchPostsListenableFuture(@Query("q") String query, @Query("after") String after,
|
||||||
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
||||||
@Query("source") String source);
|
@Query("source") String source);
|
||||||
|
|
||||||
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&type=link&restrict_sr=true")
|
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&limit=100&type=link&restrict_sr=true")
|
||||||
ListenableFuture<Response<String>> searchPostsInSpecificSubredditOauthListenableFuture(@Path("subredditName") String subredditName,
|
ListenableFuture<Response<String>> searchPostsInSpecificSubredditOauthListenableFuture(@Path("subredditName") String subredditName,
|
||||||
@Query("q") String query, @Query("sort") SortType.Type sort,
|
@Query("q") String query, @Query("sort") SortType.Type sort,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String after,
|
@Query("t") SortType.Time sortTime, @Query("after") String after,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&type=link&restrict_sr=true")
|
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&limit=100&type=link&restrict_sr=true")
|
||||||
ListenableFuture<Response<String>> searchPostsInSpecificSubredditListenableFuture(@Path("subredditName") String subredditName,
|
ListenableFuture<Response<String>> searchPostsInSpecificSubredditListenableFuture(@Path("subredditName") String subredditName,
|
||||||
@Query("q") String query, @Query("sort") SortType.Type sort,
|
@Query("q") String query, @Query("sort") SortType.Type sort,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String after);
|
@Query("t") SortType.Time sortTime, @Query("after") String after);
|
||||||
|
|
||||||
@GET("{multipath}?raw_json=1")
|
@GET("{multipath}?raw_json=1&limit=100")
|
||||||
ListenableFuture<Response<String>> getMultiRedditPostsListenableFuture(@Path(value = "multipath", encoded = true) String multiPath,
|
ListenableFuture<Response<String>> getMultiRedditPostsListenableFuture(@Path(value = "multipath", encoded = true) String multiPath,
|
||||||
@Query("after") String after, @Query("t") SortType.Time sortTime);
|
@Query("after") String after, @Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("{multipath}.json?raw_json=1")
|
@GET("{multipath}.json?raw_json=1&limit=100")
|
||||||
ListenableFuture<Response<String>> getMultiRedditPostsOauthListenableFuture(@Path(value = "multipath", encoded = true) String multiPath,
|
ListenableFuture<Response<String>> getMultiRedditPostsOauthListenableFuture(@Path(value = "multipath", encoded = true) String multiPath,
|
||||||
@Query("after") String after, @Query("t") SortType.Time sortTime,
|
@Query("after") String after, @Query("t") SortType.Time sortTime,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("{sortType}?raw_json=1")
|
@GET("{sortType}?raw_json=1&limit=100")
|
||||||
Call<String> getBestPosts(@Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime,
|
Call<String> getBestPosts(@Path("sortType") SortType.Type sortType, @Query("t") SortType.Time sortTime,
|
||||||
@Query("after") String lastItem, @HeaderMap Map<String, String> headers);
|
@Query("after") String lastItem, @HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25&always_show_media=1")
|
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=100&always_show_media=1")
|
||||||
Call<String> getSubredditBestPostsOauth(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
Call<String> getSubredditBestPostsOauth(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String lastItem,
|
@Query("t") SortType.Time sortTime, @Query("after") String lastItem,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=25&always_show_media=1")
|
@GET("r/{subredditName}/{sortType}.json?raw_json=1&limit=100&always_show_media=1")
|
||||||
Call<String> getSubredditBestPosts(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
Call<String> getSubredditBestPosts(@Path("subredditName") String subredditName, @Path("sortType") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String lastItem);
|
@Query("t") SortType.Time sortTime, @Query("after") String lastItem);
|
||||||
|
|
||||||
@GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=25")
|
@GET("user/{username}/{where}.json?&type=links&raw_json=1&limit=100")
|
||||||
Call<String> getUserPostsOauth(@Path("username") String username, @Path("where") String where,
|
Call<String> getUserPostsOauth(@Path("username") String username, @Path("where") String where,
|
||||||
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
@Query("after") String lastItem, @Query("sort") SortType.Type sortType,
|
||||||
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
@Query("t") SortType.Time sortTime, @HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("user/{username}/submitted.json?raw_json=1&limit=25")
|
@GET("user/{username}/submitted.json?raw_json=1&limit=100")
|
||||||
Call<String> getUserPosts(@Path("username") String username, @Query("after") String lastItem,
|
Call<String> getUserPosts(@Path("username") String username, @Query("after") String lastItem,
|
||||||
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
@Query("sort") SortType.Type sortType, @Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("search.json?include_over_18=1&raw_json=1&type=link")
|
@GET("search.json?include_over_18=1&raw_json=1&limit=100&type=link")
|
||||||
Call<String> searchPostsOauth(@Query("q") String query, @Query("after") String after,
|
Call<String> searchPostsOauth(@Query("q") String query, @Query("after") String after,
|
||||||
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
||||||
@Query("source") String source,
|
@Query("source") String source,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("search.json?include_over_18=1&raw_json=1&type=link")
|
@GET("search.json?include_over_18=1&raw_json=1&limit=100&type=link")
|
||||||
Call<String> searchPosts(@Query("q") String query, @Query("after") String after,
|
Call<String> searchPosts(@Query("q") String query, @Query("after") String after,
|
||||||
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
@Query("sort") SortType.Type sort, @Query("t") SortType.Time sortTime,
|
||||||
@Query("source") String source);
|
@Query("source") String source);
|
||||||
|
|
||||||
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&type=link&restrict_sr=true")
|
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&limit=100&type=link&restrict_sr=true")
|
||||||
Call<String> searchPostsInSpecificSubredditOauth(@Path("subredditName") String subredditName,
|
Call<String> searchPostsInSpecificSubredditOauth(@Path("subredditName") String subredditName,
|
||||||
@Query("q") String query, @Query("sort") SortType.Type sort,
|
@Query("q") String query, @Query("sort") SortType.Type sort,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String after,
|
@Query("t") SortType.Time sortTime, @Query("after") String after,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
|
||||||
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&type=link&restrict_sr=true")
|
@GET("r/{subredditName}/search.json?include_over_18=1&raw_json=1&limit=100&type=link&restrict_sr=true")
|
||||||
Call<String> searchPostsInSpecificSubreddit(@Path("subredditName") String subredditName,
|
Call<String> searchPostsInSpecificSubreddit(@Path("subredditName") String subredditName,
|
||||||
@Query("q") String query, @Query("sort") SortType.Type sort,
|
@Query("q") String query, @Query("sort") SortType.Type sort,
|
||||||
@Query("t") SortType.Time sortTime, @Query("after") String after);
|
@Query("t") SortType.Time sortTime, @Query("after") String after);
|
||||||
|
|
||||||
@GET("{multipath}?raw_json=1")
|
@GET("{multipath}?raw_json=1&limit=100")
|
||||||
Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath,
|
Call<String> getMultiRedditPosts(@Path(value = "multipath", encoded = true) String multiPath,
|
||||||
@Query("after") String after, @Query("t") SortType.Time sortTime);
|
@Query("after") String after, @Query("t") SortType.Time sortTime);
|
||||||
|
|
||||||
@GET("{multipath}.json?raw_json=1")
|
@GET("{multipath}.json?raw_json=1&limit=100")
|
||||||
Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath,
|
Call<String> getMultiRedditPostsOauth(@Path(value = "multipath", encoded = true) String multiPath,
|
||||||
@Query("after") String after, @Query("t") SortType.Time sortTime,
|
@Query("after") String after, @Query("t") SortType.Time sortTime,
|
||||||
@HeaderMap Map<String, String> headers);
|
@HeaderMap Map<String, String> headers);
|
||||||
|
@ -6,14 +6,16 @@ import retrofit2.Call;
|
|||||||
import retrofit2.http.FieldMap;
|
import retrofit2.http.FieldMap;
|
||||||
import retrofit2.http.FormUrlEncoded;
|
import retrofit2.http.FormUrlEncoded;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.HeaderMap;
|
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
import retrofit2.http.Query;
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
public interface RedgifsAPI {
|
public interface RedgifsAPI {
|
||||||
@GET("/v2/gifs/{id}")
|
@GET("/v2/gifs/{id}")
|
||||||
Call<String> getRedgifsData(@HeaderMap Map<String, String> headers, @Path("id") String id, @Query("user-agent") String userAgent);
|
Call<String> getRedgifsData(@Path("id") String id);
|
||||||
|
|
||||||
|
@GET("/v2/gifs")
|
||||||
|
Call<String> getRedgifsMultipleData(@Query("ids") String ids);
|
||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST("/v2/oauth/client")
|
@POST("/v2/oauth/client")
|
||||||
|
@ -13,11 +13,7 @@ public class DeleteMultiredditInDatabase {
|
|||||||
String accountName, String multipath,
|
String accountName, String multipath,
|
||||||
DeleteMultiredditInDatabaseListener deleteMultiredditInDatabaseListener) {
|
DeleteMultiredditInDatabaseListener deleteMultiredditInDatabaseListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
if (accountName.equals("-")) {
|
redditDataRoomDatabase.multiRedditDao().anonymousDeleteMultiReddit(multipath);
|
||||||
redditDataRoomDatabase.multiRedditDao().anonymousDeleteMultiReddit(multipath);
|
|
||||||
} else {
|
|
||||||
redditDataRoomDatabase.multiRedditDao().deleteMultiReddit(multipath, accountName);
|
|
||||||
}
|
|
||||||
handler.post(deleteMultiredditInDatabaseListener::success);
|
handler.post(deleteMultiredditInDatabaseListener::success);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public class InsertSubscribedThings {
|
|||||||
|
|
||||||
for (SubscribedSubredditData s : subscribedSubredditDataList) {
|
for (SubscribedSubredditData s : subscribedSubredditDataList) {
|
||||||
if (existingSubscribedSubredditDataList.contains(s)) {
|
if (existingSubscribedSubredditDataList.contains(s)) {
|
||||||
|
subscribedSubredditDao.updateSubscribedSubreddit(s.getQualified_name(), s.getName(), s.getIconUrl(), accountName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
subscribedSubredditDao.insert(s);
|
subscribedSubredditDao.insert(s);
|
||||||
|
@ -2,6 +2,7 @@ package eu.toldi.infinityforlemmy.asynctasks;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@ -25,18 +26,31 @@ public class SwitchAccount {
|
|||||||
.putString(SharedPreferencesUtils.ACCESS_TOKEN, account.getAccessToken())
|
.putString(SharedPreferencesUtils.ACCESS_TOKEN, account.getAccessToken())
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_NAME, account.getDisplay_name())
|
.putString(SharedPreferencesUtils.ACCOUNT_NAME, account.getDisplay_name())
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, account.getAccountName())
|
.putString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, account.getAccountName())
|
||||||
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE,account.getInstance_url())
|
.putString(SharedPreferencesUtils.ACCOUNT_INSTANCE, account.getInstance_url())
|
||||||
|
.putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, false)
|
||||||
.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());
|
||||||
|
retrofitHolder.setAccessToken(null);
|
||||||
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
|
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
|
||||||
boolean canDownvote = siteInfo.isEnable_downvotes();
|
boolean canDownvote = siteInfo.isEnable_downvotes();
|
||||||
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
|
||||||
|
String[] version = siteInfo.getVersion().split("\\.");
|
||||||
|
if (version.length > 0) {
|
||||||
|
Log.d("SwitchAccount", "Lemmy Version: " + version[0] + "." + version[1]);
|
||||||
|
int majorVersion = Integer.parseInt(version[0]);
|
||||||
|
int minorVersion = Integer.parseInt(version[1]);
|
||||||
|
if (majorVersion > 0 || (majorVersion == 0 && minorVersion >= 19)) {
|
||||||
|
retrofitHolder.setAccessToken(account.getAccessToken());
|
||||||
|
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true).apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchSiteInfoFailed() {
|
public void onFetchSiteInfoFailed() {
|
||||||
|
Log.e("SwitchAccount", "Failed to fetch site info");
|
||||||
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.bottomsheetfragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CommentFilterPreferenceActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.FragmentCommentFilterOptionsBottomSheetBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_POST_FILTER = "EPF";
|
||||||
|
private CommentFilterPreferenceActivity activity;
|
||||||
|
|
||||||
|
public CommentFilterOptionsBottomSheetFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
FragmentCommentFilterOptionsBottomSheetBinding binding = FragmentCommentFilterOptionsBottomSheetBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
|
CommentFilter commentFilter = getArguments().getParcelable(EXTRA_POST_FILTER);
|
||||||
|
|
||||||
|
binding.editTextViewCommentFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.editCommentFilter(commentFilter);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.applyToTextViewCommentFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.applyCommentFilterTo(commentFilter);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.deleteTextViewCommentFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.deleteCommentFilter(commentFilter);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (activity.typeface != null) {
|
||||||
|
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (CommentFilterPreferenceActivity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.bottomsheetfragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CommentFilterUsageListingActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.FragmentCommentFilterUsageOptionsBottomSheetBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
|
public class CommentFilterUsageOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_COMMENT_FILTER_USAGE = "ECFU";
|
||||||
|
|
||||||
|
private CommentFilterUsageListingActivity activity;
|
||||||
|
|
||||||
|
public CommentFilterUsageOptionsBottomSheetFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
FragmentCommentFilterUsageOptionsBottomSheetBinding binding = FragmentCommentFilterUsageOptionsBottomSheetBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
|
CommentFilterUsage commentFilterUsage = getArguments().getParcelable(EXTRA_COMMENT_FILTER_USAGE);
|
||||||
|
|
||||||
|
binding.editTextViewCommentFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.editCommentFilterUsage(commentFilterUsage);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
binding.deleteTextViewCommentFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.deleteCommentFilterUsage(commentFilterUsage);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (activity.typeface != null) {
|
||||||
|
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (CommentFilterUsageListingActivity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.bottomsheetfragments;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.activities.CommentFilterUsageListingActivity;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilterUsage;
|
||||||
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.FragmentNewCommentFilterUsageBottomSheetBinding;
|
||||||
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
|
public class NewCommentFilterUsageBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
private CommentFilterUsageListingActivity activity;
|
||||||
|
|
||||||
|
public NewCommentFilterUsageBottomSheetFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
FragmentNewCommentFilterUsageBottomSheetBinding binding = FragmentNewCommentFilterUsageBottomSheetBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
|
binding.subredditTextViewNewCommentFilterUsageBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
activity.newCommentFilterUsage(CommentFilterUsage.SUBREDDIT_TYPE);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (activity.typeface != null) {
|
||||||
|
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding.getRoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (CommentFilterUsageListingActivity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -5,26 +5,17 @@ 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.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.PostFilterPreferenceActivity;
|
import eu.toldi.infinityforlemmy.activities.PostFilterPreferenceActivity;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.FragmentPostFilterOptionsBottomSheetBinding;
|
||||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
@BindView(R.id.edit_text_view_post_filter_options_bottom_sheet_fragment)
|
|
||||||
TextView editTextView;
|
|
||||||
@BindView(R.id.apply_to_text_view_post_filter_options_bottom_sheet_fragment)
|
|
||||||
TextView applyToTextView;
|
|
||||||
@BindView(R.id.delete_text_view_post_filter_options_bottom_sheet_fragment)
|
|
||||||
TextView deleteTextView;
|
|
||||||
public static final String EXTRA_POST_FILTER = "EPF";
|
public static final String EXTRA_POST_FILTER = "EPF";
|
||||||
private PostFilterPreferenceActivity activity;
|
private PostFilterPreferenceActivity activity;
|
||||||
|
|
||||||
@ -36,32 +27,30 @@ public class PostFilterOptionsBottomSheetFragment extends LandscapeExpandedRound
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View rootView = inflater.inflate(R.layout.fragment_post_filter_options_bottom_sheet, container, false);
|
FragmentPostFilterOptionsBottomSheetBinding binding = FragmentPostFilterOptionsBottomSheetBinding.inflate(inflater, container, false);
|
||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
|
||||||
|
|
||||||
PostFilter postFilter = getArguments().getParcelable(EXTRA_POST_FILTER);
|
PostFilter postFilter = getArguments().getParcelable(EXTRA_POST_FILTER);
|
||||||
|
|
||||||
editTextView.setOnClickListener(view -> {
|
binding.editTextViewPostFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
activity.editPostFilter(postFilter);
|
activity.editPostFilter(postFilter);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
applyToTextView.setOnClickListener(view -> {
|
binding.applyToTextViewPostFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
activity.applyPostFilterTo(postFilter);
|
activity.applyPostFilterTo(postFilter);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
deleteTextView.setOnClickListener(view -> {
|
binding.deleteTextViewPostFilterOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||||
activity.deletePostFilter(postFilter);
|
activity.deletePostFilter(postFilter);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rootView;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,16 +6,13 @@ 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.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
||||||
|
import eu.toldi.infinityforlemmy.databinding.FragmentPostLayoutBottomSheetBinding;
|
||||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||||
|
|
||||||
@ -24,14 +21,7 @@ import eu.toldi.infinityforlemmy.utils.Utils;
|
|||||||
*/
|
*/
|
||||||
public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
@BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment)
|
private FragmentPostLayoutBottomSheetBinding binding;
|
||||||
TextView cardLayoutTextView;
|
|
||||||
@BindView(R.id.card_layout_2_text_view_post_layout_bottom_sheet_fragment)
|
|
||||||
TextView cardLayout2TextView;
|
|
||||||
@BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment)
|
|
||||||
TextView compactLayoutTextView;
|
|
||||||
@BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment)
|
|
||||||
TextView galleryLayoutTextView;
|
|
||||||
private BaseActivity activity;
|
private BaseActivity activity;
|
||||||
public PostLayoutBottomSheetFragment() {
|
public PostLayoutBottomSheetFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -39,33 +29,36 @@ public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBotto
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View rootView = inflater.inflate(R.layout.fragment_post_layot_bottom_sheet, container, false);
|
binding = FragmentPostLayoutBottomSheetBinding.inflate(inflater, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
|
||||||
|
|
||||||
cardLayoutTextView.setOnClickListener(view -> {
|
binding.cardLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> {
|
||||||
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD);
|
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
compactLayoutTextView.setOnClickListener(view -> {
|
binding.compactLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> {
|
||||||
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_COMPACT);
|
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_COMPACT);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
galleryLayoutTextView.setOnClickListener(view -> {
|
binding.galleryLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> {
|
||||||
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_GALLERY);
|
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_GALLERY);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
cardLayout2TextView.setOnClickListener(view -> {
|
binding.cardLayout2TextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> {
|
||||||
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_2);
|
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_2);
|
||||||
dismiss();
|
dismiss();
|
||||||
});
|
});
|
||||||
|
binding.cardLayout3TextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> {
|
||||||
|
((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_3);
|
||||||
|
dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
if (activity.typeface != null) {
|
if (activity.typeface != null) {
|
||||||
Utils.setFontToAllTextViews(rootView, activity.typeface);
|
Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface);
|
||||||
}
|
}
|
||||||
return rootView;
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
package eu.toldi.infinityforlemmy.bottomsheetfragments;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.SpannableString;
|
|
||||||
import android.text.util.Linkify;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
|
||||||
import eu.toldi.infinityforlemmy.R;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
|
||||||
import eu.toldi.infinityforlemmy.activities.MainActivity;
|
|
||||||
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
|
|
||||||
import eu.toldi.infinityforlemmy.databinding.FragmentRedditApiInfoBottomSheetBinding;
|
|
||||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
|
||||||
|
|
||||||
public class RedditAPIInfoBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
|
|
||||||
|
|
||||||
private MainActivity mainActivity;
|
|
||||||
|
|
||||||
public RedditAPIInfoBottomSheetFragment() {
|
|
||||||
// Required empty public constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
FragmentRedditApiInfoBottomSheetBinding binding = FragmentRedditApiInfoBottomSheetBinding.inflate(inflater, container, false);
|
|
||||||
|
|
||||||
if (mainActivity != null && mainActivity.typeface != null) {
|
|
||||||
Utils.setFontToAllTextViews(binding.getRoot(), mainActivity.typeface);
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.getRoot().setNestedScrollingEnabled(true);
|
|
||||||
|
|
||||||
SpannableString message = new SpannableString(getString(R.string.reddit_api_info, "https://www.reddit.com/r/reddit/comments/145bram/addressing_the_community_about_changes_to_our_api", "https://www.reddit.com/r/Infinity_For_Reddit/comments/147bhsg/the_future_of_infinity"));
|
|
||||||
Linkify.addLinks(message, Linkify.WEB_URLS);
|
|
||||||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setText(message);
|
|
||||||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkClickListener((textView, url) -> {
|
|
||||||
Intent intent = new Intent(mainActivity, LinkResolverActivity.class);
|
|
||||||
intent.setData(Uri.parse(url));
|
|
||||||
startActivity(intent);
|
|
||||||
return true;
|
|
||||||
}));
|
|
||||||
binding.messageTextViewRedditApiInfoBottomSheetFragment.setLinkTextColor(getResources().getColor(R.color.colorAccent));
|
|
||||||
|
|
||||||
binding.doNotShowThisAgainTextView.setOnClickListener(view -> {
|
|
||||||
binding.doNotShowThisAgainCheckBox.toggle();
|
|
||||||
});
|
|
||||||
|
|
||||||
binding.continueButtonRedditApiInfoBottomSheetFragment.setOnClickListener(view -> {
|
|
||||||
if (binding.doNotShowThisAgainCheckBox.isChecked()) {
|
|
||||||
mainActivity.doNotShowRedditAPIInfoAgain();
|
|
||||||
}
|
|
||||||
dismiss();
|
|
||||||
});
|
|
||||||
|
|
||||||
return binding.getRoot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(@NonNull Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
mainActivity = (MainActivity) context;
|
|
||||||
}
|
|
||||||
}
|
|
@ -35,13 +35,14 @@ public class CommentViewModel extends ViewModel {
|
|||||||
hasCommentLiveData = Transformations.switchMap(commentDataSourceFactory.getCommentDataSourceLiveData(),
|
hasCommentLiveData = Transformations.switchMap(commentDataSourceFactory.getCommentDataSourceLiveData(),
|
||||||
CommentDataSource::hasPostLiveData);
|
CommentDataSource::hasPostLiveData);
|
||||||
|
|
||||||
sortTypeLiveData = new MutableLiveData<>();
|
sortTypeLiveData = new MutableLiveData<>(sortType);
|
||||||
sortTypeLiveData.postValue(sortType);
|
|
||||||
|
|
||||||
PagedList.Config pagedListConfig =
|
PagedList.Config pagedListConfig =
|
||||||
(new PagedList.Config.Builder())
|
(new PagedList.Config.Builder())
|
||||||
.setEnablePlaceholders(false)
|
.setEnablePlaceholders(false)
|
||||||
.setPageSize(25)
|
.setPageSize(100)
|
||||||
|
.setPrefetchDistance(10)
|
||||||
|
.setInitialLoadSizeHint(10)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
comments = Transformations.switchMap(sortTypeLiveData, sort -> {
|
comments = Transformations.switchMap(sortTypeLiveData, sort -> {
|
||||||
|
@ -13,6 +13,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import eu.toldi.infinityforlemmy.SortType;
|
import eu.toldi.infinityforlemmy.SortType;
|
||||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -22,19 +23,20 @@ public class FetchComment {
|
|||||||
public static void fetchComments(Executor executor, Handler handler, Retrofit retrofit,
|
public static void fetchComments(Executor executor, Handler handler, Retrofit retrofit,
|
||||||
@Nullable String accessToken, Integer article,
|
@Nullable String accessToken, Integer article,
|
||||||
Integer commentId, SortType.Type sortType, boolean expandChildren,
|
Integer commentId, SortType.Type sortType, boolean expandChildren,
|
||||||
Integer page, FetchCommentListener fetchCommentListener) {
|
Integer page, CommentFilter commentFilter, FetchCommentListener fetchCommentListener) {
|
||||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||||
Call<String> comments;
|
Call<String> comments;
|
||||||
|
|
||||||
comments = api.getComments("All", sortType.value, 8, page, 25, null, null, article, commentId, false, accessToken);
|
comments = api.getComments("All", sortType.value, 8, page, 25, null, null, article, commentId, false, accessToken);
|
||||||
|
|
||||||
|
|
||||||
comments.enqueue(new Callback<String>() {
|
comments.enqueue(new Callback<>() {
|
||||||
@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()) {
|
||||||
ParseComment.parseComments(executor, handler, response.body(), commentId,
|
ParseComment.parseComments(executor, handler, response.body(), commentId,
|
||||||
expandChildren, new ParseComment.ParseCommentListener() {
|
expandChildren, commentFilter,
|
||||||
|
new ParseComment.ParseCommentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments,
|
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments,
|
||||||
ArrayList<Comment> expandedComments,
|
ArrayList<Comment> expandedComments,
|
||||||
@ -70,7 +72,7 @@ public class FetchComment {
|
|||||||
moreComments = api.getComments("All", sortType.value, 8, page, 25, null, null, article, commentId, false, accessToken);
|
moreComments = api.getComments("All", sortType.value, 8, page, 25, null, null, article, commentId, false, accessToken);
|
||||||
|
|
||||||
|
|
||||||
moreComments.enqueue(new Callback<String>() {
|
moreComments.enqueue(new Callback<>() {
|
||||||
@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()) {
|
||||||
|
@ -24,14 +24,14 @@ import java.util.TimeZone;
|
|||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.commentfilter.CommentFilter;
|
||||||
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
|
||||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||||
|
|
||||||
|
|
||||||
public class ParseComment {
|
public class ParseComment {
|
||||||
public static void parseComments(Executor executor, Handler handler, String response, Integer commentId,
|
public static void parseComments(Executor executor, Handler handler, String response, Integer commentId,
|
||||||
boolean expandChildren,
|
boolean expandChildren, CommentFilter commentFilter,
|
||||||
ParseCommentListener parseCommentListener) {
|
ParseCommentListener parseCommentListener) {
|
||||||
executor.execute(() -> {
|
executor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
@ -50,6 +50,9 @@ public class ParseComment {
|
|||||||
orderedComments.add(singleComment);
|
orderedComments.add(singleComment);
|
||||||
parsedComments.put(singleComment.getId(), singleComment);
|
parsedComments.put(singleComment.getId(), singleComment);
|
||||||
if (singleComment.getDepth() == 0) {
|
if (singleComment.getDepth() == 0) {
|
||||||
|
if (!CommentFilter.isCommentAllowed(singleComment, commentFilter)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
topLevelComments.add(singleComment);
|
topLevelComments.add(singleComment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +61,9 @@ public class ParseComment {
|
|||||||
if (parentComment.getDepth() == 0) {
|
if (parentComment.getDepth() == 0) {
|
||||||
parentComment = null;
|
parentComment = null;
|
||||||
} else {
|
} else {
|
||||||
expandedNewComments.add(parentComment);
|
if (CommentFilter.isCommentAllowed(parentComment, commentFilter)) {
|
||||||
|
expandedNewComments.add(parentComment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +73,9 @@ public class ParseComment {
|
|||||||
if (c.getParentId() != null) {
|
if (c.getParentId() != null) {
|
||||||
Comment parent = parsedComments.get(c.getParentId());
|
Comment parent = parsedComments.get(c.getParentId());
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
if (!CommentFilter.isCommentAllowed(c, commentFilter)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
parent.addChild(c);
|
parent.addChild(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,8 +89,13 @@ public class ParseComment {
|
|||||||
if (topLevelComments.isEmpty() && !parsedComments.isEmpty() && parentComment != null) {
|
if (topLevelComments.isEmpty() && !parsedComments.isEmpty() && parentComment != null) {
|
||||||
for (int i = 0; i < orderedComments.size(); i++) {
|
for (int i = 0; i < orderedComments.size(); i++) {
|
||||||
Comment c = orderedComments.get(i);
|
Comment c = orderedComments.get(i);
|
||||||
if (c.getParentId() == parentComment.getId())
|
if (c.getParentId() == parentComment.getId()) {
|
||||||
|
if (!CommentFilter.isCommentAllowed(c, commentFilter)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
expandedNewComments.add(c);
|
expandedNewComments.add(c);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +218,8 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void parseCommentRecursion(JSONArray comments, ArrayList<Comment> newCommentData,
|
private static void parseCommentRecursion(JSONArray comments, ArrayList<Comment> newCommentData,
|
||||||
ArrayList<String> moreChildrenIds, int depth) throws JSONException {
|
ArrayList<String> moreChildrenIds, int depth,
|
||||||
|
CommentFilter commentFilter) throws JSONException {
|
||||||
int actualCommentLength;
|
int actualCommentLength;
|
||||||
|
|
||||||
if (comments.length() == 0) {
|
if (comments.length() == 0) {
|
||||||
|
@ -0,0 +1,123 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||||
|
|
||||||
|
|
||||||
|
@Entity(tableName = "comment_filter")
|
||||||
|
public class CommentFilter implements Parcelable {
|
||||||
|
@PrimaryKey
|
||||||
|
@NonNull
|
||||||
|
public String name = "New Filter";
|
||||||
|
@ColumnInfo(name = "max_vote")
|
||||||
|
public int maxVote = -1;
|
||||||
|
@ColumnInfo(name = "min_vote")
|
||||||
|
public int minVote = -1;
|
||||||
|
@ColumnInfo(name = "exclude_strings")
|
||||||
|
public String excludeStrings;
|
||||||
|
@ColumnInfo(name = "exclude_users")
|
||||||
|
public String excludeUsers;
|
||||||
|
|
||||||
|
public CommentFilter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CommentFilter(Parcel in) {
|
||||||
|
name = in.readString();
|
||||||
|
maxVote = in.readInt();
|
||||||
|
minVote = in.readInt();
|
||||||
|
excludeStrings = in.readString();
|
||||||
|
excludeUsers = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<CommentFilter> CREATOR = new Creator<CommentFilter>() {
|
||||||
|
@Override
|
||||||
|
public CommentFilter createFromParcel(Parcel in) {
|
||||||
|
return new CommentFilter(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommentFilter[] newArray(int size) {
|
||||||
|
return new CommentFilter[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static boolean isCommentAllowed(Comment comment, CommentFilter commentFilter) {
|
||||||
|
int score = comment.getScore() + comment.getVoteType();
|
||||||
|
if (commentFilter.maxVote >= 0 && score > commentFilter.maxVote) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (commentFilter.minVote >= 0 && score < commentFilter.minVote) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (commentFilter.excludeStrings != null && !commentFilter.excludeStrings.equals("")) {
|
||||||
|
String[] titles = commentFilter.excludeStrings.split(",", 0);
|
||||||
|
for (String t : titles) {
|
||||||
|
if (!t.trim().equals("") && comment.getCommentRawText().toLowerCase().contains(t.toLowerCase().trim())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (commentFilter.excludeUsers != null && !commentFilter.excludeUsers.equals("")) {
|
||||||
|
String[] users = commentFilter.excludeUsers.split(",", 0);
|
||||||
|
for (String u : users) {
|
||||||
|
if (!u.trim().equals("") && comment.getAuthor().getQualifiedName().equalsIgnoreCase(u.trim())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommentFilter mergeCommentFilter(List<CommentFilter> commentFilterList) {
|
||||||
|
if (commentFilterList.size() == 1) {
|
||||||
|
return commentFilterList.get(0);
|
||||||
|
}
|
||||||
|
CommentFilter commentFilter = new CommentFilter();
|
||||||
|
StringBuilder stringBuilder;
|
||||||
|
commentFilter.name = "Merged";
|
||||||
|
|
||||||
|
for (CommentFilter c : commentFilterList) {
|
||||||
|
commentFilter.maxVote = Math.min(c.maxVote, commentFilter.maxVote);
|
||||||
|
commentFilter.minVote = Math.max(c.minVote, commentFilter.minVote);
|
||||||
|
|
||||||
|
if (c.excludeStrings != null && !c.excludeStrings.equals("")) {
|
||||||
|
stringBuilder = new StringBuilder(commentFilter.excludeStrings == null ? "" : commentFilter.excludeStrings);
|
||||||
|
stringBuilder.append(",").append(c.excludeStrings);
|
||||||
|
commentFilter.excludeStrings = stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.excludeUsers != null && !c.excludeUsers.equals("")) {
|
||||||
|
stringBuilder = new StringBuilder(commentFilter.excludeUsers == null ? "" : commentFilter.excludeUsers);
|
||||||
|
stringBuilder.append(",").append(c.excludeUsers);
|
||||||
|
commentFilter.excludeUsers = stringBuilder.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return commentFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
dest.writeString(name);
|
||||||
|
dest.writeInt(maxVote);
|
||||||
|
dest.writeInt(minVote);
|
||||||
|
dest.writeString(excludeStrings);
|
||||||
|
dest.writeString(excludeUsers);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Delete;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.OnConflictStrategy;
|
||||||
|
import androidx.room.Query;
|
||||||
|
import androidx.room.Transaction;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface CommentFilterDao {
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insert(CommentFilter CommentFilter);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insertAll(List<CommentFilter> CommentFilters);
|
||||||
|
|
||||||
|
@Query("DELETE FROM comment_filter")
|
||||||
|
void deleteAllCommentFilters();
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
void deleteCommentFilter(CommentFilter CommentFilter);
|
||||||
|
|
||||||
|
@Query("DELETE FROM comment_filter WHERE name = :name")
|
||||||
|
void deleteCommentFilter(String name);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter WHERE name = :name LIMIT 1")
|
||||||
|
CommentFilter getCommentFilter(String name);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter ORDER BY name")
|
||||||
|
LiveData<List<CommentFilter>> getAllCommentFiltersLiveData();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter")
|
||||||
|
List<CommentFilter> getAllCommentFilters();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter WHERE (comment_filter.name IN " +
|
||||||
|
"(SELECT comment_filter_usage.name FROM comment_filter_usage WHERE (usage = :usage AND name_of_usage = :nameOfUsage COLLATE NOCASE)))" +
|
||||||
|
" OR (comment_filter.name NOT IN (SELECT comment_filter_usage.name FROM comment_filter_usage))")
|
||||||
|
List<CommentFilter> getValidCommentFilters(int usage, String nameOfUsage);
|
||||||
|
|
||||||
|
@Transaction
|
||||||
|
@Query("SELECT * FROM comment_filter ORDER BY name")
|
||||||
|
public LiveData<List<CommentFilterWithUsage>> getAllCommentFilterWithUsageLiveData();
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.ForeignKey;
|
||||||
|
|
||||||
|
@Entity(tableName = "comment_filter_usage", primaryKeys = {"name", "usage", "name_of_usage"},
|
||||||
|
foreignKeys = @ForeignKey(entity = CommentFilter.class, parentColumns = "name",
|
||||||
|
childColumns = "name", onDelete = ForeignKey.CASCADE))
|
||||||
|
public class CommentFilterUsage implements Parcelable {
|
||||||
|
public static final int SUBREDDIT_TYPE = 1;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "name")
|
||||||
|
public String name;
|
||||||
|
@ColumnInfo(name = "usage")
|
||||||
|
public int usage;
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "name_of_usage")
|
||||||
|
public String nameOfUsage;
|
||||||
|
|
||||||
|
public CommentFilterUsage(@NonNull String name, int usage, @NonNull String nameOfUsage) {
|
||||||
|
this.name = name;
|
||||||
|
this.usage = usage;
|
||||||
|
this.nameOfUsage = nameOfUsage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CommentFilterUsage(Parcel in) {
|
||||||
|
name = in.readString();
|
||||||
|
usage = in.readInt();
|
||||||
|
nameOfUsage = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<CommentFilterUsage> CREATOR = new Creator<CommentFilterUsage>() {
|
||||||
|
@Override
|
||||||
|
public CommentFilterUsage createFromParcel(Parcel in) {
|
||||||
|
return new CommentFilterUsage(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommentFilterUsage[] newArray(int size) {
|
||||||
|
return new CommentFilterUsage[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
|
dest.writeString(name);
|
||||||
|
dest.writeInt(usage);
|
||||||
|
dest.writeString(nameOfUsage);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Delete;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.OnConflictStrategy;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface CommentFilterUsageDao {
|
||||||
|
@Query("SELECT * FROM comment_filter_usage WHERE name = :name")
|
||||||
|
LiveData<List<CommentFilterUsage>> getAllCommentFilterUsageLiveData(String name);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter_usage WHERE name = :name")
|
||||||
|
List<CommentFilterUsage> getAllCommentFilterUsage(String name);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM comment_filter_usage")
|
||||||
|
List<CommentFilterUsage> getAllCommentFilterUsageForBackup();
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insert(CommentFilterUsage CommentFilterUsage);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
void insertAll(List<CommentFilterUsage> CommentFilterUsageList);
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
void deleteCommentFilterUsage(CommentFilterUsage CommentFilterUsage);
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterUsageViewModel extends ViewModel {
|
||||||
|
private LiveData<List<CommentFilterUsage>> mCommentFilterUsageListLiveData;
|
||||||
|
|
||||||
|
public CommentFilterUsageViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String name) {
|
||||||
|
mCommentFilterUsageListLiveData = redditDataRoomDatabase.commentFilterUsageDao().getAllCommentFilterUsageLiveData(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<CommentFilterUsage>> getCommentFilterUsageListLiveData() {
|
||||||
|
return mCommentFilterUsageListLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||||
|
|
||||||
|
private final RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private final String mName;
|
||||||
|
|
||||||
|
public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String name) {
|
||||||
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) new CommentFilterUsageViewModel(mRedditDataRoomDatabase, mName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import androidx.room.Embedded;
|
||||||
|
import androidx.room.Relation;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommentFilterWithUsage {
|
||||||
|
@Embedded
|
||||||
|
public CommentFilter commentFilter;
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "name",
|
||||||
|
entityColumn = "name"
|
||||||
|
)
|
||||||
|
public List<CommentFilterUsage> commentFilterUsageList;
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommentFilterWithUsageViewModel extends ViewModel {
|
||||||
|
private LiveData<List<CommentFilterWithUsage>> mCommentFilterWithUsageListLiveData;
|
||||||
|
|
||||||
|
public CommentFilterWithUsageViewModel(RedditDataRoomDatabase redditDataRoomDatabase) {
|
||||||
|
mCommentFilterWithUsageListLiveData = redditDataRoomDatabase.commentFilterDao().getAllCommentFilterWithUsageLiveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<CommentFilterWithUsage>> getCommentFilterWithUsageListLiveData() {
|
||||||
|
return mCommentFilterWithUsageListLiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Factory extends ViewModelProvider.NewInstanceFactory {
|
||||||
|
|
||||||
|
private final RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public Factory(RedditDataRoomDatabase redditDataRoomDatabase) {
|
||||||
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) new CommentFilterWithUsageViewModel(mRedditDataRoomDatabase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class DeleteCommentFilter {
|
||||||
|
public static void deleteCommentFilter(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor, CommentFilter commentFilter) {
|
||||||
|
executor.execute(() -> redditDataRoomDatabase.commentFilterDao().deleteCommentFilter(commentFilter));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class DeleteCommentFilterUsage {
|
||||||
|
public static void deleteCommentFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
|
||||||
|
CommentFilterUsage commentFilterUsage) {
|
||||||
|
executor.execute(() -> redditDataRoomDatabase.commentFilterUsageDao().deleteCommentFilterUsage(commentFilterUsage));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
;import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
public class FetchCommentFilter {
|
||||||
|
public static void fetchCommentFilter(Executor executor, Handler handler,
|
||||||
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
String subreddit, FetchCommentFilterListener fetchCommentFilterListener) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
List<CommentFilter> commentFilterList = redditDataRoomDatabase.commentFilterDao().getValidCommentFilters(CommentFilterUsage.SUBREDDIT_TYPE, subreddit);
|
||||||
|
CommentFilter commentFilter = CommentFilter.mergeCommentFilter(commentFilterList);
|
||||||
|
|
||||||
|
handler.post(() -> fetchCommentFilterListener.success(commentFilter));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface FetchCommentFilterListener {
|
||||||
|
void success(CommentFilter commentFilter);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class SaveCommentFilter {
|
||||||
|
public interface SaveCommentFilterListener {
|
||||||
|
void success();
|
||||||
|
|
||||||
|
void duplicate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void saveCommentFilter(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
|
CommentFilter commentFilter, String originalName, SaveCommentFilter.SaveCommentFilterListener saveCommentFilterListener) {
|
||||||
|
executor.execute(() -> {
|
||||||
|
if (!originalName.equals(commentFilter.name) &&
|
||||||
|
redditDataRoomDatabase.commentFilterDao().getCommentFilter(commentFilter.name) != null) {
|
||||||
|
handler.post(saveCommentFilterListener::duplicate);
|
||||||
|
} else {
|
||||||
|
List<CommentFilterUsage> commentFilterUsages = redditDataRoomDatabase.commentFilterUsageDao().getAllCommentFilterUsage(originalName);
|
||||||
|
if (!originalName.equals(commentFilter.name)) {
|
||||||
|
redditDataRoomDatabase.commentFilterDao().deleteCommentFilter(originalName);
|
||||||
|
}
|
||||||
|
redditDataRoomDatabase.commentFilterDao().insert(commentFilter);
|
||||||
|
for (CommentFilterUsage commentFilterUsage : commentFilterUsages) {
|
||||||
|
commentFilterUsage.name = commentFilter.name;
|
||||||
|
redditDataRoomDatabase.commentFilterUsageDao().insert(commentFilterUsage);
|
||||||
|
}
|
||||||
|
handler.post(saveCommentFilterListener::success);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.commentfilter;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||||
|
|
||||||
|
|
||||||
|
public class SaveCommentFilterUsage {
|
||||||
|
public static void saveCommentFilterUsage(RedditDataRoomDatabase redditDataRoomDatabase, Executor executor,
|
||||||
|
CommentFilterUsage commentFilterUsage) {
|
||||||
|
executor.execute(() -> redditDataRoomDatabase.commentFilterUsageDao().insert(commentFilterUsage));
|
||||||
|
}
|
||||||
|
}
|
@ -64,6 +64,10 @@ public class CustomTheme {
|
|||||||
public int cardViewBackgroundColor;
|
public int cardViewBackgroundColor;
|
||||||
@ColumnInfo(name = "read_post_card_view_background_color")
|
@ColumnInfo(name = "read_post_card_view_background_color")
|
||||||
public int readPostCardViewBackgroundColor;
|
public int readPostCardViewBackgroundColor;
|
||||||
|
@ColumnInfo(name = "filled_card_view_background_color")
|
||||||
|
public int filledCardViewBackgroundColor;
|
||||||
|
@ColumnInfo(name = "read_post_filled_card_view_background_color")
|
||||||
|
public int readPostFilledCardViewBackgroundColor;
|
||||||
@ColumnInfo(name = "comment_background_color")
|
@ColumnInfo(name = "comment_background_color")
|
||||||
public int commentBackgroundColor;
|
public int commentBackgroundColor;
|
||||||
@ColumnInfo(name = "bottom_app_bar_background_color")
|
@ColumnInfo(name = "bottom_app_bar_background_color")
|
||||||
@ -255,71 +259,73 @@ public class CustomTheme {
|
|||||||
customTheme.backgroundColor = customThemeSettingsItems.get(19).colorValue;
|
customTheme.backgroundColor = customThemeSettingsItems.get(19).colorValue;
|
||||||
customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(20).colorValue;
|
customTheme.cardViewBackgroundColor = customThemeSettingsItems.get(20).colorValue;
|
||||||
customTheme.readPostCardViewBackgroundColor = customThemeSettingsItems.get(21).colorValue;
|
customTheme.readPostCardViewBackgroundColor = customThemeSettingsItems.get(21).colorValue;
|
||||||
customTheme.commentBackgroundColor = customThemeSettingsItems.get(22).colorValue;
|
customTheme.filledCardViewBackgroundColor = customThemeSettingsItems.get(22).colorValue;
|
||||||
customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(23).colorValue;
|
customTheme.readPostFilledCardViewBackgroundColor = customThemeSettingsItems.get(23).colorValue;
|
||||||
customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(24).colorValue;
|
customTheme.commentBackgroundColor = customThemeSettingsItems.get(24).colorValue;
|
||||||
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(25).colorValue;
|
customTheme.fullyCollapsedCommentBackgroundColor = customThemeSettingsItems.get(25).colorValue;
|
||||||
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(26).colorValue;
|
customTheme.awardedCommentBackgroundColor = customThemeSettingsItems.get(26).colorValue;
|
||||||
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(27).colorValue;
|
customTheme.receivedMessageBackgroundColor = customThemeSettingsItems.get(27).colorValue;
|
||||||
customTheme.primaryIconColor = customThemeSettingsItems.get(28).colorValue;
|
customTheme.sentMessageBackgroundColor = customThemeSettingsItems.get(28).colorValue;
|
||||||
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(29).colorValue;
|
customTheme.bottomAppBarBackgroundColor = customThemeSettingsItems.get(29).colorValue;
|
||||||
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(30).colorValue;
|
customTheme.primaryIconColor = customThemeSettingsItems.get(30).colorValue;
|
||||||
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(31).colorValue;
|
customTheme.bottomAppBarIconColor = customThemeSettingsItems.get(31).colorValue;
|
||||||
customTheme.fabIconColor = customThemeSettingsItems.get(32).colorValue;
|
customTheme.postIconAndInfoColor = customThemeSettingsItems.get(32).colorValue;
|
||||||
customTheme.sendMessageIconColor = customThemeSettingsItems.get(33).colorValue;
|
customTheme.commentIconAndInfoColor = customThemeSettingsItems.get(33).colorValue;
|
||||||
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(34).colorValue;
|
customTheme.fabIconColor = customThemeSettingsItems.get(34).colorValue;
|
||||||
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(35).colorValue;
|
customTheme.sendMessageIconColor = customThemeSettingsItems.get(35).colorValue;
|
||||||
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(36).colorValue;
|
customTheme.toolbarPrimaryTextAndIconColor = customThemeSettingsItems.get(36).colorValue;
|
||||||
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(37).colorValue;
|
customTheme.toolbarSecondaryTextColor = customThemeSettingsItems.get(37).colorValue;
|
||||||
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(38).colorValue;
|
customTheme.circularProgressBarBackground = customThemeSettingsItems.get(38).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(39).colorValue;
|
customTheme.mediaIndicatorIconColor = customThemeSettingsItems.get(39).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(40).colorValue;
|
customTheme.mediaIndicatorBackgroundColor = customThemeSettingsItems.get(40).colorValue;
|
||||||
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(41).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = customThemeSettingsItems.get(41).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(42).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = customThemeSettingsItems.get(42).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(43).colorValue;
|
customTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(43).colorValue;
|
||||||
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(44).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = customThemeSettingsItems.get(44).colorValue;
|
||||||
customTheme.upvoted = customThemeSettingsItems.get(45).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = customThemeSettingsItems.get(45).colorValue;
|
||||||
customTheme.downvoted = customThemeSettingsItems.get(46).colorValue;
|
customTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = customThemeSettingsItems.get(46).colorValue;
|
||||||
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(47).colorValue;
|
customTheme.upvoted = customThemeSettingsItems.get(47).colorValue;
|
||||||
customTheme.postTypeTextColor = customThemeSettingsItems.get(48).colorValue;
|
customTheme.downvoted = customThemeSettingsItems.get(48).colorValue;
|
||||||
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(49).colorValue;
|
customTheme.postTypeBackgroundColor = customThemeSettingsItems.get(49).colorValue;
|
||||||
customTheme.spoilerTextColor = customThemeSettingsItems.get(50).colorValue;
|
customTheme.postTypeTextColor = customThemeSettingsItems.get(50).colorValue;
|
||||||
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(51).colorValue;
|
customTheme.spoilerBackgroundColor = customThemeSettingsItems.get(51).colorValue;
|
||||||
customTheme.nsfwTextColor = customThemeSettingsItems.get(52).colorValue;
|
customTheme.spoilerTextColor = customThemeSettingsItems.get(52).colorValue;
|
||||||
customTheme.flairBackgroundColor = customThemeSettingsItems.get(53).colorValue;
|
customTheme.nsfwBackgroundColor = customThemeSettingsItems.get(53).colorValue;
|
||||||
customTheme.flairTextColor = customThemeSettingsItems.get(54).colorValue;
|
customTheme.nsfwTextColor = customThemeSettingsItems.get(54).colorValue;
|
||||||
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(55).colorValue;
|
customTheme.flairBackgroundColor = customThemeSettingsItems.get(55).colorValue;
|
||||||
customTheme.awardsTextColor = customThemeSettingsItems.get(56).colorValue;
|
customTheme.flairTextColor = customThemeSettingsItems.get(56).colorValue;
|
||||||
customTheme.archivedTint = customThemeSettingsItems.get(57).colorValue;
|
customTheme.awardsBackgroundColor = customThemeSettingsItems.get(57).colorValue;
|
||||||
customTheme.lockedIconTint = customThemeSettingsItems.get(58).colorValue;
|
customTheme.awardsTextColor = customThemeSettingsItems.get(58).colorValue;
|
||||||
customTheme.crosspostIconTint = customThemeSettingsItems.get(59).colorValue;
|
customTheme.archivedTint = customThemeSettingsItems.get(59).colorValue;
|
||||||
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(60).colorValue;
|
customTheme.lockedIconTint = customThemeSettingsItems.get(60).colorValue;
|
||||||
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(61).colorValue;
|
customTheme.crosspostIconTint = customThemeSettingsItems.get(61).colorValue;
|
||||||
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(62).colorValue;
|
customTheme.upvoteRatioIconTint = customThemeSettingsItems.get(62).colorValue;
|
||||||
customTheme.subscribed = customThemeSettingsItems.get(63).colorValue;
|
customTheme.stickiedPostIconTint = customThemeSettingsItems.get(63).colorValue;
|
||||||
customTheme.unsubscribed = customThemeSettingsItems.get(64).colorValue;
|
customTheme.noPreviewPostTypeIconTint = customThemeSettingsItems.get(64).colorValue;
|
||||||
customTheme.username = customThemeSettingsItems.get(65).colorValue;
|
customTheme.subscribed = customThemeSettingsItems.get(65).colorValue;
|
||||||
customTheme.subreddit = customThemeSettingsItems.get(66).colorValue;
|
customTheme.unsubscribed = customThemeSettingsItems.get(66).colorValue;
|
||||||
customTheme.authorFlairTextColor = customThemeSettingsItems.get(67).colorValue;
|
customTheme.username = customThemeSettingsItems.get(67).colorValue;
|
||||||
customTheme.submitter = customThemeSettingsItems.get(68).colorValue;
|
customTheme.subreddit = customThemeSettingsItems.get(68).colorValue;
|
||||||
customTheme.moderator = customThemeSettingsItems.get(69).colorValue;
|
customTheme.authorFlairTextColor = customThemeSettingsItems.get(69).colorValue;
|
||||||
customTheme.currentUser = customThemeSettingsItems.get(70).colorValue;
|
customTheme.submitter = customThemeSettingsItems.get(70).colorValue;
|
||||||
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(71).colorValue;
|
customTheme.moderator = customThemeSettingsItems.get(71).colorValue;
|
||||||
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(72).colorValue;
|
customTheme.currentUser = customThemeSettingsItems.get(72).colorValue;
|
||||||
customTheme.dividerColor = customThemeSettingsItems.get(73).colorValue;
|
customTheme.singleCommentThreadBackgroundColor = customThemeSettingsItems.get(73).colorValue;
|
||||||
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(74).colorValue;
|
customTheme.unreadMessageBackgroundColor = customThemeSettingsItems.get(74).colorValue;
|
||||||
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(75).colorValue;
|
customTheme.dividerColor = customThemeSettingsItems.get(75).colorValue;
|
||||||
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(76).colorValue;
|
customTheme.noPreviewPostTypeBackgroundColor = customThemeSettingsItems.get(76).colorValue;
|
||||||
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(77).colorValue;
|
customTheme.voteAndReplyUnavailableButtonColor = customThemeSettingsItems.get(77).colorValue;
|
||||||
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(78).colorValue;
|
customTheme.commentVerticalBarColor1 = customThemeSettingsItems.get(78).colorValue;
|
||||||
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(79).colorValue;
|
customTheme.commentVerticalBarColor2 = customThemeSettingsItems.get(79).colorValue;
|
||||||
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(80).colorValue;
|
customTheme.commentVerticalBarColor3 = customThemeSettingsItems.get(80).colorValue;
|
||||||
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(81).colorValue;
|
customTheme.commentVerticalBarColor4 = customThemeSettingsItems.get(81).colorValue;
|
||||||
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(82).colorValue;
|
customTheme.commentVerticalBarColor5 = customThemeSettingsItems.get(82).colorValue;
|
||||||
customTheme.navBarColor = customThemeSettingsItems.get(83).colorValue;
|
customTheme.commentVerticalBarColor6 = customThemeSettingsItems.get(83).colorValue;
|
||||||
customTheme.isLightStatusBar = customThemeSettingsItems.get(84).isEnabled;
|
customTheme.commentVerticalBarColor7 = customThemeSettingsItems.get(84).colorValue;
|
||||||
customTheme.isLightNavBar = customThemeSettingsItems.get(85).isEnabled;
|
customTheme.navBarColor = customThemeSettingsItems.get(85).colorValue;
|
||||||
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(86).isEnabled;
|
customTheme.isLightStatusBar = customThemeSettingsItems.get(86).isEnabled;
|
||||||
|
customTheme.isLightNavBar = customThemeSettingsItems.get(87).isEnabled;
|
||||||
|
customTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = customThemeSettingsItems.get(88).isEnabled;
|
||||||
|
|
||||||
return customTheme;
|
return customTheme;
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,14 @@ public class CustomThemeSettingsItem implements Parcelable {
|
|||||||
context.getString(R.string.theme_item_read_post_card_view_background_color),
|
context.getString(R.string.theme_item_read_post_card_view_background_color),
|
||||||
context.getString(R.string.theme_item_read_post_card_view_background_color_detail),
|
context.getString(R.string.theme_item_read_post_card_view_background_color_detail),
|
||||||
customTheme.readPostCardViewBackgroundColor));
|
customTheme.readPostCardViewBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_filled_card_view_background_color),
|
||||||
|
context.getString(R.string.theme_item_filled_card_view_background_color_detail),
|
||||||
|
customTheme.filledCardViewBackgroundColor));
|
||||||
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
|
context.getString(R.string.theme_item_read_post_filled_card_view_background_color),
|
||||||
|
context.getString(R.string.theme_item_read_post_filled_card_view_background_color_detail),
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor));
|
||||||
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
customThemeSettingsItems.add(new CustomThemeSettingsItem(
|
||||||
context.getString(R.string.theme_item_comment_background_color),
|
context.getString(R.string.theme_item_comment_background_color),
|
||||||
context.getString(R.string.theme_item_comment_background_color_detail),
|
context.getString(R.string.theme_item_comment_background_color_detail),
|
||||||
|
@ -127,6 +127,16 @@ public class CustomThemeWrapper {
|
|||||||
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
|
getDefaultColor("#F2E9E1", "#2B3B51", "#282828"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFilledCardViewBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.FILLED_CARD_VIEW_BACKGROUND_COLOR,
|
||||||
|
getDefaultColor("#E6F4FF", "#242424", "#000000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReadPostFilledCardViewBackgroundColor() {
|
||||||
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.READ_POST_FILLED_CARD_VIEW_BACKGROUND_COLOR,
|
||||||
|
getDefaultColor("#F5F5F5", "#101010", "#000000"));
|
||||||
|
}
|
||||||
|
|
||||||
public int getCommentBackgroundColor() {
|
public int getCommentBackgroundColor() {
|
||||||
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR,
|
return getThemeSharedPreferences().getInt(CustomThemeSharedPreferencesUtils.COMMENT_BACKGROUND_COLOR,
|
||||||
getDefaultColor("#F6F2EE", "#192330", "#282828"));
|
getDefaultColor("#F6F2EE", "#192330", "#282828"));
|
||||||
@ -548,6 +558,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#E6F4FF");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#000000");
|
customTheme.primaryIconColor = Color.parseColor("#000000");
|
||||||
@ -641,6 +653,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#121212");
|
customTheme.backgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -734,6 +748,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#000000");
|
customTheme.backgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -827,6 +843,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#E6F4FF");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#000000");
|
customTheme.primaryIconColor = Color.parseColor("#000000");
|
||||||
@ -920,6 +938,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#121212");
|
customTheme.backgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -1013,6 +1033,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#000000");
|
customTheme.backgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -1106,6 +1128,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.backgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#FFE9F3");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#F5F5F5");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.commentBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#FFFFFF");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#000000");
|
customTheme.primaryIconColor = Color.parseColor("#000000");
|
||||||
@ -1199,6 +1223,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#121212");
|
customTheme.backgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#242424");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#101010");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
customTheme.commentBackgroundColor = Color.parseColor("#242424");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#121212");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -1292,6 +1318,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#000000");
|
customTheme.backgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
customTheme.commentBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#000000");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -1385,6 +1413,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#282A36");
|
customTheme.backgroundColor = Color.parseColor("#282A36");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#393A59");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#393A59");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#1C1F3D");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#1C1F3D");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#393A59");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#1C1F3D");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#393A59");
|
customTheme.commentBackgroundColor = Color.parseColor("#393A59");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#393A59");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#393A59");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
customTheme.primaryIconColor = Color.parseColor("#FFFFFF");
|
||||||
@ -1478,6 +1508,8 @@ public class CustomThemeWrapper {
|
|||||||
customTheme.backgroundColor = Color.parseColor("#DAD0DE");
|
customTheme.backgroundColor = Color.parseColor("#DAD0DE");
|
||||||
customTheme.cardViewBackgroundColor = Color.parseColor("#C0F0F4");
|
customTheme.cardViewBackgroundColor = Color.parseColor("#C0F0F4");
|
||||||
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#D2E7EA");
|
customTheme.readPostCardViewBackgroundColor = Color.parseColor("#D2E7EA");
|
||||||
|
customTheme.filledCardViewBackgroundColor = Color.parseColor("#C0F0F4");
|
||||||
|
customTheme.readPostFilledCardViewBackgroundColor = Color.parseColor("#D2E7EA");
|
||||||
customTheme.commentBackgroundColor = Color.parseColor("#C0F0F4");
|
customTheme.commentBackgroundColor = Color.parseColor("#C0F0F4");
|
||||||
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#D48AE0");
|
customTheme.bottomAppBarBackgroundColor = Color.parseColor("#D48AE0");
|
||||||
customTheme.primaryIconColor = Color.parseColor("#000000");
|
customTheme.primaryIconColor = Color.parseColor("#000000");
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package eu.toldi.infinityforlemmy.customviews;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
public class InterceptTouchEventLinearLayout extends LinearLayout {
|
||||||
|
public InterceptTouchEventLinearLayout(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterceptTouchEventLinearLayout(Context context, @Nullable AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterceptTouchEventLinearLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterceptTouchEventLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
}
|
@ -389,7 +389,7 @@ public class SliderPanel extends FrameLayout {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The drag helper callbacks for dragging the slidr attachment from the bottom of hte screen
|
* The drag helper callbacks for dragging the slidr attachment from the bottom of the screen
|
||||||
*/
|
*/
|
||||||
private final ViewDragHelper.Callback bottomCallback = new ViewDragHelper.Callback() {
|
private final ViewDragHelper.Callback bottomCallback = new ViewDragHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,7 +154,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||||
if (!(viewHolder instanceof CommentsListingRecyclerViewAdapter.CommentViewHolder)) {
|
if (!(viewHolder instanceof CommentsListingRecyclerViewAdapter.CommentBaseViewHolder)) {
|
||||||
return makeMovementFlags(0, 0);
|
return makeMovementFlags(0, 0);
|
||||||
}
|
}
|
||||||
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,7 +29,6 @@ import javax.inject.Named;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
|
||||||
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
import eu.toldi.infinityforlemmy.FragmentCommunicator;
|
||||||
import eu.toldi.infinityforlemmy.Infinity;
|
import eu.toldi.infinityforlemmy.Infinity;
|
||||||
import eu.toldi.infinityforlemmy.R;
|
import eu.toldi.infinityforlemmy.R;
|
||||||
@ -45,6 +44,7 @@ import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
|||||||
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.utils.SharedPreferencesUtils;
|
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||||
|
import me.zhanghai.android.fastscroll.FastScrollerBuilder;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class MultiRedditListingFragment extends Fragment implements FragmentCommunicator {
|
public class MultiRedditListingFragment extends Fragment implements FragmentCommunicator {
|
||||||
@ -111,9 +111,9 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
|
|||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
|
boolean isGettingMultiredditInfo = getArguments().getBoolean(EXTRA_IS_GETTING_MULTIREDDIT_INFO, false);
|
||||||
|
|
||||||
if (accessToken == null) {
|
|
||||||
mSwipeRefreshLayout.setEnabled(false);
|
mSwipeRefreshLayout.setEnabled(false);
|
||||||
}
|
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
|
|||||||
MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(mActivity,
|
MultiRedditListingRecyclerViewAdapter adapter = new MultiRedditListingRecyclerViewAdapter(mActivity,
|
||||||
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken,
|
mExecutor, mOauthRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, accessToken,
|
||||||
new MultiRedditListingRecyclerViewAdapter.OnItemClickListener() {
|
new MultiRedditListingRecyclerViewAdapter.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(MultiReddit multiReddit) {
|
public void onClick(MultiReddit multiReddit) {
|
||||||
if (mActivity instanceof MultiredditSelectionActivity) {
|
if (mActivity instanceof MultiredditSelectionActivity) {
|
||||||
((MultiredditSelectionActivity) mActivity).getSelectedMultireddit(multiReddit);
|
((MultiredditSelectionActivity) mActivity).getSelectedMultireddit(multiReddit);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user