52 Commits

Author SHA1 Message Date
Balazs Toldi
134c895cd4 The .profm sorting in build.gradle instead of excluding them from the build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:49:58 +02:00
Balazs Toldi
ec6567b9b2 Add python to build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:49:14 +02:00
Balazs Toldi
40fa3a1987 Fully reproducible build
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-20 07:39:12 +02:00
Balazs Toldi
05123c7068 Reproducible classes2.dex
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-19 22:00:03 +02:00
Balazs Toldi
908f294130 Fix issue with marking as read when swiping
This commit fixes the issue where the 'swiping between posts' and 'mark post as read' options are enable. Previously, it only marked the first post as read, and not the ones that were swiped to. Now, all posts are marked read in these scenarios.
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-19 08:18:14 +02:00
Balazs Toldi
95408f8125 Fix link for translation
Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-16 18:58:49 +02:00
Balazs Toldi
6d5ba059f8 Fixing issue with swiping to see new posts.
This commit fixes the issue with Fetching new posts when swiping on the post detail page.
2023-10-13 18:21:37 +02:00
Balazs Toldi
ecdd9da9c8 Fix issue where display name makes impossible to load saved things
This commit fixes an issue where the display name of a user makes it
impossible to load saved things. The problem is that the display name
was used in the url to load the saved things instead of the username.

Closes #179

Signed-off-by: Balazs Toldi <balazs@toldi.eu>
2023-10-12 09:16:56 +02:00
Balazs Toldi
1c17e6b7d2 Fix some issues with the "goto User" and "goto Community" options
This commit allows the user to input the communities with their "!" prefix. Similarly, it also allows the "@" prefix for users when trying to navigate to them with their corresponding "go to" options.

Also fixes issues with these options in the Community and User pages.
2023-10-12 08:26:50 +02:00
Balazs Toldi
9f60eca225 Fix crash when trying to open the community lists in some cases.
In some cases the app crashed when trying to select a community. This commit attempts to fix this issue
2023-10-12 08:08:02 +02:00
Balazs Toldi
9deba8b10e Fixing some sort type issues
This commit fixes issues where the sort type/time isn't loaded properly and the app resets back to NEW on the frontpage and Hot on Community pages.

Heads up: You might need to change the sort type in your settings if you see any issues.
2023-10-12 08:06:06 +02:00
Balazs Toldi
05948d74f4 Fix authentication when opening the app 2023-10-11 14:00:07 +02:00
Balazs Toldi
1007be50f8 Fix autherntiction on first logging in to Lemmy 0.19 2023-10-11 13:56:14 +02:00
Balazs Toldi
28617cf9a8 Compatibility for Lemmy 0.19
Closes #197
2023-10-06 12:56:33 +02:00
Bazsalanszky
5d2d43eebc Merge pull request 'Add preview to RedGIFs posts' (#187) from tinsukE/Eternity:regifs-preview into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/187
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-10-06 06:15:34 +00:00
Bazsalanszky
f2b2525823 Merge pull request 'Fix parsing posts and userdata: admin flag removed in recent versions of Lemmy' (#190) from otaconix/Eternity:fix-for-missing-admin-flag into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/190
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-10-06 06:01:11 +00:00
Balazs Toldi
29547f4750 Show instance for user listings
Closes #166
2023-09-12 09:02:27 +02:00
Balazs Toldi
af63bba54a Show instance for community listings 2023-09-12 08:43:56 +02:00
Stefan Zwanenburg
caf4f177d2 Fix parsing posts and userdata: admin flag removed in recent versions of Lemmy
See: https://github.com/LemmyNet/lemmy/pull/3403

For now, I guess we can try parsing the flag if it's present, and fall
back on assuming the associated user is *not* an admin.
2023-09-11 11:46:08 +02:00
Angelo Suzuki
1e67b34440 Add previews to RedGIFs posts
- Setup Glide with OkHttp in the custom application
- Add PostEnricher framework, that allows to add more data to fetched Posts. This was used to fetch the RedGIFs preview from their API.
2023-09-07 13:03:08 +02:00
Angelo Suzuki
67afcd7e88 Cleanup RedGIFs API usage
- Add User-Agent and authentication transparently
- Provide RedgifsAPI instance
2023-09-07 13:02:59 +02:00
Bazsalanszky
9406f29562 Merge pull request 'Use an OkHttpClient with User-Agent when initializing BigImageViewer' (#185) from tinsukE/Eternity:glide_user_agent into master
Reviewed-on: https://codeberg.org/Bazsalanszky/Eternity/pulls/185
Reviewed-by: Bazsalanszky <bazsalanszky@noreply.codeberg.org>
2023-09-07 08:48:52 +00:00
Angelo Suzuki
b626c5fb73 Use an OkHttpClient with User-Agent when initializing BigImageViewer.
If not passed, BigImageViewer overrides the Glide OkHttp downloader upon initialization with an empty one:
https://github.com/Piasy/BigImageViewer/blob/067f8eb/GlideImageLoader/src/main/java/com/github/piasy/biv/loader/glide/GlideProgressSupport.java#L76

In that case, Glide creates a default User-Agent:
cbdc1e78b4/library/src/main/java/com/bumptech/glide/load/model/LazyHeaders.java (L103-L106)

Example User-Agent: Dalvik/2.1.0 (Linux; U; Android 11; sdk_gphone_x86 Build/RSR1.201013.001)

https://files.catbox.moe is filtering out that User-Agent. Using the App one fixes it.
2023-09-05 11:42:38 +02:00
Balazs Toldi
0393ff6e77 Fix link text colour on the InstanceInfoActivity 2023-09-03 10:31:07 +02:00
Balazs Toldi
30ecc17d55 Fixing crash on opening community selector on post creation page 2023-09-03 10:21:43 +02:00
Bazsalanszky
7c5f184cc8 Updated Readme.md 2023-08-30 10:13:23 +02:00
Balazs Toldi
d5fff14cb0 Fix flashing screen on the MainActivity when changing the anonymous instance 2023-08-25 22:23:20 +02:00
Balazs Toldi
5cdda037b2 Change artifact name on tagged builds 2023-08-25 17:41:24 +02:00
Balazs Toldi
0942f7c5ec Bump version 2023-08-25 17:34:14 +02:00
Balazs Toldi
efe90d0030 Changed default media download location to the "Eternity" folder 2023-08-25 17:23:56 +02:00
Balazs Toldi
2d45f337d7 Somewhat better phone images 2023-08-25 17:15:50 +02:00
Balazs Toldi
70cf6f3340 Fix bug with unsubscribing from communities 2023-08-25 17:14:23 +02:00
Balazs Toldi
6542859892 Fix IndexOutOfBoundsException in CommentsRecyclerViewAdapter 2023-08-25 09:36:37 +02:00
Balazs Toldi
143bc5e1b6 Fix issues with resolving Links
This commit changes how resolving links work. It will not use the resolve object function now for local instance links, as they would fail almost every time.

It also opens toasts in the application context instead of the activity context. This might prevent some crashes
2023-08-25 09:02:39 +02:00
Balazs Toldi
6e51ea6ee7 Fix crashes and issues with searching in communities 2023-08-25 08:35:05 +02:00
Balazs Toldi
d7c4e3d5bc Truncate long names in the navigation header 2023-08-24 23:11:34 +02:00
Balazs Toldi
1ed86c138e Removed automatically added dependency 2023-08-24 23:10:46 +02:00
Balazs Toldi
2d83545865 Fix theming on multiple elements
Fixed theming on:
- Post content on PostImage and PostLink activities
- Report content forms

Closes #163
2023-08-24 20:09:52 +02:00
Balazs Toldi
3594f10fdd Fix issues with subscription listing after marking communities as favorite
Previously, when marking a community as favorite made some communities disappear on the subscription list
2023-08-24 19:53:48 +02:00
Balazs Toldi
a903ac9dbd Attempt to fix crash when deleted comment add necessary placeholder 2023-08-23 23:23:10 +02:00
Balazs Toldi
ed90a278a6 Fix crashes related to sort types
Closes #153 and #113
2023-08-23 22:53:41 +02:00
Balazs Toldi
6221b33a3d Fix user name on collapsed comments
Closes #161
2023-08-23 22:35:51 +02:00
Balazs Toldi
2561ba8bd0 Fix post layouts 2023-08-23 21:39:08 +02:00
Balazs Toldi
9859608764 Merge remote-tracking branch 'weblate/master'
# Conflicts:
#	app/src/main/res/values/strings.xml
2023-08-23 21:24:20 +02:00
SomeTr
b40077f83f Translated using Weblate (Ukrainian)
Currently translated at 99.7% (1249 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-23 19:19:38 +00:00
Bazsalanszky
76dc0ff083 Translated using Weblate (Hungarian)
Currently translated at 81.7% (1024 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/hu/
2023-08-23 19:19:38 +00:00
Bazsalanszky
6a2d59ed48 Translated using Weblate (English)
Currently translated at 100.0% (1252 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/en/
2023-08-23 19:19:38 +00:00
Balazs Toldi
a09d6f85f8 Add option to share links on local instance 2023-08-23 21:14:53 +02:00
SomeTr
2f3d39ed31 Translated using Weblate (Ukrainian)
Currently translated at 99.6% (1248 of 1252 strings)

Translation: Eternity/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/uk/
2023-08-23 09:21:45 +00:00
American_Jesus
83e0fc039f Translated using Weblate (Portuguese)
Currently translated at 99.1% (1235 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/pt/
2023-08-23 09:21:45 +00:00
julroy67
d4ca682882 Translated using Weblate (French)
Currently translated at 94.5% (1177 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/fr/
2023-08-23 09:21:45 +00:00
dieserniko
e2b75a3928 Translated using Weblate (German)
Currently translated at 98.2% (1223 of 1245 strings)

Translation: Infinity for Lemmy/App
Translate-URL: https://translate.codeberg.org/projects/infinity-for-lemmy/app/de/
2023-08-23 09:21:45 +00:00
91 changed files with 1406 additions and 618 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -2,13 +2,14 @@ steps:
build:
image: alvrme/alpine-android:android-33-jdk11
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleRelease
when:
path: [ app/**, build.gradle ]
sign:
image: alvrme/alpine-android:android-33-jdk11
commands:
- ./scripts/apk-sign.sh LemmInfinity-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk
- ./scripts/apk-sign.sh Eternity-signed.apk app/build/outputs/apk/release/app-release-unsigned.apk
secrets: [ APK_KS_PASS, APK_KS, APK_KS_ALIAS ]
when:
event: [ tag ]
@@ -17,7 +18,7 @@ steps:
settings:
base_url: https://codeberg.org
files:
- LemmInfinity-signed.apk
- Eternity-signed.apk
api_key:
from_secret: GITEA_ACCESS_TOKEN
target: main

View File

@@ -8,6 +8,7 @@ steps:
build:
image: alvrme/alpine-android:android-33-jdk11
commands:
- apk add --no-cache python3
- ./gradlew :app:assembleNightly
sign:
image: alvrme/alpine-android:android-33-jdk11

View File

@@ -10,22 +10,28 @@ A Lemmy client for Android written in Java. It's a fork of the [Infinity for Red
<br>
<div align="center">
<img src="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
<img src="https://codeberg.org/Bazsalanszky/Eternity/raw/branch/master/fastlane/metadata/android/en-US/images/icon.png" width=256>
[![status-badge](https://ci.codeberg.org/api/badges/12474/status.svg)](https://ci.codeberg.org/repos/12474)
[![Liberapay patrons](https://img.shields.io/liberapay/patrons/bazsalanszky)](https://liberapay.com/Bazsalanszky)
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues">Report a Bug</a>
<a href="https://codeberg.org/Bazsalanszky/Eternity/issues">Report a Bug</a>
</div>
<div align="center">
<a href="https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy">
<img src="./.assets/google-play-badge.png" height="80">
</a>
<a href="https://apt.izzysoft.de/fdroid/index/apk/eu.toldi.infinityforlemmy">
<img src="./.assets/IzzyOnDroid.png" height="80">
</a>
<a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/releases/">
<a href="https://codeberg.org/Bazsalanszky/Eternity/releases/">
<img src="./.assets/codeberg.png" height="80">
</a>
</div>
---
@@ -68,17 +74,17 @@ Don't forget to give the project a star! Thanks again!
You can alos 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/infinity-for-lemmy/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/infinity-for-lemmy/)
[![Translation](https://translate.codeberg.org/widgets/infinity-for-lemmy/-/app/multi-auto.svg)](https://translate.codeberg.org/engage/Eternity/)
### Reporting bugs
You can also contribute by [reporting bugs](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/issues)
You can also contribute by [reporting bugs](https://codeberg.org/Bazsalanszky/Eternity/issues)
<p align="right">(<a href="#top">back to top</a>)</p>
## License
Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy/src/branch/master/LICENSE">LICENSE</a> for more information.
Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsalanszky/Eternity/src/branch/master/LICENSE">LICENSE</a> for more information.
<p align="right">(<a href="#top">back to top</a>)</p>
@@ -86,6 +92,6 @@ Distributed under the AGPL-3.0 License. See <a href="https://codeberg.org/Bazsal
[@bazsalanszky@lemmy.toldi.eu](https://lemmy.toldi.eu/u/bazsalanszky) - (Owner)
Project Link: [https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy](https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy)
Project Link: [https://codeberg.org/Bazsalanszky/Eternity](https://codeberg.org/Bazsalanszky/Eternity)
<p align="right">(<a href="#top">back to top</a>)</p>

View File

@@ -21,8 +21,8 @@ android {
applicationId "eu.toldi.infinityforlemmy"
minSdk 21
targetSdk 33
versionCode 129
versionName "0.1.0"
versionCode 130
versionName "0.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
@@ -98,6 +98,30 @@ android {
doNotStrip '**/*.so'
}
namespace 'eu.toldi.infinityforlemmy'
task rearrangeClass(type: Exec) {
commandLine 'python', '../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 {
@@ -108,7 +132,7 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.0"
def lifecycleVersion = "2.5.1"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion"
@@ -196,6 +220,7 @@ dependencies {
def glideVersion = "4.12.0"
implementation "com.github.bumptech.glide:glide:$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 'com.github.santalu:aspect-ratio-imageview:1.0.9'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
@@ -245,3 +270,34 @@ dependencies {
//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, "")
}
}
}
}
}
}
}

View File

@@ -113,7 +113,7 @@ import eu.toldi.infinityforlemmy.settings.TranslationFragment;
import eu.toldi.infinityforlemmy.settings.VideoPreferenceFragment;
@Singleton
@Component(modules = {AppModule.class, NetworkModule.class})
@Component(modules = {AppModule.class, NetworkModule.class, PostEnricherModule.class})
public interface AppComponent {
void inject(MainActivity mainActivity);

View File

@@ -1,7 +1,5 @@
package eu.toldi.infinityforlemmy;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler;
import org.json.JSONException;
@@ -12,9 +10,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.GfycatAPI;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
@@ -44,14 +40,12 @@ public class FetchGfycatOrRedgifsVideoLinks {
});
}
public static void fetchRedgifsVideoLinks(Context context, Executor executor, Handler handler, Retrofit redgifsRetrofit,
SharedPreferences currentAccountSharedPreferences,
public static void fetchRedgifsVideoLinks(Executor executor, Handler handler, Retrofit redgifsRetrofit,
String gfycatId,
FetchGfycatOrRedgifsVideoLinksListener fetchGfycatOrRedgifsVideoLinksListener) {
executor.execute(() -> {
try {
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(currentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")),
gfycatId, APIUtils.USER_AGENT).execute();
Response<String> response = redgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(gfycatId).execute();
if (response.isSuccessful()) {
parseRedgifsVideoLinks(handler, response.body(), fetchGfycatOrRedgifsVideoLinksListener);
} else {

View File

@@ -11,6 +11,16 @@ import android.os.Bundle;
import android.view.WindowManager;
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.livefront.bridge.Bridge;
import com.livefront.bridge.SavedStateHandler;
@@ -18,15 +28,11 @@ import com.livefront.bridge.SavedStateHandler;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.io.InputStream;
import javax.inject.Inject;
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.broadcastreceivers.NetworkWifiStatusReceiver;
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.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.Call;
import okhttp3.OkHttpClient;
public class Infinity extends Application implements LifecycleObserver {
public Typeface typeface;
@@ -55,6 +63,9 @@ public class Infinity extends Application implements LifecycleObserver {
@Inject
@Named("security")
SharedPreferences mSecuritySharedPreferences;
@Inject
@Named("glide")
OkHttpClient glideOkHttpClient;
@Override
public void onCreate() {
@@ -159,6 +170,9 @@ public class Infinity extends Application implements LifecycleObserver {
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
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)

View File

@@ -9,10 +9,11 @@ import javax.inject.Singleton;
import dagger.Module;
import dagger.Provides;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
import eu.toldi.infinityforlemmy.privatemessage.LemmyPrivateMessageAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import okhttp3.ConnectionPool;
import okhttp3.Interceptor;
@@ -34,6 +35,21 @@ abstract class NetworkModule {
.build();
}
@Provides
@Named("glide")
@Singleton
static OkHttpClient provideGlideOkHttp(@Named("base") OkHttpClient baseOkHttp,
@Named("RedgifsAccessTokenAuthenticator") Interceptor redGifsAuthenticator) {
return baseOkHttp.newBuilder()
.addInterceptor(chain -> chain.proceed(
chain.request()
.newBuilder()
.header("User-Agent", APIUtils.USER_AGENT)
.build()
))
.addInterceptor(redGifsAuthenticator)
.build();
}
@Provides
@Named("base")
@@ -165,6 +181,12 @@ abstract class NetworkModule {
.build();
}
@Provides
@Singleton
static RedgifsAPI provideRedgifsAPI(@Named("redgifs") Retrofit redgifsRetrofit) {
return redgifsRetrofit.create(RedgifsAPI.class);
}
@Provides
@Named("imgur")
@Singleton

View File

@@ -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);
}
}

View File

@@ -14,7 +14,6 @@ import java.util.Map;
import eu.toldi.infinityforlemmy.apis.RedgifsAPI;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import okhttp3.Headers;
import okhttp3.Interceptor;
import okhttp3.Response;
import retrofit2.Call;
@@ -22,6 +21,8 @@ import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;
public class RedgifsAccessTokenAuthenticator implements Interceptor {
private static final String REDGIFS_HOST = "redgifs.com";
private SharedPreferences mCurrentAccountSharedPreferences;
public RedgifsAccessTokenAuthenticator(SharedPreferences currentAccountSharedPreferences) {
@@ -60,7 +61,17 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
@NonNull
@Override
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) {
String accessTokenHeader = response.request().header(APIUtils.AUTHORIZATION_KEY);
if (accessTokenHeader == null) {
@@ -74,13 +85,21 @@ public class RedgifsAccessTokenAuthenticator implements Interceptor {
String newAccessToken = refreshAccessToken();
if (!newAccessToken.equals("")) {
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 {
return response;
}
} else {
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()
);
}
}
}

View File

@@ -1,7 +1,10 @@
package eu.toldi.infinityforlemmy;
import android.util.Log;
import eu.toldi.infinityforlemmy.network.SortTypeConverterFactory;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.guava.GuavaCallAdapterFactory;
@@ -12,8 +15,14 @@ public class RetrofitHolder {
private Retrofit retrofit;
private OkHttpClient okHttpClient;
private OkHttpClient okHttpClientBase;
private String baseURL = APIUtils.API_BASE_URI;
private String accessToken = null;
private Interceptor oAuthInterceptor;
public Retrofit getRetrofit() {
return retrofit;
}
@@ -33,6 +42,7 @@ public class RetrofitHolder {
public RetrofitHolder(OkHttpClient okHttpClient) {
this.okHttpClient = okHttpClient;
this.okHttpClientBase = okHttpClient;
this.retrofit = createRetrofit(okHttpClient, APIUtils.API_BASE_URI);
}
@@ -46,4 +56,18 @@ public class RetrofitHolder {
.addConverterFactory(GsonConverterFactory.create())
.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);
}
}

View File

@@ -69,15 +69,15 @@ public class SortType {
}
public enum Time {
HOUR("TopHour", "Top Hour"),
SIX_HOURS("TopSixHour", "Top Six Hours"),
TWELVE_HOURS("TopTwelveHour", "Top Twelve Hours"),
HOUR("hour", "Hour"),
SIX_HOURS("SixHour", "Six Hours"),
TWELVE_HOURS("TwelveHour", "Twelve Hours"),
DAY("day", "Day"),
WEEK("week", "Week"),
MONTH("month", "Month"),
THREE_MONTHS("TopThreeMonth", "Top Three Months"),
SIX_MONTHS("TopSixMonth", "Top Six Months"),
NINE_MONTHS("TopNineMonth", "Top Nine Months"),
THREE_MONTHS("ThreeMonths", "Three Months"),
SIX_MONTHS("SixMonths", "Six Months"),
NINE_MONTHS("NineMonths", "Nine Months"),
YEAR("year", "Year"),
ALL("all", "All Time");
@@ -88,5 +88,14 @@ public class SortType {
this.value = value;
this.fullName = fullName;
}
public static Time fromValue(String value) {
for (Time time : values()) {
if (time.value.equalsIgnoreCase(value)) {
return time;
}
}
return null;
}
}
}

View File

@@ -283,7 +283,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
PostFragment fragment = new PostFragment();
Bundle bundle = new Bundle();
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_ACCESS_TOKEN, mAccessToken);
bundle.putString(PostFragment.EXTRA_ACCOUNT_NAME, mAccountName);
@@ -293,7 +293,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
CommentsListingFragment fragment = new CommentsListingFragment();
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_ACCOUNT_NAME, mAccountName);
bundle.putBoolean(CommentsListingFragment.EXTRA_ARE_SAVED_COMMENTS, true);

View File

@@ -1,14 +1,19 @@
package eu.toldi.infinityforlemmy.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Bundle;
import android.text.Spanned;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
@@ -40,6 +45,9 @@ import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.MarkwonConfiguration;
import io.noties.markwon.MarkwonPlugin;
import io.noties.markwon.core.MarkwonTheme;
import io.noties.markwon.recycler.MarkwonAdapter;
public class InstanceInfoActivity extends BaseActivity {
@@ -105,16 +113,43 @@ public class InstanceInfoActivity extends BaseActivity {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Remove transparency from navigation bar
getWindow().setNavigationBarColor(mCustomThemeWrapper.getBackgroundColor());
int markdownColor = customThemeWrapper.getPostContentColor();
int postSpoilerBackgroundColor = markdownColor | 0xFF000000;
int linkColor = customThemeWrapper.getLinkColor();
MarkwonPlugin miscPlugin = new AbstractMarkwonPlugin() {
@Override
public void beforeSetText(@NonNull TextView textView, @NonNull Spanned markdown) {
if (InstanceInfoActivity.this.contentTypeface != null) {
textView.setTypeface(InstanceInfoActivity.this.contentTypeface);
}
textView.setTextColor(markdownColor);
textView.setHighlightColor(Color.TRANSPARENT);
}
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
Intent intent = new Intent(InstanceInfoActivity.this, LinkResolverActivity.class);
Uri uri = Uri.parse(link);
intent.setData(uri);
InstanceInfoActivity.this.startActivity(intent);
});
}
@Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
builder.linkColor(linkColor);
}
};
mPostDetailMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
new AbstractMarkwonPlugin() {
}, markdownColor, postSpoilerBackgroundColor, null);
miscPlugin, markdownColor, postSpoilerBackgroundColor, null);
mMarkwonAdapter = MarkdownUtils.createTablesAdapter();
mContentMarkdownView.setAdapter(mMarkwonAdapter);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);

View File

@@ -7,6 +7,7 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.URLUtil;
import android.widget.Toast;
@@ -17,8 +18,11 @@ import androidx.browser.customtabs.CustomTabsService;
import org.apache.commons.io.FilenameUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
@@ -29,8 +33,10 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.FetchComment;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.post.FetchPost;
import eu.toldi.infinityforlemmy.post.ObjectResolver;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -75,6 +81,12 @@ public class LinkResolverActivity extends AppCompatActivity {
@Named("no_oauth")
RetrofitHolder mRetrofit;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private String mAccessToken;
private Uri getRedditUriByPath(String path) {
@@ -94,20 +106,23 @@ public class LinkResolverActivity extends AppCompatActivity {
if (mAccessToken != null) {
String instance = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_INSTANCE, null);
mRetrofit.setBaseURL(instance);
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
mRetrofit.setAccessToken(mAccessToken);
}
}
Uri uri = getIntent().getData();
if (uri == null) {
String url = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if (!URLUtil.isValidUrl(url)) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
try {
uri = Uri.parse(url);
} catch (NullPointerException e) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
@@ -115,7 +130,7 @@ public class LinkResolverActivity extends AppCompatActivity {
if (uri.getScheme() == null && uri.getHost() == null) {
if (uri.toString().isEmpty()) {
Toast.makeText(this, R.string.invalid_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.invalid_link, Toast.LENGTH_SHORT).show();
finish();
return;
}
@@ -127,7 +142,7 @@ public class LinkResolverActivity extends AppCompatActivity {
private void handleUri(Uri uri) {
if (uri == null) {
Toast.makeText(this, R.string.no_link_available, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.no_link_available, Toast.LENGTH_SHORT).show();
} else {
String path = uri.getPath();
if (path == null) {
@@ -201,23 +216,52 @@ public class LinkResolverActivity extends AppCompatActivity {
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
} else {
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object p) {
Post post = (Post) p;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), segments.get(segments.size() - 1), mAccessToken, postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
@Override
public void onResolveObjectFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
@Override
public void fetchPostFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
});
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
if (!local) {
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object p) {
Post post = (Post) p;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
} else if (uri.toString().matches(COMMENT_PATTERN)) {
if (mAccessToken == null) {
@@ -237,30 +281,61 @@ public class LinkResolverActivity extends AppCompatActivity {
@Override
public void onFetchCommentFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
} else {
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object c) {
Comment comment = (Comment) c;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
boolean local = false;
try {
URL baseURL = new URL(mRetrofit.getBaseURL());
if (baseURL.getHost().equalsIgnoreCase(uri.getHost())) {
local = true;
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), mAccessToken, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
Comment comment = comments.get(0);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
@Override
public void onFetchCommentFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
});
} catch (MalformedURLException e) {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
if (!local) {
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
@Override
public void onResolveObjectSuccess(Object c) {
Comment comment = (Comment) c;
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_PARENT_ID, comment.getParentId());
startActivity(intent);
}
@Override
public void onResolveObjectFailed() {
Toast.makeText(getApplicationContext(), R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
finish();
}
});
}
}
} else if (authority.equals("v.redd.it")) {
Intent intent = new Intent(this, ViewVideoActivity.class);

View File

@@ -8,7 +8,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.util.Log;
import android.util.Patterns;
import android.view.InflateException;
import android.view.MenuItem;
import android.widget.Button;
@@ -180,6 +179,7 @@ public class LoginActivity extends BaseActivity {
try {
JSONObject responseJSON = new JSONObject(accountResponse);
String accessToken = responseJSON.getString("jwt");
mRetrofit.setAccessToken(null);
FetchMyInfo.fetchAccountInfo(mRetrofit.getRetrofit(), mRedditDataRoomDatabase, username,
accessToken, new FetchMyInfo.FetchMyInfoListener() {
@@ -189,13 +189,23 @@ public class LoginActivity extends BaseActivity {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name,display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance,canDownvote, mRedditDataRoomDatabase.accountDao(),
ParseAndInsertNewAccount.parseAndInsertNewAccount(mExecutor, new Handler(), name, display_name, accessToken, profileImageUrl, bannerImageUrl, authCode, finalInstance, canDownvote, mRedditDataRoomDatabase.accountDao(),
() -> {
Intent resultIntent = new Intent();
setResult(Activity.RESULT_OK, resultIntent);
finish();
});
mCurrentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
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

View File

@@ -336,11 +336,14 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
fragmentManager = getSupportFragmentManager();
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
if (mCurrentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.BEARER_TOKEN_AUTH, true)) {
mRetrofit.setAccessToken(mAccessToken);
}
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_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);
if(instance != null) {
if (instance != null) {
mRetrofit.setBaseURL(instance);
}
@@ -365,7 +368,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
super.onResume();
if (mAccessToken == null) {
String instancePreference = mSharedPreferences.getString(SharedPreferencesUtils.ANONYMOUS_ACCOUNT_INSTANCE, APIUtils.API_BASE_URI);
if (!mRetrofit.getBaseURL().equalsIgnoreCase(instancePreference)) {
if (!instancePreference.startsWith(mRetrofit.getBaseURL())) {
mRetrofit.setBaseURL(instancePreference);
this.recreate();
}
}
@@ -1510,7 +1514,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1568,7 +1577,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1589,7 +1602,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1602,7 +1619,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@@ -504,7 +504,7 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -475,6 +475,8 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
nsfwTextView.setTextColor(primaryTextColor);
titleEditText.setTextColor(primaryTextColor);
titleEditText.setHintTextColor(secondaryTextColor);
contentEditText.setTextColor(primaryTextColor);
contentEditText.setHintTextColor(secondaryTextColor);
boolean circleFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
applyFABTheme(captureFab, circleFab);
applyFABTheme(selectFromLibraryFab, circleFab);
@@ -487,6 +489,10 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
titleEditText.setTypeface(typeface);
selectAgainTextView.setTypeface(typeface);
}
if (contentTypeface != null) {
contentEditText.setTypeface(contentTypeface);
}
}
private void loadImage() {
@@ -511,7 +517,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(), mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -458,6 +458,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
titleEditText.setHintTextColor(secondaryTextColor);
suggestTitleButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
suggestTitleButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
contentEditText.setTextColor(primaryTextColor);
contentEditText.setHintTextColor(secondaryTextColor);
linkEditText.setTextColor(primaryTextColor);
linkEditText.setHintTextColor(secondaryTextColor);
if (typeface != null) {
@@ -470,6 +472,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
}
if (contentTypeface != null) {
linkEditText.setTypeface(contentTypeface);
contentEditText.setTypeface(contentTypeface);
}
}
@@ -489,7 +492,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -500,7 +500,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
}
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName, mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;

View File

@@ -451,11 +451,11 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, communityData.getQualified_name(),
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -486,11 +486,11 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -433,12 +433,14 @@ public class SearchActivity extends BaseActivity {
if (resultCode == RESULT_OK && data != null) {
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
communityData = data.getParcelableExtra(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
subredditName = communityData.getName();
subredditIsUser = false;
if (subredditName == null) {
if (communityData == null) {
subredditNameTextView.setText(R.string.all_communities);
} else {
subredditName = communityData.getName();
communityQualifiedName = communityData.getQualified_name();
subredditNameTextView.setText(subredditName);
}
} else if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {

View File

@@ -499,11 +499,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
private void loadSubredditIcon() {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
iconUrl = iconImageUrl;
displaySubredditIcon();
loadSubredditIconSuccessful = true;
});
}
private void promptAlertDialog(int titleResId, int messageResId) {

View File

@@ -78,6 +78,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontStyle;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.OkHttpClient;
public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWallpaperCallback, CustomFontReceiver {
@@ -108,6 +109,9 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
@Inject
Executor mExecutor;
private boolean isActionBarHidden = false;
private boolean isDownloading = false;
@@ -146,7 +150,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
getTheme().applyStyle(ContentFontFamily.valueOf(mSharedPreferences
.getString(SharedPreferencesUtils.CONTENT_FONT_FAMILY_KEY, ContentFontFamily.Default.name())).getResId(), true);
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
setContentView(R.layout.activity_view_image_or_gif);

View File

@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.SaveComment;
import eu.toldi.infinityforlemmy.SaveThing;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.SortTypeSelectionCallback;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
import eu.toldi.infinityforlemmy.comment.Comment;
@@ -81,10 +82,12 @@ import eu.toldi.infinityforlemmy.post.HistoryPostPagingSource;
import eu.toldi.infinityforlemmy.post.ParsePost;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.readpost.ReadPost;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
@@ -147,6 +150,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
@Inject
PostEnricher postEnricher;
@State
ArrayList<Post> posts;
@State
@@ -195,7 +203,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
super.onCreate(savedInstanceState);
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(this.getApplicationContext(), okHttpClient));
setContentView(R.layout.activity_view_post_detail);
@@ -526,69 +534,38 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
Handler handler = new Handler(Looper.getMainLooper());
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {
int nextPage = posts.size() / 25 + 1;
mExecutor.execute(() -> {
RedditAPI api = (mAccessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit).create(RedditAPI.class);
LemmyAPI api = mRetrofit.getRetrofit().create(LemmyAPI.class);
Call<String> call;
String afterKey = posts.isEmpty() ? null : posts.get(posts.size() - 1).getFullName();
switch (postType) {
case PostPagingSource.TYPE_SUBREDDIT:
if (mAccessToken == null) {
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
} else {
call = api.getSubredditBestPostsOauth(subredditName, sortType,
sortTime, afterKey, APIUtils.getOAuthHeader(mAccessToken));
}
call = api.getPosts(null, sortType.value, nextPage, 25, null, post.getSubredditNamePrefixed(), false, mAccessToken);
break;
case PostPagingSource.TYPE_USER:
if (mAccessToken == null) {
call = api.getUserPosts(username, afterKey, sortType, sortTime);
} else {
call = api.getUserPostsOauth(username, userWhere, afterKey, sortType,
sortTime, APIUtils.getOAuthHeader(mAccessToken));
}
call = api.getUserPosts(username, sortType.value, nextPage, 25, false, mAccessToken);
break;
case PostPagingSource.TYPE_SEARCH:
if (subredditName == null) {
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));
}
}
call = api.search(query, null, subredditName, null, "Post", sortType.value, "All", nextPage, 25, mAccessToken);
break;
case PostPagingSource.TYPE_MULTI_REDDIT:
if (mAccessToken == null) {
call = api.getMultiRedditPosts(multiPath, afterKey, sortTime);
} else {
call = api.getMultiRedditPostsOauth(multiPath, afterKey,
sortTime, APIUtils.getOAuthHeader(mAccessToken));
}
break;
// TODO: Implement multi community
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
//case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT
call = api.getSubredditBestPosts(subredditName, sortType, sortTime, afterKey);
break;
// TODO: Implement anonymous front page
default:
call = api.getBestPosts(sortType, sortTime, afterKey,
APIUtils.getOAuthHeader(mAccessToken));
String type = (subredditName.equals("all")) ? "All" : (subredditName.equals("local")) ? "Local" : "Subscribed";
call = api.getPosts(type, sortType.value, nextPage, 25, null, null, false, mAccessToken);
}
try {
Response<String> response = call.execute();
if (response.isSuccessful()) {
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) {
handler.post(() -> {
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;
@@ -670,7 +647,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
Response<String> response = historyPosts.execute();
if (response.isSuccessful()) {
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()) {
handler.post(() -> {
loadingMorePostsStatus = LoadingMorePostsStatus.NO_MORE_POSTS;

View File

@@ -1518,7 +1518,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1576,7 +1580,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1597,7 +1605,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1610,7 +1622,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@@ -1514,7 +1514,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1572,7 +1576,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@@ -1593,7 +1601,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}
@@ -1606,7 +1618,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {

View File

@@ -108,6 +108,7 @@ import eu.toldi.infinityforlemmy.font.TitleFontFamily;
import eu.toldi.infinityforlemmy.font.TitleFontStyle;
import eu.toldi.infinityforlemmy.post.FetchPost;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.services.DownloadRedditVideoService;
import eu.toldi.infinityforlemmy.utils.APIUtils;
@@ -222,10 +223,6 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@@ -235,6 +232,9 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
@Inject
SimpleCache mSimpleCache;
@Inject
PostEnricher postEnricher;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -756,8 +756,8 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
}
});
} else {
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(this, mExecutor, new Handler(), redgifsRetrofit,
mCurrentAccountSharedPreferences, gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
FetchGfycatOrRedgifsVideoLinks.fetchRedgifsVideoLinks(mExecutor, new Handler(), redgifsRetrofit,
gfycatId, new FetchGfycatOrRedgifsVideoLinks.FetchGfycatOrRedgifsVideoLinksListener() {
@Override
public void success(String webm, String mp4) {
progressBar.setVisibility(View.GONE);
@@ -791,7 +791,7 @@ public class ViewVideoActivity extends AppCompatActivity implements CustomFontRe
int commentsIndex = segments.lastIndexOf("comments");
String postId = segments.get(commentsIndex + 1);
FetchPost.fetchPost(mExecutor, new Handler(), retrofit.getRetrofit(), postId, null,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (post.isGfycat()) {

View File

@@ -15,6 +15,7 @@ import com.bumptech.glide.request.RequestOptions;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.regex.Pattern;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -186,6 +187,10 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText("@" + fullname.split(Pattern.quote("@"), 2)[1]);
((SubredditViewHolder) viewHolder).communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
@@ -318,6 +323,9 @@ public class BlockedCommunitiesRecyclerViewAdapter extends RecyclerView.Adapter<
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
SubredditViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);

View File

@@ -572,7 +572,9 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
Comment comment = getCurrentComment(position);
if (comment != null) {
String authorWithPrefix = "u/" + comment.getAuthorName();
String author_name = (mShowUserDisplayName) ? comment.getAuthorName() : comment.getAuthor().getUsername();
String authorInstance = (mHideUserInstance) ? "" : "@" + comment.getAuthor().getQualifiedName().split(Pattern.quote("@"))[1];
String authorWithPrefix = author_name + authorInstance;
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
if (comment.getAuthorIconUrl() == null) {
@@ -662,21 +664,21 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
mExpandChildren, 1, new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
if (mVisibleComments.size() > parentPosition
&& parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
if (parentComment.getId() == mVisibleComments.get(parentPosition).getId()) {
if (mVisibleComments.get(parentPosition).isExpanded()) {
mVisibleComments.get(parentPosition).getChildren()
.remove(mVisibleComments.get(parentPosition).getChildren().size() - 1);
// mVisibleComments.get(parentPosition).removeMoreChildrenIds();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), commentPosition);
if (placeholderPosition != -1) {
mVisibleComments.remove(placeholderPosition);
if (position != -1) {
if (mIsSingleCommentThreadMode) {
notifyItemRemoved(placeholderPosition + 1);
mVisibleComments.remove(position - 1);
notifyItemRemoved(position + 1);
} else {
notifyItemRemoved(placeholderPosition);
mVisibleComments.remove(position);
notifyItemRemoved(position);
}
List<Comment> trulyNewComments = new ArrayList<>();
for (int i = 0; i < expandedComments.size(); i++) {
@@ -686,11 +688,13 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
trulyNewComments.add(expandedComments.get(i));
loadedComments.add(expandedComments.get(i).getId());
}
mVisibleComments.addAll(placeholderPosition, trulyNewComments);
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(placeholderPosition + 1, trulyNewComments.size());
} else {
notifyItemRangeInserted(placeholderPosition, trulyNewComments.size());
if (!trulyNewComments.isEmpty()) {
mVisibleComments.addAll(position, trulyNewComments);
if (mIsSingleCommentThreadMode) {
notifyItemRangeInserted(position + 1, trulyNewComments.size());
} else {
notifyItemRangeInserted(position, trulyNewComments.size());
}
}
}
@@ -720,7 +724,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (mVisibleComments.get(i).getFullName().equals(parentComment.getFullName())) {
if (mVisibleComments.get(i).isExpanded()) {
int placeholderPositionHint = i + mVisibleComments.get(i).getChildren().size();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), placeholderPositionHint);
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getId(), placeholderPositionHint);
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
@@ -758,7 +762,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
@Override
public void onFetchCommentFailed() {
int currentParentPosition = findCommentPosition(parentComment.getFullName(), parentPosition);
int currentParentPosition = findCommentPosition(parentComment.getId(), parentPosition);
if (currentParentPosition == -1) {
// note: returning here is probably a mistake, because
// parent is just not visible, but it can still exist in the comments tree.
@@ -768,7 +772,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
if (currentParentComment.isExpanded()) {
int placeholderPositionHint = currentParentPosition + currentParentComment.getChildren().size();
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getFullName(), placeholderPositionHint);
int placeholderPosition = findLoadMoreCommentsPlaceholderPosition(parentComment.getId(), placeholderPositionHint);
if (placeholderPosition != -1) {
mVisibleComments.get(placeholderPosition).setLoadingMoreChildren(false);
@@ -817,7 +821,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
*
* @return position of the placeholder or -1 if not found
*/
private int findCommentPosition(String fullName, int positionHint) {
private int findCommentPosition(int fullName, int positionHint) {
return findCommentPosition(fullName, positionHint, Comment.NOT_PLACEHOLDER);
}
@@ -827,20 +831,20 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
*
* @return position of the placeholder or -1 if not found
*/
private int findLoadMoreCommentsPlaceholderPosition(String fullName, int positionHint) {
return findCommentPosition(fullName, positionHint, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS);
private int findLoadMoreCommentsPlaceholderPosition(int id, int positionHint) {
return findCommentPosition(id, positionHint, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS);
}
private int findCommentPosition(String fullName, int positionHint, int placeholderType) {
private int findCommentPosition(int id, int positionHint, int placeholderType) {
if (0 <= positionHint && positionHint < mVisibleComments.size()
&& mVisibleComments.get(positionHint).getFullName().equals(fullName)
&& mVisibleComments.get(positionHint).getId() == id
&& mVisibleComments.get(positionHint).getPlaceholderType() == placeholderType) {
return positionHint;
}
for (int i = 0; i < mVisibleComments.size(); i++) {
Comment comment = mVisibleComments.get(i);
if (comment.getFullName().equals(fullName) && comment.getPlaceholderType() == placeholderType) {
if (comment.getId() == id && comment.getPlaceholderType() == placeholderType) {
return i;
}
}

View File

@@ -139,7 +139,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
private BaseActivity mActivity;
private HistoryPostFragment mFragment;
private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor;
private Retrofit retrofit;
private Retrofit mGfycatRetrofit;
@@ -227,7 +226,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streambleApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
SharedPreferences sharedPreferences, SharedPreferences currentAccountSharedPreferences,
SharedPreferences sharedPreferences,
SharedPreferences nsfwAndSpoilerSharedPreferences,
ExoCreator exoCreator, Callback callback) {
super(DIFF_CALLBACK);
@@ -235,7 +234,6 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
mActivity = activity;
mFragment = fragment;
mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor;
retrofit = oauthRetrofit;
mGfycatRetrofit = gfycatRetrofit;
@@ -698,7 +696,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -875,7 +873,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,

View File

@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveMemoryCenterInisdeDownsampleStrategy;
import eu.toldi.infinityforlemmy.SavePost;
import eu.toldi.infinityforlemmy.SaveThing;
@@ -135,8 +136,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private BaseActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor;
private Retrofit mRetrofit;
private Retrofit mOauthRetrofit;
private RetrofitHolder mRetrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private final Provider<StreamableAPI> mStreamableApiProvider;
@@ -172,6 +172,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private boolean mHideUpvoteRatio;
private boolean mHideTheNumberOfAwards;
private boolean mHideSubredditAndUserPrefix;
private boolean mShareOnLocalInstance;
private boolean mShowDisplayNames;
private boolean mHideTheNumberOfVotes;
@@ -223,7 +224,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit gfycatRetrofit,
RetrofitHolder retrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
boolean separatePostAndComments, String accessToken,
@@ -347,6 +348,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mHideUpvoteRatio = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_UPVOTE_RATIO, false);
mHideTheNumberOfAwards = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_AWARDS, false);
mHideSubredditAndUserPrefix = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mShareOnLocalInstance = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
mShowDisplayNames = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.POST_DETAIL_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
mHideTheNumberOfVotes = postDetailsSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
@@ -485,7 +487,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
if (mPost.getAuthorIconUrl() == null) {
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase,mPost.getAuthorNamePrefixed(), mOauthRetrofit, iconImageUrl -> {
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase, mPost.getAuthorNamePrefixed(), mRetrofit.getRetrofit(), iconImageUrl -> {
if (mActivity != null && getItemCount() > 0) {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
@@ -519,7 +521,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.getSubredditIconUrl() == null) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(),
mRedditDataRoomDatabase, mPost.getSubredditNamePrefixed(),
mAccessToken, mOauthRetrofit, mRetrofit, iconImageUrl -> {
mAccessToken, mRetrofit.getRetrofit(), iconImageUrl -> {
if (iconImageUrl == null || iconImageUrl.equals("")) {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
@@ -696,7 +698,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
if (mPost.isGfycat() || mPost.isRedgifs() && !mPost.isLoadGfycatOrStreamableVideoSuccess()) {
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
mPost.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(mPost.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), mPost.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(mPost.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostDetailVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
mPost.isGfycat(), mAutomaticallyTryRedgifs,
@@ -1385,7 +1387,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
VoteThing.votePost(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
VoteThing.votePost(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
@Override
public void onVoteThingSuccess() {
if (newVoteType == Integer.parseInt(APIUtils.DIR_UPVOTE)) {
@@ -1491,13 +1493,13 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mPostDetailRecyclerViewAdapterCallback.updatePost(mPost);
VoteThing.votePost(mActivity, mRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
VoteThing.votePost(mActivity, mRetrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
@Override
public void onVoteThingSuccess() {
if (newVoteType == Integer.parseInt(APIUtils.DIR_DOWNVOTE)) {
mPost.setVoteType(-1);
mDownvoteButton.setColorFilter(mDownvotedColor, PorterDuff.Mode.SRC_IN);
if(mSeperateUpvoteAndDownvote) {
if (mSeperateUpvoteAndDownvote) {
mDownvoteTextView.setTextColor(mDownvotedColor);
} else {
mScoreTextView.setTextColor(mDownvotedColor);
@@ -1587,7 +1589,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
SavePost savePost = new SavePost();
if (mPost.isSaved()) {
mSaveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(mRetrofit, mAccessToken, mPost.getId(),
savePost.unsaveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -1607,7 +1609,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
} else {
mSaveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(mRetrofit, mAccessToken, mPost.getId(),
savePost.saveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -1629,8 +1631,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
mShareButton.setOnClickListener(view -> {
String link = (mShareOnLocalInstance) ? mRetrofit.getBaseURL() + "/post/" + mPost.getId() : mPost.getPermalink();
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, mPost.getPermalink());
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, link);
if (mPost.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, mPost.getPostType());
switch (mPost.getPostType()) {
@@ -1651,7 +1654,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
});
mShareButton.setOnLongClickListener(view -> {
mActivity.copyLink(mPost.getPermalink());
String link = (mShareOnLocalInstance) ? mRetrofit.getBaseURL() + "/post/" + mPost.getId() : mPost.getPermalink();
mActivity.copyLink(link);
return true;
});

View File

@@ -71,6 +71,7 @@ import eu.toldi.infinityforlemmy.FetchGfycatOrRedgifsVideoLinks;
import eu.toldi.infinityforlemmy.FetchStreamableVideo;
import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
import eu.toldi.infinityforlemmy.R;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SaveMemoryCenterInisdeDownsampleStrategy;
import eu.toldi.infinityforlemmy.SavePost;
import eu.toldi.infinityforlemmy.SaveThing;
@@ -150,7 +151,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private SharedPreferences mSharedPreferences;
private SharedPreferences mCurrentAccountSharedPreferences;
private Executor mExecutor;
private Retrofit retrofit;
private RetrofitHolder retrofit;
private Retrofit mGfycatRetrofit;
private Retrofit mRedgifsRetrofit;
private Provider<StreamableAPI> mStreamableApiProvider;
@@ -230,6 +231,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean mShowDisplayNames;
private boolean mHideTheNumberOfVotes;
private boolean mShareLinkOnLocalInstance;
private boolean mSeparateUpandDownVotes;
private boolean mHideDownvotes;
@@ -244,7 +247,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private boolean canPlayVideo = true;
private RecyclerView.RecycledViewPool mGalleryRecycledViewPool;
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit,
public PostRecyclerViewAdapter(BaseActivity activity, PostFragment fragment, Executor executor, RetrofitHolder retrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
CustomThemeWrapper customThemeWrapper, Locale locale,
String accessToken, String accountName, int postType, int postLayout, boolean displaySubredditName,
@@ -259,7 +262,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mSharedPreferences = sharedPreferences;
mCurrentAccountSharedPreferences = currentAccountSharedPreferences;
mExecutor = executor;
retrofit = oauthRetrofit;
this.retrofit = retrofit;
mGfycatRetrofit = gfycatRetrofit;
mRedgifsRetrofit = redgifsRetrofit;
mStreamableApiProvider = streamableApiProvider;
@@ -316,6 +319,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mHideSubredditAndUserPrefix = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX, false);
mShowDisplayNames = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_DISPLAY_NAME_INSTEAD_OF_USERNAME, true);
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mShareLinkOnLocalInstance = sharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
mHideDownvotes = !currentAccountSharedPreferences.getBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true);
mSeparateUpandDownVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.POST_SEPARATE_UP_AND_DOWN_VOTES, true) && !mHideDownvotes;
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
@@ -783,7 +787,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -975,7 +979,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if ((post.isGfycat() || post.isRedgifs()) && !post.isLoadGfycatOrStreamableVideoSuccess()) {
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
post.isGfycat() ? mGfycatRetrofit.create(GfycatAPI.class).getGfycatData(post.getGfycatId()) :
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(APIUtils.getRedgifsOAuthHeader(mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.REDGIFS_ACCESS_TOKEN, "")), post.getGfycatId(), APIUtils.USER_AGENT);
mRedgifsRetrofit.create(RedgifsAPI.class).getRedgifsData(post.getGfycatId());
FetchGfycatOrRedgifsVideoLinks.fetchGfycatOrRedgifsVideoLinksInRecyclerViewAdapter(mExecutor, new Handler(),
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall,
post.isGfycat(), mAutomaticallyTryRedgifs,
@@ -1893,8 +1897,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
private void shareLink(Post post) {
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
Bundle bundle = new Bundle();
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, post.getPermalink());
bundle.putString(ShareLinkBottomSheetFragment.EXTRA_POST_LINK, link);
if (post.getPostType() != Post.TEXT_TYPE) {
bundle.putInt(ShareLinkBottomSheetFragment.EXTRA_MEDIA_TYPE, post.getPostType());
switch (post.getPostType()) {
@@ -2666,7 +2671,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -2782,7 +2787,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -2790,9 +2795,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
post.setVoteType(-1);
if (currentPosition == position) {
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if(mSeparateUpandDownVotes){
if (mSeparateUpandDownVotes) {
downvoteTextView.setTextColor(mDownvotedColor);
}else {
} else {
scoreTextView.setTextColor(mDownvotedColor);
}
}
@@ -2855,7 +2860,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost savePost = new SavePost();
if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
savePost.unsaveThing(retrofit, mAccessToken, post.getId(),
savePost.unsaveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -2879,7 +2884,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
savePost.saveThing(retrofit, mAccessToken, post.getId(),
savePost.saveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -2923,7 +2928,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
Post post = getItem(position);
if (post != null) {
mActivity.copyLink(post.getPermalink());
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
mActivity.copyLink(link);
return true;
}
return false;
@@ -4118,7 +4124,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes, post.getScore() + post.getVoteType()));
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -4224,7 +4230,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
VoteThing.votePost(mActivity, retrofit, mAccessToken, new VoteThing.VoteThingListener() {
VoteThing.votePost(mActivity, retrofit.getRetrofit(), mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getBindingAdapterPosition();
@@ -4232,7 +4238,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
post.setVoteType(-1);
if (currentPosition == position) {
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if(mSeparateUpandDownVotes) {
if (mSeparateUpandDownVotes) {
downvoteTextView.setTextColor(mDownvotedColor);
} else {
scoreTextView.setTextColor(mDownvotedColor);
@@ -4297,7 +4303,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
SavePost postSave = new SavePost();
if (post.isSaved()) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
postSave.unsaveThing(retrofit, mAccessToken, post.getId(),
postSave.unsaveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -4321,7 +4327,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
});
} else {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
postSave.saveThing(retrofit, mAccessToken, post.getId(),
postSave.saveThing(retrofit.getRetrofit(), mAccessToken, post.getId(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
@@ -4365,7 +4371,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
Post post = getItem(position);
if (post != null) {
mActivity.copyLink(post.getPermalink());
String link = (mShareLinkOnLocalInstance) ? retrofit.getBaseURL() + "/post/" + post.getId() : post.getPermalink();
mActivity.copyLink(link);
return true;
}
return false;

View File

@@ -141,7 +141,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
.into(((DataViewHolder) holder).iconGifImageView);
}
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName());
((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getTitle());
((DataViewHolder) holder).communityInstanceTextView.setText('@' + LemmyUtils.actorID2FullName(subredditData.getActorId()).split("@")[1]);
((DataViewHolder) holder).subscriberCountTextView.setText(activity.getString(R.string.subscribers_number_detail, subredditData.getNSubscribers()));
if (!isMultiSelection) {
@@ -262,6 +263,9 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
GifImageView iconGifImageView;
@BindView(R.id.subreddit_name_text_view_item_subreddit_listing)
TextView subredditNameTextView;
@BindView(R.id.community_instance_text_view_item_subreddit_listing)
TextView communityInstanceTextView;
@BindView(R.id.subscriber_count_text_view_item_subreddit_listing)
TextView subscriberCountTextView;
@BindView(R.id.subscribe_image_view_item_subreddit_listing)
@@ -273,6 +277,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
super(itemView);
ButterKnife.bind(this, itemView);
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
subscriberCountTextView.setTextColor(secondaryTextColor);
subscribeButton.setColorFilter(unsubscribed, android.graphics.PorterDuff.Mode.SRC_IN);
if (isMultiSelection) {

View File

@@ -84,12 +84,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) {
if (itemClickListener != null && !hasClearSelectionRow) {
if (position == 0) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 1) {
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
} else if (position == mFavoriteSubscribedSubredditData.size() + 2) {
} else if (position == mFavoriteSubscribedSubredditData.size() + 1) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteSubscribedSubredditData.size() + 1) {
} else if (position <= mFavoriteSubscribedSubredditData.size()) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
@@ -98,12 +96,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (position == 0) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 1) {
return VIEW_TYPE_SUBREDDIT;
} else if (position == 2) {
return VIEW_TYPE_FAVORITE_SUBREDDIT_DIVIDER;
} else if (position == mFavoriteSubscribedSubredditData.size() + 3) {
} else if (position == mFavoriteSubscribedSubredditData.size() + 2) {
return VIEW_TYPE_SUBREDDIT_DIVIDER;
} else if (position <= mFavoriteSubscribedSubredditData.size() + 2) {
} else if (position < mFavoriteSubscribedSubredditData.size() + 2) {
return VIEW_TYPE_FAVORITE_SUBREDDIT;
} else {
return VIEW_TYPE_SUBREDDIT;
@@ -155,8 +151,22 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(null));
return;
} else {
int offset = hasClearSelectionRow ? 1 : 0;
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 3 : 1;
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
name = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
fullname = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
iconUrl = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
@@ -181,6 +191,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
});
if (itemClickListener != null) {
SubscribedSubredditData communityData = mSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
viewHolder.itemView.setOnClickListener(view -> itemClickListener.onClick(communityData));
}
}
@@ -209,19 +220,23 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((SubredditViewHolder) viewHolder).iconGifImageView);
}
((SubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((SubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
} else if (viewHolder instanceof FavoriteSubredditViewHolder) {
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = 3;
} else {
offset = 2;
} else {
offset = 1;
}
} else {
offset = 1;
}
SubscribedSubredditData communityData = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset);
String name = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getName();
String fullname = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getQualified_name();
String iconUrl = mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).getIconUrl();
if (mFavoriteSubscribedSubredditData.get(viewHolder.getBindingAdapterPosition() - offset).isFavorite()) {
@@ -267,15 +282,26 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
.into(((FavoriteSubredditViewHolder) viewHolder).iconGifImageView);
}
((FavoriteSubredditViewHolder) viewHolder).subredditNameTextView.setText(name);
if (fullname.contains("@")) {
((FavoriteSubredditViewHolder) viewHolder).communityInstanceTextView.setText(fullname.substring(fullname.indexOf("@")));
}
}
}
@Override
public int getItemCount() {
if (mSubscribedSubredditData != null) {
if (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) {
if (itemClickListener != null) {
return mSubscribedSubredditData.size() > 0 ?
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 3 : 2) : 0;
}
return mSubscribedSubredditData.size() > 0 ?
mFavoriteSubscribedSubredditData.size() + mSubscribedSubredditData.size() + 2 : 0;
}
if (itemClickListener != null) {
return mSubscribedSubredditData.size() > 0 ? mSubscribedSubredditData.size() + ((hasClearSelectionRow) ? 1 : 0) : 0;
return (hasClearSelectionRow) ? mSubscribedSubredditData.size() + 1 : mSubscribedSubredditData.size();
}
return mSubscribedSubredditData.size();
@@ -283,6 +309,7 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
return 0;
}
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
if(holder instanceof SubredditViewHolder) {
@@ -324,10 +351,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 4 : 0;
mFavoriteSubscribedSubredditData.size() + 3 : 0;
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
mFavoriteSubscribedSubredditData.size() + 3 : 0;
mFavoriteSubscribedSubredditData.size() + 2 : 0;
}
} else {
offset = (mFavoriteSubscribedSubredditData != null && mFavoriteSubscribedSubredditData.size() > 0) ?
@@ -340,9 +367,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
int offset;
if (itemClickListener != null) {
if (hasClearSelectionRow) {
offset = 3;
} else {
offset = 2;
} else {
offset = 1;
}
} else {
offset = 1;
@@ -362,6 +389,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
GifImageView iconGifImageView;
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
@@ -370,8 +400,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}
@@ -380,6 +412,9 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
GifImageView iconGifImageView;
@BindView(R.id.thing_name_text_view_item_subscribed_thing)
TextView subredditNameTextView;
@BindView(R.id.thing_instance_text_view_item_subscribed_thing)
TextView communityInstanceTextView;
@BindView(R.id.favorite_image_view_item_subscribed_thing)
ImageView favoriteImageView;
@@ -389,8 +424,10 @@ public class SubscribedSubredditsRecyclerViewAdapter extends RecyclerView.Adapte
ButterKnife.bind(this, itemView);
if (mActivity.typeface != null) {
subredditNameTextView.setTypeface(mActivity.typeface);
communityInstanceTextView.setTypeface(mActivity.typeface);
}
subredditNameTextView.setTextColor(primaryTextColor);
communityInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
}
}

View File

@@ -136,7 +136,9 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
.into(((DataViewHolder) holder).iconGifImageView);
}
((DataViewHolder) holder).userNameTextView.setText(userData.getName());
((DataViewHolder) holder).userNameTextView.setText(userData.getTitle().equals("") ? userData.getName() : userData.getTitle());
String qualifiedName = LemmyUtils.actorID2FullName(userData.getActorId());
((DataViewHolder) holder).userInstanceTextView.setText(qualifiedName.substring(qualifiedName.indexOf('@')));
if (!isMultiSelection) {
CheckIsFollowingUser.checkIsFollowingUser(executor, new Handler(), redditDataRoomDatabase,
@@ -237,6 +239,9 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
GifImageView iconGifImageView;
@BindView(R.id.user_name_text_view_item_user_listing)
TextView userNameTextView;
@BindView(R.id.user_instance_text_view_item_user_listing)
TextView userInstanceTextView;
@BindView(R.id.subscribe_image_view_item_user_listing)
ImageView subscribeButton;
@BindView(R.id.checkbox__item_user_listing)
@@ -246,6 +251,7 @@ public class UserListingRecyclerViewAdapter extends PagedListAdapter<UserData, R
super(itemView);
ButterKnife.bind(this, itemView);
userNameTextView.setTextColor(primaryTextColor);
userInstanceTextView.setTextColor(CustomThemeWrapper.darkenColor(primaryTextColor, 0.7f));
subscribeButton.setColorFilter(unsubscribedColor, android.graphics.PorterDuff.Mode.SRC_IN);
if (activity.typeface != null) {

View File

@@ -101,7 +101,16 @@ public interface LemmyAPI {
Call<String> postDelete(@Body DeletePostDTO params);
@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("sort") String sort,
@Query("page") Integer page,
@@ -129,7 +138,19 @@ public interface LemmyAPI {
);
@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("sort") String sort,
@Query("page") Integer page,

View File

@@ -6,14 +6,16 @@ import retrofit2.Call;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HeaderMap;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
public interface RedgifsAPI {
@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
@POST("/v2/oauth/client")

View File

@@ -118,25 +118,20 @@ public class InsertSubscribedThings {
(List<SubscribedSubredditData> newSubscribedSubreddits,
List<SubscribedSubredditData> oldSubscribedSubreddits,
List<String> unsubscribedSubredditNames) {
int newIndex = 0;
for (int oldIndex = 0; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
if (newIndex >= newSubscribedSubreddits.size()) {
for (; oldIndex < oldSubscribedSubreddits.size(); oldIndex++) {
unsubscribedSubredditNames.add(oldSubscribedSubreddits.get(oldIndex).getQualified_name());
}
return;
}
List<String> oldSubredditNames = new ArrayList<>();
for (SubscribedSubredditData subredditData : oldSubscribedSubreddits) {
oldSubredditNames.add(subredditData.getQualified_name());
}
SubscribedSubredditData old = oldSubscribedSubreddits.get(oldIndex);
for (; newIndex < newSubscribedSubreddits.size(); newIndex++) {
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) == 0) {
newIndex++;
break;
}
if (newSubscribedSubreddits.get(newIndex).getQualified_name().compareToIgnoreCase(old.getQualified_name()) > 0) {
unsubscribedSubredditNames.add(old.getQualified_name());
break;
}
List<String> newSubredditNames = new ArrayList<>();
for (SubscribedSubredditData subredditData : newSubscribedSubreddits) {
newSubredditNames.add(subredditData.getQualified_name());
}
for (String subredditName : oldSubredditNames) {
if (!newSubredditNames.contains(subredditName)) {
unsubscribedSubredditNames.add(subredditName);
}
}
}

View File

@@ -15,7 +15,7 @@ import retrofit2.Retrofit;
public class LoadSubredditIcon {
public static void loadSubredditIcon(Executor executor, Handler handler, RedditDataRoomDatabase redditDataRoomDatabase,
String subredditName, String accessToken, Retrofit oauthRetrofit, Retrofit retrofit,
String subredditName, String accessToken, Retrofit retrofit,
LoadSubredditIconAsyncTaskListener loadSubredditIconAsyncTaskListener) {
executor.execute(() -> {
SubredditDao subredditDao = redditDataRoomDatabase.subredditDao();

View File

@@ -2,6 +2,7 @@ package eu.toldi.infinityforlemmy.asynctasks;
import android.content.SharedPreferences;
import android.os.Handler;
import android.util.Log;
import java.util.concurrent.Executor;
@@ -25,18 +26,31 @@ public class SwitchAccount {
.putString(SharedPreferencesUtils.ACCESS_TOKEN, account.getAccessToken())
.putString(SharedPreferencesUtils.ACCOUNT_NAME, account.getDisplay_name())
.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();
retrofitHolder.setBaseURL(account.getInstance_url());
retrofitHolder.setAccessToken(null);
FetchSiteInfo.fetchSiteInfo(retrofitHolder.getRetrofit(), account.getAccessToken(), new FetchSiteInfo.FetchSiteInfoListener() {
@Override
public void onFetchSiteInfoSuccess(SiteInfo siteInfo) {
boolean canDownvote = siteInfo.isEnable_downvotes();
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, canDownvote).apply();
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
public void onFetchSiteInfoFailed() {
Log.e("SwitchAccount", "Failed to fetch site info");
currentAccountSharedPreferences.edit().putBoolean(SharedPreferencesUtils.CAN_DOWNVOTE, true).apply();
}
});

View File

@@ -4,6 +4,7 @@ package eu.toldi.infinityforlemmy.bottomsheetfragments;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
@@ -23,6 +24,7 @@ import androidx.fragment.app.Fragment;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -37,6 +39,7 @@ import eu.toldi.infinityforlemmy.comment.Comment;
import eu.toldi.infinityforlemmy.comment.LemmyCommentAPI;
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
import eu.toldi.infinityforlemmy.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import eu.toldi.infinityforlemmy.utils.Utils;
@@ -72,8 +75,14 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
@Inject
CustomThemeWrapper mCustomThemeWrapper;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
private BaseActivity activity;
private boolean mShareLinksOnLocalInstance;
public CommentMoreBottomSheetFragment() {
// Required empty public constructor
}
@@ -103,6 +112,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN);
boolean editAndDeleteAvailable = bundle.getBoolean(EXTRA_EDIT_AND_DELETE_AVAILABLE, false);
boolean showReplyAndSaveOption = bundle.getBoolean(EXTRA_SHOW_REPLY_AND_SAVE_OPTION, false);
mShareLinksOnLocalInstance = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHARE_LINK_ON_LOCAL_INSTANCE, false);
if (accessToken != null && !accessToken.equals("")) {
@@ -167,13 +177,13 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
dismiss();
});
}
String link = (mShareLinksOnLocalInstance) ? lemmyCommentAPI.getRetrofitHolder().getBaseURL() + "/comment/" + comment.getId() : comment.getPermalink();
shareTextView.setOnClickListener(view -> {
dismiss();
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, comment.getPermalink());
intent.putExtra(Intent.EXTRA_TEXT, link);
activity.startActivity(Intent.createChooser(intent, getString(R.string.share)));
} catch (ActivityNotFoundException e) {
Toast.makeText(activity, R.string.no_activity_found_for_share, Toast.LENGTH_SHORT).show();
@@ -182,7 +192,7 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
shareTextView.setOnLongClickListener(view -> {
dismiss();
activity.copyLink(comment.getPermalink());
activity.copyLink(link);
return true;
});
@@ -201,6 +211,12 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
LayoutInflater dialog_inflater = LayoutInflater.from(activity);
View dialog_view = dialog_inflater.inflate(R.layout.dialog_report, null);
EditText reasonEditText = dialog_view.findViewById(R.id.reasonEditText);
reasonEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
reasonEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
reasonEditText.setTypeface(activity.typeface);
}
reasonEditText.setHighlightColor(mCustomThemeWrapper.getColorAccent());
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.report_post)

View File

@@ -124,6 +124,7 @@ import eu.toldi.infinityforlemmy.events.ShowThumbnailOnTheRightInCompactLayoutEv
import eu.toldi.infinityforlemmy.post.HistoryPostPagingSource;
import eu.toldi.infinityforlemmy.post.HistoryPostViewModel;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -178,9 +179,6 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
@Named("current_account")
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
@Named("post_layout")
SharedPreferences mPostLayoutSharedPreferences;
@Inject
@@ -198,6 +196,8 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
ExoCreator mExoCreator;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private RequestManager mGlide;
private BaseActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
@@ -383,7 +383,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
mAdapter = new HistoryPostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences,
mExoCreator, new HistoryPostRecyclerViewAdapter.Callback() {
@Override
public void typeChipClicked(int filter) {
@@ -654,15 +654,10 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
}
private void initializeAndBindPostViewModel(String accessToken) {
if (postType == HistoryPostPagingSource.TYPE_READ_POSTS) {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
} else {
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter)).get(HistoryPostViewModel.class);
}
mHistoryPostViewModel = new ViewModelProvider(HistoryPostFragment.this, new HistoryPostViewModel.Factory(mExecutor,
accessToken == null ? mRetrofit.getRetrofit() : mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
accountName, mSharedPreferences, HistoryPostPagingSource.TYPE_READ_POSTS, postFilter, postEnricher))
.get(HistoryPostViewModel.class);
bindPostViewModel();
}
@@ -933,7 +928,7 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
subredditOrUserName, accessToken, mOauthRetrofit, mRetrofit.getRetrofit(),
subredditOrUserName, accessToken, mRetrofit.getRetrofit(),
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
@@ -1447,4 +1442,4 @@ public class HistoryPostFragment extends Fragment implements FragmentCommunicato
public interface LoadIconListener {
void loadIconSuccess(String subredditOrUserName, String iconUrl);
}
}
}

View File

@@ -135,6 +135,7 @@ import eu.toldi.infinityforlemmy.events.ShowThumbnailOnTheRightInCompactLayoutEv
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.PostPagingSource;
import eu.toldi.infinityforlemmy.post.PostViewModel;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -222,6 +223,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
ExoCreator mExoCreator;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private RequestManager mGlide;
private BaseActivity activity;
private LinearLayoutManagerBugFixed mLinearLayoutManager;
@@ -465,7 +468,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st,sortTime != null ? SortType.Time.valueOf(sortTime) : null);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -533,16 +536,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName,
mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
}
sortType = newSortType(sort, sortTime);
boolean displaySubredditName = subredditName != null && (subredditName.equals("local") || subredditName.equals("all"));
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
if (sortTime != null) {
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -604,16 +605,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
defaultPostLayout);
if (sortTime != null) {
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -669,16 +668,17 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TYPE, SortType.Type.NEW.name()));
String sortTime = null;
if (sort.equalsIgnoreCase(SortType.Type.TOP.value)) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
sortType = new SortType(SortType.Type.fromValue(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -732,16 +732,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
subredditName = getArguments().getString(EXTRA_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -792,16 +791,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = multiRedditPath;
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Type.HOT.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -850,15 +848,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
nameOfUsage = PostFilterUsage.NO_USAGE;
subredditName = getArguments().getString(EXTRA_NAME);
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.ACTIVE.name());
String sortTime = null;
if (sort.equals(SortType.Type.TOP.name())) {
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name());
}
sortType = newSortType(sort, sortTime);
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit.getRetrofit(), mGfycatRetrofit,
mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mCustomThemeWrapper, locale,
accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@@ -1206,30 +1203,36 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mRetrofit, accessToken,
accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, mPostHistorySharedPreferences, subredditName,
query, trendingSource, postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
query, trendingSource, postType, sortType, postFilter, readPosts, postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, subredditName, postType, sortType, postFilter, readPosts))
mPostHistorySharedPreferences, subredditName, postType, sortType, postFilter, readPosts,
postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, multiRedditPath, postType, sortType, postFilter, readPosts))
mPostHistorySharedPreferences, multiRedditPath, postType, sortType, postFilter, readPosts,
postEnricher))
.get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts))
mPostHistorySharedPreferences, username, postType, sortType, postFilter, where, readPosts,
postEnricher))
.get(PostViewModel.class);
} else {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, accessToken,
accountName, mSharedPreferences, mPostFeedScrolledPositionSharedPreferences,
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts, subredditName)).get(PostViewModel.class);
mPostHistorySharedPreferences, postType, sortType, postFilter, readPosts, subredditName,
postEnricher))
.get(PostViewModel.class);
}
bindPostViewModel();
@@ -1241,26 +1244,27 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, subredditName, query, trendingSource,
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
postType, sortType, postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT) {
mPostViewModel = new ViewModelProvider(this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, subredditName, postType, sortType,
postFilter, readPosts)).get(PostViewModel.class);
postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_MULTI_REDDIT) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, multiRedditPath,
postType, sortType, postFilter, readPosts)).get(PostViewModel.class);
postType, sortType, postFilter, readPosts, postEnricher)).get(PostViewModel.class);
} else if (postType == PostPagingSource.TYPE_USER) {
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, null, accountName, mSharedPreferences,
mPostFeedScrolledPositionSharedPreferences, null, username, postType, sortType, postFilter,
where, readPosts)).get(PostViewModel.class);
where, readPosts, postEnricher)).get(PostViewModel.class);
} else {
//Anonymous Front Page
mPostViewModel = new ViewModelProvider(PostFragment.this, new PostViewModel.Factory(mExecutor,
mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter, subredditName))
mRetrofit, mSharedPreferences, concatenatedSubredditNames, postType, sortType, postFilter, subredditName,
postEnricher))
.get(PostViewModel.class);
}
@@ -1364,25 +1368,25 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) {
switch (postType) {
case PostPagingSource.TYPE_FRONT_PAGE:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_BEST_POST, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_SUBREDDIT:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_USER:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_SEARCH:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
}else {
@@ -1392,14 +1396,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
sortType.getType().name()).apply();
sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath,
sortType.getTime().name()).apply();
}
break;
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().name()).apply();
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().value).apply();
if (sortType.getTime() != null) {
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", sortType.getTime().name()).apply();
}
@@ -1750,7 +1754,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} else {
if (isSubreddit) {
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase,
subredditOrUserName, accessToken, mRetrofit.getRetrofit(), mRetrofit.getRetrofit(),
subredditOrUserName, accessToken, mRetrofit.getRetrofit(),
iconImageUrl -> {
subredditOrUserIcons.put(subredditOrUserName, iconImageUrl);
loadIconListener.loadIconSuccess(subredditOrUserName, iconImageUrl);
@@ -2238,6 +2242,24 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
}
public SortType newSortType(String sortTypeText, String sortTimeText) {
SortType.Type st = SortType.Type.fromValue(sortTypeText);
st = st == null ? SortType.Type.NEW : st;
SortType result;
if (sortTypeText.startsWith("Top")) {
sortTimeText = st.value.substring(3);
result = new SortType(st, SortType.Time.fromValue(sortTimeText));
} else if (sortTimeText != null) {
SortType.Time sortTime = SortType.Time.fromValue(sortTimeText);
SortType.Type sortType = SortType.Type.fromValue("Top" + sortTimeText);
result = new SortType(sortType != null ? sortType : st, sortTime);
} else {
result = new SortType(st);
}
return result;
}
private static abstract class LazyModeRunnable implements Runnable {
private int currentPosition = -1;

View File

@@ -112,6 +112,7 @@ import eu.toldi.infinityforlemmy.post.HidePost;
import eu.toldi.infinityforlemmy.post.LemmyPostAPI;
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
@@ -200,6 +201,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
MarkPostAsRead markPostAsRead;
@Inject
LemmyPostAPI mLemmyPostAPI;
@Inject
PostEnricher postEnricher;
@State
Post mPost;
@State
@@ -324,7 +327,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mLockFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mSwipeUpToHideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON, false);
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountQualifiedName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
if (savedInstanceState == null) {
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
viewPostDetailFragmentId = System.currentTimeMillis();
@@ -614,7 +617,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
setupMenu();
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
this, mExecutor, mCustomThemeWrapper, mRetrofit.getRetrofit(), mGfycatRetrofit,
this, mExecutor, mCustomThemeWrapper, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide,
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
@@ -1155,10 +1158,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
.show();
return true;
} else if (itemId == R.id.action_report_view_post_detail_fragment) {
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
}
if (mAccessToken == null) {
Toast.makeText(activity, R.string.login_first, Toast.LENGTH_SHORT).show();
return true;
@@ -1166,7 +1165,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
LayoutInflater inflater = LayoutInflater.from(activity);
View view = inflater.inflate(R.layout.dialog_report, null);
EditText reasonEditText = view.findViewById(R.id.reasonEditText);
reasonEditText.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
reasonEditText.setHintTextColor(mCustomThemeWrapper.getSecondaryTextColor());
if (activity.typeface != null) {
reasonEditText.setTypeface(activity.typeface);
}
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.report_post)
.setView(view)
@@ -1329,7 +1332,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mSwipeRefreshLayout.setRefreshing(true);
mGlide.clear(mFetchPostInfoImageView);
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), String.valueOf(subredditId), mAccessToken,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (!isAdded()) {
@@ -1338,7 +1341,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
mPost = post;
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
mRetrofit.getRetrofit(), mGfycatRetrofit, mRedgifsRetrofit,
mRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
@@ -1588,7 +1591,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
Retrofit retrofit = mRetrofit.getRetrofit();
FetchPost.fetchPost(mExecutor, new Handler(), retrofit, String.valueOf(mPost.getId()), mAccessToken,
new FetchPost.FetchPostListener() {
postEnricher, new FetchPost.FetchPostListener() {
@Override
public void fetchPostSuccess(Post post) {
if (isAdded()) {

View File

@@ -52,6 +52,7 @@ import java.io.File;
import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -69,6 +70,7 @@ import eu.toldi.infinityforlemmy.bottomsheetfragments.UrlMenuBottomSheetFragment
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.services.DownloadMediaService;
import eu.toldi.infinityforlemmy.utils.Utils;
import okhttp3.OkHttpClient;
public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@@ -105,6 +107,9 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
ImageView wallpaperImageView;
@Inject
Executor mExecutor;
@Inject
@Named("glide")
OkHttpClient okHttpClient;
private ViewRedditGalleryActivity activity;
private RequestManager glide;
@@ -122,7 +127,7 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext()));
BigImageViewer.initialize(GlideImageLoader.with(activity.getApplicationContext(), okHttpClient));
View rootView = inflater.inflate(R.layout.fragment_view_reddit_gallery_image_or_gif, container, false);

View File

@@ -8,6 +8,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -15,7 +16,7 @@ import retrofit2.Retrofit;
public class FetchPost {
public static void fetchPost(Executor executor, Handler handler, Retrofit retrofit, String id, String accessToken,
FetchPostListener fetchPostListener) {
PostEnricher postEnricher, FetchPostListener fetchPostListener) {
Call<String> postCall;
// Use LemmyAPI.postInfo() instead of RedditAPI.getPost()
postCall = retrofit.create(LemmyAPI.class).postInfo(Integer.parseInt(id), null, accessToken);
@@ -24,7 +25,7 @@ public class FetchPost {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
ParsePost.parsePost(executor, handler, response.body(), new ParsePost.ParsePostListener() {
ParsePost.parsePost(executor, handler, postEnricher, response.body(), new ParsePost.ParsePostListener() {
@Override
public void onParsePostSuccess(Post post) {
fetchPostListener.fetchPostSuccess(post);

View File

@@ -19,6 +19,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.apis.RedditAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.readpost.ReadPost;
import eu.toldi.infinityforlemmy.utils.APIUtils;
@@ -39,10 +40,11 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
private String username;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
public HistoryPostPagingSource(Retrofit retrofit, Executor executor, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences,
String username, int postType, PostFilter postFilter) {
String username, int postType, PostFilter postFilter, PostEnricher postEnricher) {
this.retrofit = retrofit;
this.executor = executor;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -52,6 +54,7 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
this.username = username;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
}
@Nullable
@@ -92,7 +95,7 @@ public class HistoryPostPagingSource extends ListenableFuturePagingSource<String
Response<String> response = historyPosts.execute();
if (response.isSuccessful()) {
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) {
return new LoadResult.Error<>(new Exception("Error parsing posts"));
} else {

View File

@@ -17,6 +17,7 @@ import androidx.paging.PagingLiveData;
import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import retrofit2.Retrofit;
@@ -29,6 +30,7 @@ public class HistoryPostViewModel extends ViewModel {
private SharedPreferences sharedPreferences;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
private LiveData<PagingData<Post>> posts;
@@ -36,7 +38,7 @@ public class HistoryPostViewModel extends ViewModel {
public HistoryPostViewModel(Executor executor, Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences,
int postType, PostFilter postFilter) {
int postType, PostFilter postFilter, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -45,11 +47,12 @@ public class HistoryPostViewModel extends ViewModel {
this.sharedPreferences = sharedPreferences;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
postFilterLiveData = new MutableLiveData<>();
postFilterLiveData.postValue(postFilter);
Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce);
Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSource);
posts = Transformations.switchMap(postFilterLiveData, postFilterValue -> PagingLiveData.cachedIn(PagingLiveData.getLiveData(pager), ViewModelKt.getViewModelScope(this)));
}
@@ -58,19 +61,9 @@ public class HistoryPostViewModel extends ViewModel {
return posts;
}
public HistoryPostPagingSource returnPagingSoruce() {
HistoryPostPagingSource paging3PagingSource;
switch (postType) {
case HistoryPostPagingSource.TYPE_READ_POSTS:
paging3PagingSource = new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter);
break;
default:
paging3PagingSource = new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter);
break;
}
return paging3PagingSource;
public HistoryPostPagingSource returnPagingSource() {
return new HistoryPostPagingSource(retrofit, executor, redditDataRoomDatabase, accessToken, accountName,
sharedPreferences, accountName, postType, postFilter, postEnricher);
}
public void changePostFilter(PostFilter postFilter) {
@@ -86,10 +79,11 @@ public class HistoryPostViewModel extends ViewModel {
private SharedPreferences sharedPreferences;
private int postType;
private PostFilter postFilter;
private PostEnricher postEnricher;
public Factory(Executor executor, Retrofit retrofit, RedditDataRoomDatabase redditDataRoomDatabase,
String accessToken, String accountName, SharedPreferences sharedPreferences, int postType,
PostFilter postFilter) {
PostFilter postFilter, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.redditDataRoomDatabase = redditDataRoomDatabase;
@@ -98,18 +92,14 @@ public class HistoryPostViewModel extends ViewModel {
this.sharedPreferences = sharedPreferences;
this.postType = postType;
this.postFilter = postFilter;
this.postEnricher = postEnricher;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
if (postType == HistoryPostPagingSource.TYPE_READ_POSTS) {
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter);
} else {
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter);
}
return (T) new HistoryPostViewModel(executor, retrofit, redditDataRoomDatabase, accessToken, accountName, sharedPreferences,
postType, postFilter, postEnricher);
}
}
}

View File

@@ -34,6 +34,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import eu.toldi.infinityforlemmy.community.BasicCommunityInfo;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.user.BasicUserInfo;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
@@ -45,7 +46,8 @@ import eu.toldi.infinityforlemmy.utils.Utils;
*/
public class ParsePost {
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter, List<String> readPostList) {
public static LinkedHashSet<Post> parsePostsSync(String response, int nPosts, PostFilter postFilter,
List<String> readPostList, PostEnricher postEnricher) {
LinkedHashSet<Post> newPosts = new LinkedHashSet<>();
try {
JSONObject jsonResponse = new JSONObject(response);
@@ -80,6 +82,8 @@ public class ParsePost {
}
}
postEnricher.enrich(newPosts);
return newPosts;
} catch (JSONException e) {
e.printStackTrace();
@@ -87,21 +91,9 @@ public class ParsePost {
}
}
public static String getLastItem(String response) {
try {
JSONObject object = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY);
return object.isNull(JSONUtils.AFTER_KEY) ? null : object.getString(JSONUtils.AFTER_KEY);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
public static void parsePost(Executor executor, Handler handler, String response, ParsePostListener parsePostListener) {
PostFilter postFilter = new PostFilter();
postFilter.allowNSFW = true;
public static void parsePost(Executor executor, Handler handler, PostEnricher postEnricher,
String response, ParsePostListener parsePostListener) {
executor.execute(() -> {
try {
JSONObject allData = new JSONObject(response).getJSONObject("post_view");
@@ -111,6 +103,7 @@ public class ParsePost {
}
Post post = parseBasicData(allData);
postEnricher.enrich(List.of(post));
handler.post(() -> parsePostListener.onParsePostSuccess(post));
} catch (JSONException e) {
e.printStackTrace();
@@ -188,7 +181,7 @@ public class ParsePost {
boolean nsfw = post.getBoolean("nsfw");
boolean locked = post.getBoolean("locked");
boolean saved = data.getBoolean("saved");
String distinguished = (creator.getBoolean("admin") ? "admin" : "");
String distinguished = creator.optBoolean("admin") ? "admin" : "";
String suggestedSort = "";
ArrayList<Post.Preview> previews = new ArrayList<>();
if (!post.isNull("thumbnail_url")) {

View File

@@ -21,6 +21,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
import retrofit2.HttpException;
@@ -57,6 +58,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private List<String> readPostList;
private String userWhere;
private String multiRedditPath;
private final PostEnricher postEnricher;
private LinkedHashSet<Post> postLinkedHashSet;
private int page = 1;
@@ -64,7 +66,8 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences,
SharedPreferences postFeedScrolledPositionSharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
SortType sortType, PostFilter postFilter, List<String> readPostList, String option,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -76,13 +79,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.sortType = sortType == null ? new SortType(SortType.Type.ACTIVE) : sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String path, int postType, SortType sortType, PostFilter postFilter,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -114,13 +118,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
}
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, int postType, SortType sortType, PostFilter postFilter,
String where, List<String> readPostList) {
String where, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -133,13 +138,14 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.postFilter = postFilter;
userWhere = where;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
PostPagingSource(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
String subredditOrUserName, String query, String trendingSource, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList) {
SortType sortType, PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -152,8 +158,9 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
this.postType = postType;
this.sortType = sortType == null ? new SortType(SortType.Type.TOP) : sortType;
this.postFilter = postFilter;
postLinkedHashSet = new LinkedHashSet<>();
this.readPostList = readPostList;
this.postEnricher = postEnricher;
postLinkedHashSet = new LinkedHashSet<>();
}
@Nullable
@@ -190,7 +197,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
public LoadResult<Integer, Post> transformData(Response<String> response) {
if (response.isSuccessful()) {
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) {
return new LoadResult.Error<>(new Exception("Error parsing posts"));
@@ -236,7 +243,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
}
String feed_type = Objects.equals(subredditOrUserName, "all") ? "All" : Objects.equals(subredditOrUserName, "local") ? "Local" : "Subscribed";
bestPost = api.getPosts(feed_type,sortType.getType().value,page,25,null,null,false,accessToken);
bestPost = api.getPostsListenableFuture(feed_type, sortType.getType().value, page, 25, null, null, false, accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(bestPost, this::transformData, executor);
@@ -251,7 +258,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private ListenableFuture<LoadResult<Integer, Post>> loadSubredditPosts(@NonNull LoadParams<Integer> loadParams, LemmyAPI api) {
ListenableFuture<Response<String>> subredditPost;
subredditPost = api.getPosts(null,sortType.getType().value,loadParams.getKey(),25,null,subredditOrUserName,false,accessToken);
subredditPost = api.getPostsListenableFuture(null, sortType.getType().value, loadParams.getKey(), 25, null, subredditOrUserName, false, accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(subredditPost, this::transformData, executor);
@@ -266,7 +273,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
private ListenableFuture<LoadResult<Integer, Post>> loadUserPosts(@NonNull LoadParams<Integer> loadParams, LemmyAPI api) {
ListenableFuture<Response<String>> userPosts;
userPosts = api.getUserPosts(subredditOrUserName, sortType.getType().value, loadParams.getKey(), 25, userWhere.equals(USER_WHERE_SAVED), accessToken);
userPosts = api.getUserPostsListenableFuture(subredditOrUserName, sortType.getType().value, loadParams.getKey(), 25, userWhere.equals(USER_WHERE_SAVED), accessToken);
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(userPosts, this::transformData, executor);

View File

@@ -23,6 +23,7 @@ import java.util.concurrent.Executor;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.SortType;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
@@ -41,6 +42,7 @@ public class PostViewModel extends ViewModel {
private PostFilter postFilter;
private String userWhere;
private List<String> readPostList;
private PostEnricher postEnricher;
private MutableLiveData<Boolean> currentlyReadPostIdsLiveData = new MutableLiveData<>();
private LiveData<PagingData<Post>> posts;
@@ -53,7 +55,7 @@ public class PostViewModel extends ViewModel {
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList, String option) {
SortType sortType, PostFilter postFilter, List<String> readPostList, String option, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -65,6 +67,7 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = option;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -95,7 +98,7 @@ public class PostViewModel extends ViewModel {
public PostViewModel(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, int postType,
SortType sortType, PostFilter postFilter, List<String> readPostList) {
SortType sortType, PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -107,6 +110,7 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = subredditName;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -139,7 +143,7 @@ public class PostViewModel extends ViewModel {
SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String username,
int postType, SortType sortType, PostFilter postFilter, String userWhere,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -152,6 +156,7 @@ public class PostViewModel extends ViewModel {
this.readPostList = readPostList;
this.name = username;
this.userWhere = userWhere;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -183,7 +188,7 @@ public class PostViewModel extends ViewModel {
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
@Nullable SharedPreferences postHistorySharedPreferences, String subredditName, String query,
String trendingSource, int postType, SortType sortType, PostFilter postFilter,
List<String> readPostList) {
List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -197,6 +202,7 @@ public class PostViewModel extends ViewModel {
this.name = subredditName;
this.query = query;
this.trendingSource = trendingSource;
this.postEnricher = postEnricher;
sortTypeLiveData = new MutableLiveData<>();
sortTypeLiveData.postValue(sortType);
@@ -238,25 +244,25 @@ public class PostViewModel extends ViewModel {
case PostPagingSource.TYPE_FRONT_PAGE:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, postType, sortType,
postFilter, readPostList,name);
postFilter, readPostList, name, postEnricher);
break;
case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, readPostList);
sortType, postFilter, readPostList, postEnricher);
break;
case PostPagingSource.TYPE_SEARCH:
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, query, trendingSource,
postType, sortType, postFilter, readPostList);
postType, sortType, postFilter, readPostList, postEnricher);
break;
default:
//User
paging3PagingSource = new PostPagingSource(executor, retrofit, accessToken, accountName,
sharedPreferences, postFeedScrolledPositionSharedPreferences, name, postType,
sortType, postFilter, userWhere, readPostList);
sortType, postFilter, userWhere, readPostList, postEnricher);
break;
}
return paging3PagingSource;
@@ -291,11 +297,12 @@ public class PostViewModel extends ViewModel {
private PostFilter postFilter;
private String userWhere;
private List<String> readPostList;
private PostEnricher postEnricher;
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, int postType, SortType sortType,
PostFilter postFilter, List<String> readPostList, String option) {
PostFilter postFilter, List<String> readPostList, String option, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -308,12 +315,13 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
this.readPostList = readPostList;
this.name = option;
this.postEnricher = postEnricher;
}
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String name, int postType, SortType sortType,
PostFilter postFilter, List<String> readPostList) {
PostFilter postFilter, List<String> readPostList, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -326,13 +334,15 @@ public class PostViewModel extends ViewModel {
this.sortType = sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
//User posts
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String username, int postType,
SortType sortType, PostFilter postFilter, String where, List<String> readPostList) {
SortType sortType, PostFilter postFilter, String where, List<String> readPostList,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -346,12 +356,14 @@ public class PostViewModel extends ViewModel {
this.postFilter = postFilter;
userWhere = where;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
public Factory(Executor executor, RetrofitHolder retrofit, String accessToken, String accountName,
SharedPreferences sharedPreferences, SharedPreferences postFeedScrolledPositionSharedPreferences,
SharedPreferences postHistorySharedPreferences, String name, String query, String trendingSource,
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList) {
int postType, SortType sortType, PostFilter postFilter, List<String> readPostList,
PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.accessToken = accessToken;
@@ -366,19 +378,23 @@ public class PostViewModel extends ViewModel {
this.sortType = sortType;
this.postFilter = postFilter;
this.readPostList = readPostList;
this.postEnricher = postEnricher;
}
//Anonymous Front Page
public Factory(Executor executor, RetrofitHolder retrofit, SharedPreferences sharedPreferences,
String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter, String opt) {
String concatenatedSubredditNames, int postType, SortType sortType, PostFilter postFilter,
String opt, PostEnricher postEnricher) {
this.executor = executor;
this.retrofit = retrofit;
this.sharedPreferences = sharedPreferences;
// TODO is this used? because it is getting overwritten with opt
this.name = concatenatedSubredditNames;
this.postType = postType;
this.sortType = sortType;
this.postFilter = postFilter;
this.name = opt;
this.postEnricher = postEnricher;
}
@NonNull
@@ -387,23 +403,23 @@ public class PostViewModel extends ViewModel {
if (postType == PostPagingSource.TYPE_FRONT_PAGE) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, postType,
sortType, postFilter, readPostList,name);
sortType, postFilter, readPostList,name, postEnricher);
} else if (postType == PostPagingSource.TYPE_SEARCH) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name, query,
trendingSource, postType, sortType, postFilter, readPostList);
trendingSource, postType, sortType, postFilter, readPostList, postEnricher);
} else if (postType == PostPagingSource.TYPE_SUBREDDIT || postType == PostPagingSource.TYPE_MULTI_REDDIT) {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name,
postType, sortType, postFilter, readPostList);
postType, sortType, postFilter, readPostList, postEnricher);
} else if (postType == PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE) {
return (T) new PostViewModel(executor, retrofit, null, null, sharedPreferences,
null, null, name, postType, sortType,
postFilter, null);
postFilter, null, postEnricher);
} else {
return (T) new PostViewModel(executor, retrofit, accessToken, accountName, sharedPreferences,
postFeedScrolledPositionSharedPreferences, postHistorySharedPreferences, name,
postType, sortType, postFilter, userWhere, readPostList);
postType, sortType, postFilter, userWhere, readPostList, postEnricher);
}
}
}

View File

@@ -15,6 +15,7 @@ import eu.toldi.infinityforlemmy.Flair;
import eu.toldi.infinityforlemmy.RetrofitHolder;
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
import retrofit2.Call;
@@ -25,22 +26,24 @@ public class SubmitPost {
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String body, String url,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, body,
isNSFW, receivePostReplyNotifications, kind, url, submitPostListener);
isNSFW, receivePostReplyNotifications, kind, url, postEnricher, submitPostListener);
}
public static void submitImagePost(Executor executor, Handler handler, RetrofitHolder mRetrofit,
String accessToken, int communityId, String title, String body, Bitmap image,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
boolean receivePostReplyNotifications, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
try {
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, accessToken, image);
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
submitPost(executor, handler, mRetrofit.getRetrofit(), accessToken,
communityId, title, body, isNSFW,
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError, submitPostListener);
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError,
postEnricher, submitPostListener);
} else {
submitPostListener.submitFailed(imageUrlOrError);
}
@@ -53,17 +56,18 @@ public class SubmitPost {
public static void submitCrosspost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String crosspostFullname,
Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
isNSFW, receivePostReplyNotifications, kind, null, postEnricher, submitPostListener);
}
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
int communityId, String title, String content,
boolean isNSFW,
boolean receivePostReplyNotifications, String kind,
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
@Nullable String posterUrl, PostEnricher postEnricher,
SubmitPostListener submitPostListener) {
LemmyAPI api = oauthRetrofit.create(LemmyAPI.class);
@@ -73,7 +77,7 @@ public class SubmitPost {
Response<String> response = submitPostCall.execute();
if (response.isSuccessful()) {
getSubmittedPost(executor, handler, response.body(), kind, oauthRetrofit, accessToken,
submitPostListener);
postEnricher, submitPostListener);
} else {
submitPostListener.submitFailed(response.message());
}
@@ -84,10 +88,10 @@ public class SubmitPost {
}
private static void getSubmittedPost(Executor executor, Handler handler, String response, String kind,
Retrofit oauthRetrofit, String accessToken,
Retrofit oauthRetrofit, String accessToken, PostEnricher postEnricher,
SubmitPostListener submitPostListener) throws JSONException, IOException {
ParsePost.parsePost(executor, handler, response, new ParsePost.ParsePostListener() {
ParsePost.parsePost(executor, handler, postEnricher, response, new ParsePost.ParsePostListener() {
@Override
public void onParsePostSuccess(Post post) {
submitPostListener.submitSuccessful(post);

View File

@@ -153,7 +153,7 @@ public class DownloadMediaService extends Service {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
File directory = getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
if (directory != null) {
String directoryPath = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? directory.getAbsolutePath() + "/Infinity/" + subredditName + "/" : directory.getAbsolutePath() + "/Infinity/";
String directoryPath = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? directory.getAbsolutePath() + "/Eternity/" + subredditName + "/" : directory.getAbsolutePath() + "/Eternity/";
File infinityDir = new File(directoryPath);
if (!infinityDir.exists() && !infinityDir.mkdirs()) {
downloadFinished(mediaType, randomNotificationIdOffset, mimeType,
@@ -168,7 +168,7 @@ public class DownloadMediaService extends Service {
}
} else {
String dir = mediaType == EXTRA_MEDIA_TYPE_VIDEO ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES;
destinationFileUriString = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? dir + "/Infinity/" + subredditName + "/" : dir + "/Infinity/";
destinationFileUriString = separateDownloadFolder && subredditName != null && !subredditName.equals("") ? dir + "/Eternity/" + subredditName + "/" : dir + "/Eternity/";
}
isDefaultDestination = true;
} else {

View File

@@ -54,6 +54,7 @@ import eu.toldi.infinityforlemmy.events.SubmitPollPostEvent;
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
import eu.toldi.infinityforlemmy.post.Post;
import eu.toldi.infinityforlemmy.post.SubmitPost;
import eu.toldi.infinityforlemmy.post.enrich.PostEnricher;
import eu.toldi.infinityforlemmy.utils.APIUtils;
import eu.toldi.infinityforlemmy.utils.JSONUtils;
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
@@ -102,6 +103,8 @@ public class SubmitPostService extends Service {
CustomThemeWrapper mCustomThemeWrapper;
@Inject
Executor mExecutor;
@Inject
PostEnricher postEnricher;
private Handler handler;
private ServiceHandler serviceHandler;
@@ -221,7 +224,7 @@ public class SubmitPostService extends Service {
String kind) {
SubmitPost.submitTextOrLinkPost(mExecutor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(),
communityId, title, body, url, flair, isSpoiler,
isNSFW, receivePostReplyNotifications, kind, new SubmitPost.SubmitPostListener() {
isNSFW, receivePostReplyNotifications, kind, postEnricher, new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {
handler.post(() -> EventBus.getDefault().post(new SubmitTextOrLinkPostEvent(true, post, null)));
@@ -243,7 +246,7 @@ public class SubmitPostService extends Service {
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications) {
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), communityId, title,
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST,
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST, postEnricher,
new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {
@@ -266,7 +269,8 @@ public class SubmitPostService extends Service {
try {
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
SubmitPost.submitImagePost(mExecutor, handler, newAuthenticatorOauthRetrofit,
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler,
isNSFW, receivePostReplyNotifications, postEnricher,
new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {

View File

@@ -20,13 +20,16 @@ public class SiteInfo {
private boolean enable_nsfw;
private boolean community_creation_admin_only;
private String version;
private List<BasicUserInfo> admins;
SiteStatistics siteStatistics;
public SiteInfo(int id, String name, String sidebar, String description, boolean enable_downvotes, boolean enable_nsfw, boolean community_creation_admin_only, List<BasicUserInfo> admins, SiteStatistics siteStatistics) {
public SiteInfo(int id, String name, String version, String sidebar, String description, boolean enable_downvotes, boolean enable_nsfw, boolean community_creation_admin_only, List<BasicUserInfo> admins, SiteStatistics siteStatistics) {
this.id = id;
this.name = name;
this.version = version;
this.sidebar = sidebar;
this.description = description;
this.enable_downvotes = enable_downvotes;
@@ -72,6 +75,10 @@ public class SiteInfo {
return siteStatistics;
}
public String getVersion() {
return version;
}
public static SiteInfo parseSiteInfo(String siteInfoJson) {
try {
JSONObject siteInfo = new JSONObject(siteInfoJson);
@@ -84,6 +91,7 @@ public class SiteInfo {
String sidebar = null;
if (site.has("sidebar"))
sidebar = site.getString("sidebar");
String version = siteInfo.getString("version");
String description = null;
if (site.has("description"))
@@ -106,7 +114,7 @@ public class SiteInfo {
}
}
return new SiteInfo(id, name, sidebar, description, enable_downvotes, enable_nsfw, community_creation_admin_only, admins, SiteStatistics.parseSiteStatistics(counts));
return new SiteInfo(id, name, version, sidebar, description, enable_downvotes, enable_nsfw, community_creation_admin_only, admins, SiteStatistics.parseSiteStatistics(counts));
} catch (JSONException e) {
e.printStackTrace();
return null;

View File

@@ -31,7 +31,7 @@ public interface SubscribedSubredditDao {
@Query("SELECT * from subscribed_subreddits WHERE qualified_name = :qualified_name COLLATE NOCASE AND username = :accountName COLLATE NOCASE LIMIT 1")
SubscribedSubredditData getSubscribedSubredditByQualifiedName(String qualified_name, String accountName);
@Query("DELETE FROM subscribed_subreddits WHERE name = :subredditName COLLATE NOCASE AND username = :accountName COLLATE NOCASE")
@Query("DELETE FROM subscribed_subreddits WHERE qualified_name = :subredditName COLLATE NOCASE AND username = :accountName COLLATE NOCASE")
void deleteSubscribedSubreddit(String subredditName, String accountName);
@Query("SELECT * from subscribed_subreddits WHERE username = :qualified_name AND name LIKE '%' || :searchQuery || '%' COLLATE NOCASE AND is_favorite = 1 ORDER BY name COLLATE NOCASE ASC")

View File

@@ -129,13 +129,13 @@ public class SubscribedSubredditData implements Parcelable {
@Override
public int hashCode() {
return id;
return id + username.hashCode();
}
@Override
public boolean equals(@Nullable Object obj) {
if (obj instanceof SubscribedSubredditData) {
return id == ((SubscribedSubredditData) obj).getId();
return id == ((SubscribedSubredditData) obj).getId() && username.equalsIgnoreCase(((SubscribedSubredditData) obj).getUsername());
}
return false;
}

View File

@@ -48,7 +48,7 @@ public class ParseUserData {
boolean isBot = personJson.getBoolean("bot_account");
boolean isBanned = personJson.getBoolean("banned");
boolean isLocal = personJson.getBoolean("local");
boolean isAdmin = personJson.getBoolean("admin");
boolean isAdmin = personJson.optBoolean("admin");
boolean isDeleted = personJson.getBoolean("deleted");
String description = "";

View File

@@ -5,7 +5,9 @@ import android.util.Base64;
import java.util.HashMap;
import java.util.Map;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
/**
@@ -142,12 +144,6 @@ public class APIUtils {
return params;
}
public static Map<String, String> getRedgifsOAuthHeader(String redgifsAccessToken) {
Map<String, String> params = new HashMap<>();
params.put(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + redgifsAccessToken);
return params;
}
public static RequestBody getRequestBody(String s) {
return RequestBody.create(s, MediaType.parse("text/plain"));
}
@@ -159,4 +155,13 @@ public class APIUtils {
params.put(APIUtils.USER_AGENT_KEY, APIUtils.USER_AGENT);
return params;
}
public static Interceptor getOAuthInterceptor(String accessToken) {
return chain -> {
Request newRequest = chain.request().newBuilder()
.addHeader("Authorization", "Bearer " + accessToken)
.build();
return chain.proceed(newRequest);
};
}
}

View File

@@ -126,6 +126,7 @@ public class JSONUtils {
public static final String Y_KEY = "y";
public static final String DEST_KEY = "dest";
public static final String GIF_KEY = "gif";
public static final String GIFS_KEY = "gifs";
public static final String MAX_EMOJIS_KEY = "max_emojis";
public static final String RICHTEXT_KEY = "richtext";
public static final String SUGGESTED_COMMENT_SORT_KEY = "suggested_comment_sort";

View File

@@ -359,6 +359,8 @@ public class SharedPreferencesUtils {
public static final String CURRENT_ACCOUNT_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.current_account";
public static final String ACCOUNT_NAME = "account_name";
public static final String ACCESS_TOKEN = "access_token";
public static final String BEARER_TOKEN_AUTH = "bearer_token_auth";
public static final String ACCOUNT_IMAGE_URL = "account_image_url";
public static final String REDGIFS_ACCESS_TOKEN = "redgifs_access_token";
@@ -416,4 +418,6 @@ public class SharedPreferencesUtils {
public static final String CAN_DOWNVOTE = "can_downvote";
public static final String SHOW_STATISTICS = "show_statistics";
public static final String SHOW_POST_AND_COMMENT_SCORE = "show_score";
public static final String SHARE_LINK_ON_LOCAL_INSTANCE = "share_link_on_local_instance";
}

View File

@@ -0,0 +1,11 @@
package eu.toldi.infinityforlemmy.post.enrich
import eu.toldi.infinityforlemmy.post.Post
class CompositePostEnricher(private val enrichers: Set<PostEnricher>) : PostEnricher {
override fun enrich(posts: Collection<Post>) {
for (enricher in enrichers) {
enricher.enrich(posts)
}
}
}

View File

@@ -0,0 +1,7 @@
package eu.toldi.infinityforlemmy.post.enrich
import eu.toldi.infinityforlemmy.post.Post
interface PostEnricher {
fun enrich(posts: Collection<Post>)
}

View File

@@ -0,0 +1,56 @@
package eu.toldi.infinityforlemmy.post.enrich
import android.util.Log
import eu.toldi.infinityforlemmy.apis.RedgifsAPI
import eu.toldi.infinityforlemmy.post.Post
import eu.toldi.infinityforlemmy.post.Post.Preview
import eu.toldi.infinityforlemmy.utils.JSONUtils
import org.json.JSONException
import org.json.JSONObject
import java.io.IOException
class RedGifsPostEnricher(private val redgifsAPI: RedgifsAPI) : PostEnricher {
override fun enrich(posts: Collection<Post>) {
val redGifsPosts = posts.filter { it.isRedgifs && it.previews.isEmpty() }
.groupBy { it.gfycatId }
if (redGifsPosts.isEmpty()) {
return
}
try {
val response = redgifsAPI.getRedgifsMultipleData(redGifsPosts.keys.joinToString(",")).execute()
val body = response.body()
if (response.isSuccessful && body != null) {
try {
val gifsJson = JSONObject(body).getJSONArray(JSONUtils.GIFS_KEY)
for (i in 0 until gifsJson.length()) {
val gifJson = gifsJson.getJSONObject(i)
val id = gifJson.getString(JSONUtils.ID_KEY)
val width = gifJson.getInt(JSONUtils.WIDTH_KEY)
val height = gifJson.getInt(JSONUtils.HEIGHT_KEY)
val thumbnail = gifJson.getJSONObject(JSONUtils.URLS_KEY)
.getString(JSONUtils.THUMBNAIL_KEY)
val previews = ArrayList(listOf(Preview(thumbnail, width, height, null, null)))
redGifsPosts[id]?.forEach {
it.previews = previews
}
}
} catch (e: JSONException) {
Log.w(TAG, "Failed to parse JSON", e)
}
} else {
Log.w(TAG, "Failed fetch data. Status code ${response.code()}")
}
} catch (e: IOException) {
Log.w(TAG, "Failed fetch data", e)
}
}
companion object {
private const val TAG = "RedGifsPostEnricher"
}
}

View File

@@ -26,67 +26,69 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:textSize="?attr/font_default"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_video_autoplay"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constrainedWidth="true" />
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/community_instance_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
app:layout_constraintStart_toEndOf="@+id/subreddit_text_view_item_post_detail_video_autoplay"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/user_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:textSize="?attr/font_default"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/author_flair_text_view_item_post_detail_video_autoplay"
app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_video_autoplay"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_video_autoplay"
app:layout_constraintHorizontal_bias="0"
app:layout_constrainedWidth="true" />
app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_video_autoplay" />
<TextView
android:id="@+id/user_instance_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/author_flair_text_view_item_post_detail_video_autoplay"
app:layout_constraintStart_toEndOf="@+id/user_text_view_item_post_detail_video_autoplay"
app:layout_constraintTop_toBottomOf="@+id/subreddit_text_view_item_post_detail_video_autoplay" />
<TextView
android:id="@+id/author_flair_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_12"
android:visibility="gone"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_detail_video_autoplay"
app:layout_constraintEnd_toStartOf="@id/guideline"
app:layout_constraintTop_toBottomOf="@+id/user_text_view_item_post_detail_video_autoplay"
app:layout_constraintHorizontal_bias="0"
app:layout_constrainedWidth="true"
tools:visibility="visible" />
<TextView
android:id="@+id/post_time_text_view_item_post_detail_video_autoplay"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.6" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
@@ -103,104 +105,124 @@
android:focusable="true"
android:longClickable="true" />
<com.nex3z.flowlayout.FlowLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:flChildSpacing="16dp"
app:flChildSpacingForLastRow="align"
app:flRowSpacing="8dp"
app:flRowVerticalGravity="center">
<com.libRG.CustomTextView
android:id="@+id/type_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/video"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/spoiler"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:text="@string/nsfw"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="4dp"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
android:layout_height="match_parent">
<TextView
android:id="@+id/upvote_ratio_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:id="@+id/post_time_text_view_item_post_detail_video_autoplay"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="?attr/font_12"
android:fontFamily="?attr/font_family" />
<ImageView
android:id="@+id/archived_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_archive_outline"
android:visibility="gone" />
<ImageView
android:id="@+id/locked_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_outline_lock_24dp"
android:visibility="gone" />
<ImageView
android:id="@+id/crosspost_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/crosspost"
android:visibility="gone" />
<TextView
android:id="@+id/awards_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="?attr/font_12"
android:layout_marginEnd="8dp"
android:fontFamily="?attr/font_family"
android:visibility="gone" />
android:gravity="end"
android:textSize="?attr/font_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</com.nex3z.flowlayout.FlowLayout>
<com.nex3z.flowlayout.FlowLayout
android:id="@+id/flowLayout10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
app:flChildSpacing="16dp"
app:flChildSpacingForLastRow="align"
app:flRowSpacing="8dp"
app:flRowVerticalGravity="center"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.libRG.CustomTextView
android:id="@+id/type_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:text="@string/video"
android:textSize="?attr/font_12"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/spoiler_custom_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:text="@string/spoiler"
android:textSize="?attr/font_12"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/nsfw_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:text="@string/nsfw"
android:textSize="?attr/font_12"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<com.libRG.CustomTextView
android:id="@+id/flair_custom_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="?attr/font_family"
android:padding="4dp"
android:textSize="?attr/font_12"
android:visibility="gone"
app:lib_setRadius="6dp"
app:lib_setRoundedView="true"
app:lib_setShape="rectangle" />
<TextView
android:id="@+id/upvote_ratio_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_12" />
<ImageView
android:id="@+id/archived_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_archive_outline"
android:visibility="gone" />
<ImageView
android:id="@+id/locked_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_outline_lock_24dp"
android:visibility="gone" />
<ImageView
android:id="@+id/crosspost_image_view_item_post_detail_video_autoplay"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/crosspost"
android:visibility="gone" />
<TextView
android:id="@+id/awards_text_view_item_post_detail_video_autoplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_12"
android:visibility="gone" />
</com.nex3z.flowlayout.FlowLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout
android:id="@+id/aspect_ratio_frame_layout_item_post_detail_video_autoplay"

View File

@@ -36,6 +36,9 @@
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_video_type_autoplay"
@@ -50,6 +53,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
@@ -65,6 +70,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toBottomOf="parent"
@@ -78,6 +86,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"

View File

@@ -36,6 +36,9 @@
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_video_type_autoplay"
@@ -50,6 +53,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
@@ -65,6 +70,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toBottomOf="parent"
@@ -78,6 +86,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"

View File

@@ -36,6 +36,9 @@
android:layout_gravity="center"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_with_preview"
@@ -50,6 +53,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"
@@ -65,6 +70,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:maxWidth="170dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toBottomOf="parent"
@@ -78,6 +86,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:maxLines="1"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:textSize="?attr/font_default"
app:layout_constrainedWidth="true"

View File

@@ -20,15 +20,28 @@
<TextView
android:id="@+id/subreddit_name_text_view_item_subreddit_listing"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:fontFamily="?attr/font_family"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
app:layout_constraintStart_toEndOf="@+id/subreddit_icon_gif_image_view_item_subreddit_listing"
app:layout_constraintEnd_toStartOf="@id/barrier3"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/community_instance_text_view_item_subreddit_listing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="?attr/font_family"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
app:layout_constraintStart_toEndOf="@+id/subreddit_name_text_view_item_subreddit_listing"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/subscriber_count_text_view_item_subreddit_listing"
android:layout_width="0dp"

View File

@@ -15,14 +15,33 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="32dp" />
<TextView
android:id="@+id/thing_name_text_view_item_subscribed_thing"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
android:layout_gravity="center_vertical" />
android:orientation="horizontal">
<TextView
android:id="@+id/thing_name_text_view_item_subscribed_thing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:gravity="start"
android:maxLines="1"
android:textSize="?attr/font_default" />
<TextView
android:id="@+id/thing_instance_text_view_item_subscribed_thing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:fontFamily="?attr/font_family"
android:maxLines="1"
android:textSize="?attr/font_default" />
</LinearLayout>
<ImageView
android:id="@+id/favorite_image_view_item_subscribed_thing"

View File

@@ -24,12 +24,27 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="32dp"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/user_icon_gif_image_view_item_user_listing"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/user_instance_text_view_item_user_listing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fontFamily="?attr/font_family"
android:maxLines="1"
android:ellipsize="end"
android:textSize="?attr/font_default"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/user_name_text_view_item_user_listing"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/subscribe_image_view_item_user_listing"
android:layout_width="wrap_content"

View File

@@ -28,6 +28,8 @@
android:layout_marginTop="@dimen/nav_header_vertical_spacing"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:maxLines="1"
android:ellipsize="end"
android:layout_alignParentStart="true"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
@@ -40,6 +42,8 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:maxLines="1"
android:ellipsize="end"
android:layout_alignParentStart="true"
android:layout_below="@id/name_text_view_nav_header_main"
android:layout_toStartOf="@id/account_switcher_image_view_nav_header_main"

View File

@@ -397,7 +397,7 @@
<string name="settings_community_summary">!eternityapp@lemdro.id</string>
<string name="settings_share_title">Teilen</string>
<string name="settings_share_summary">Teile diese App mit anderen Leuten, wenn sie dir gefällt</string>
<string name="settings_version_title">Infinity For Reddit</string>
<string name="settings_version_title">Eternity</string>
<string name="settings_version_summary">Version %s</string>
<string name="settings_category_customization_title">Anpassung</string>
<string name="settings_customize_light_theme_title">Helles Thema</string>
@@ -1203,11 +1203,11 @@
<string name="settings_custom_content_font_family_title">Benutzerdefinierte Inhaltschriftart-familie</string>
<string name="settings_fixed_height_preview_in_card_title">Festgestellte Höhe in Kartenansicht</string>
<string name="settings_hide_text_post_content">Text-Post Inhalt verstecken</string>
<string name="settings_hide_comment_awards_title">"Kommentarauszeichnungen verstecken "</string>
<string name="settings_hide_comment_awards_title">Kommentarauszeichnungen verstecken</string>
<string name="settings_show_fewer_toolbar_options_threshold_title">Weniger Werkzeugleistenoptionen anzeigen</string>
<string name="settings_show_fewer_toolbar_options_threshold_summary">Wert %1$d</string>
<string name="settings_show_author_avatar_title">Autoravatar zeigen</string>
<string name="settings_reddit_user_agreement_title">"Lemmy Nutzungsbestimmungen "</string>
<string name="settings_reddit_user_agreement_title">Lemmy Nutzungsbestimmungen</string>
<string name="settings_always_show_child_comment_count_title">Immer die Anzahl von untergeordneten Kommentaren anzeigen</string>
<string name="settings_hide_upvote_ratio_title">Upvoteverhaltnis verstecken</string>
<string name="settings_miscellaneous_dangerous_group_title">Gefährlich</string>
@@ -1223,7 +1223,7 @@
<string name="user_agreement_dialog_title">Nutzungsbedingungen</string>
<string name="user_agreement_message">Du musst Reddit Nutzungsbedingungen (%1$s) und Infinity for reddit\'s Datenschutz-Bestimmungen (%2$s) zustimmen bevor du dich anmelden kannst.</string>
<string name="agree">Zustimmen</string>
<string name="do_not_agree">"Nicht zustimmen "</string>
<string name="do_not_agree">Nicht zustimmen</string>
<string name="option_1_hint">Option 1 (notwendig)</string>
<string name="option_2_hint">Option 2 (notwendig)</string>
<string name="option_3_hint">Option 3</string>

View File

@@ -408,7 +408,7 @@
<string name="settings_community_summary">!eternityapp@lemdro.id</string>
<string name="settings_share_title">Partager</string>
<string name="settings_share_summary">Partagez cette application avec d\'autres si vous l\'appréciez</string>
<string name="settings_version_title">Infinity pour Reddit</string>
<string name="settings_version_title">Eternity</string>
<string name="settings_version_summary">Version %s</string>
<string name="settings_category_customization_title">Personnalisations</string>
<string name="settings_customize_light_theme_title">Thème clair</string>
@@ -473,7 +473,7 @@
<string name="error_getting_multi_reddit_data">Erreur de récupération des données de la multi-communauté</string>
<string name="error_loading_multi_reddit_list">Impossible de synchroniser les multi-communautés</string>
<string name="error_loading_subscriptions">Impossible de synchroniser les abonnements</string>
<string name="share_this_app">Essaie Infinity pour Lemmy, un super client Lemmy !
<string name="share_this_app">Essaie Eternity, un super client Lemmy !
\nhttps://play.google.com/store/apps/details\?id=eu.toldi.infinityforlemmy</string>
<string name="error_getting_community_name">Impossible de récupérer le nom de la communauté</string>
<string name="share_post_link">Partager le lien du post</string>
@@ -728,7 +728,7 @@ https://s3.eu-west-1.amazonaws.com/po-pub/i/dFZKKms9HbrDGOlcgW9QTcwF.jpg -->
<!-- Fuzzy -->
<string name="reset_all_settings_success">Réinitialisation des paramètres réussie</string>
<string name="username_preview">u/Hostilenemy</string>
<string name="community_preview">r/Infinity_For_Reddit</string>
<string name="community_preview">!eternityapp@lemdro.id</string>
<string name="primary_text_preview">Texte principal</string>
<string name="secondary_text_preview">Texte secondaire</string>
<string name="post_title_preview">C\'est une publication</string>
@@ -1226,4 +1226,32 @@ https://s3.eu-west-1.amazonaws.com/po-pub/i/dFZKKms9HbrDGOlcgW9QTcwF.jpg -->
<string name="app_lock_timeout_immediately">Immédiatement</string>
<string name="settings_save_nsfw_media_in_different_folder_title">Sauvegarder les médias NSFW à un autre endroit</string>
<string name="settings_app_lock_timeout_title">Expiration du verrouillage de l\'application</string>
<string name="active_users_number_detail">%1$,d utilisateurs actifs</string>
<string name="message_change_avatar_success">Avatar modifié</string>
<string name="message_change_avatar_failed">Échec de la modification de lavatar %s</string>
<string name="unable_to_get_font_file">Impossible dobtenir votre police</string>
<string name="user_agreement_message">Vous devez accepter le contrat dutilisation de Reddit (%1$s) et la politique de confidentialité dInfinity pour Reddit (%2$s) avant de vous connecter.</string>
<string name="user_agreement_dialog_title">Contrat dutilisateur</string>
<string name="agree">Jaccepte</string>
<string name="post_count_detail">%1$,d publications</string>
<string name="comment_count_detail">%1$,d commentaires</string>
<string name="message_change_banner_success">Bannière modifiée</string>
<string name="message_change_banner_failed">Échec de la modification de la bannière %s</string>
<string name="message_save_profile_success">Profil enregistré</string>
<string name="message_save_profile_failed">Échec de lenregistrement du profil %s</string>
<string name="select_a_ttf_font">Sélectionnez un fichier de police TTF</string>
<string name="unable_to_load_font">Impossible de charger votre police personnalisée</string>
<string name="unable_to_copy_font_file">Impossible de copier votre police</string>
<string name="reddit_gallery_item_caption_hint">Légende (180 caractères max)</string>
<string name="reddit_gallery_item_url_hint">URL</string>
<string name="do_not_agree">Je refuse</string>
<string name="option_1_hint">Option 1 (Requise)</string>
<string name="option_2_hint">Option 2 (Requise)</string>
<string name="option_3_hint">Option 3</string>
<string name="option_4_hint">Option 4</string>
<string name="option_5_hint">Option 5</string>
<string name="option_6_hint">Option 6</string>
<string name="not_a_valid_number">Nombre non valide</string>
<string name="post_karma">Karma de la publication :</string>
<string name="comment_karma">Karma du commentaire :</string>
</resources>

View File

@@ -861,7 +861,7 @@
<string name="multireddit_selection_activity_label">Multireddit kiválasztása</string>
<string name="action_save_to_database">Mentés adatbázisba</string>
<string name="action_read_all_messages">Összes üzenet olvasása</string>
<string name="action_add_to_multireddit">Multireddithez adás</string>
<string name="action_add_to_multireddit">Mulitközösséghez adás</string>
<string name="search_only_communities_hint">Közösségek keresése</string>
<string name="search_only_users_hint">Felhasználók keresése</string>
<string name="post_type_gif">Gif</string>
@@ -1052,4 +1052,10 @@
<string name="mark_post_as_read_failed">Nem sikerült a posztot olvasottként megjelölni</string>
<string name="user_2fa_token">2FA token (ha szükséges)</string>
<string name="instance_url_hint">Az Ön által preferált Lemmy példány URL címe a https:// előtaggal vagy anélkül.</string>
<string name="settings_category_community_and_user_pages_title">Közösségi és Felhasználói oldalak</string>
<string name="settings_show_statistics">Statisztikák mutatása</string>
<string name="moderators">Moderátorok</string>
<string name="admins">Adminok</string>
<string name="settings_hide_user_instance">Felhasználó példányának elrejtése</string>
<string name="report_post">Poszt jelentése</string>
</resources>

View File

@@ -110,7 +110,7 @@
<string name="saved">Guardado</string>
<string name="gilded">Dourado</string>
<string name="settings">Definições</string>
<string name="subscribers_number_detail">Membros: %1$,d</string>
<string name="subscribers_number_detail">%1$,d Membros</string>
<string name="online_subscribers_number_detail">Online: %1$,d</string>
<string name="cannot_fetch_community_info">Não é possível obter informações da comunidade</string>
<string name="cannot_fetch_user_info">Não é possível obter informações do utilizador</string>
@@ -680,7 +680,7 @@
<string name="delete_all_front_page_scrolled_positions_success">Eliminação das posições de deslizamento com sucesso</string>
<string name="reset_all_settings_success">Todas as definições repostas com sucesso</string>
<string name="username_preview">u/Hostilenemy</string>
<string name="community_preview">c/infinityforlemmy</string>
<string name="community_preview">!eternityapp@lemdro.id</string>
<string name="primary_text_preview">Texto Principal</string>
<string name="secondary_text_preview">Texto Secundário</string>
<string name="post_title_preview">Isto é uma publicação</string>
@@ -1264,4 +1264,16 @@
<string name="display_name_description">Isto será apresentado aos visualizadores da sua página de perfil e não altera o seu nome de utilizador.</string>
<string name="reddit_gallery_item_caption_hint">Legenda (máx. 180 caracteres)</string>
<string name="action_unblock_user">Desbloquear Utilizador</string>
<string name="settings_show_statistics">Mostrar Estatísticas</string>
<string name="active_users_number_detail">%1$,d Utilizadores Ativos</string>
<string name="comment_count_detail">%1$,d Comentários</string>
<string name="settings_category_community_and_user_pages_title">Paginas da comunidade e do utilizador</string>
<string name="settings_show_post_and_comment_score">Mostrar pontuações de publicações e comentários</string>
<string name="moderators">Moderadores</string>
<string name="report_post">Denunciar publicação</string>
<string name="separate_down_and_up_votes">Votos Positivos e Negativos separados</string>
<string name="settings_show_display_name_instead_of_user_name">Mostrar nomes de exibição da comunidade e do utilizador</string>
<string name="settings_hide_community_and_user_instance">Ocultar instância da comunidade e do utilizador</string>
<string name="post_count_detail">%1$,d Publicações</string>
<string name="send_report">Enviar Denuncia</string>
</resources>

View File

@@ -144,7 +144,7 @@
<string name="send_message_content_hint">Повідомлення</string>
<string name="reply_message_failed">Не вдалося відповісти на це повідомлення</string>
<string name="error_getting_message">Помилка отримання цього повідомлення</string>
<string name="message_username_required">Чуєш, кому ти хочеш надіслати це повідомлення\?</string>
<string name="message_username_required">Кому ж Ви хочете надіслати це повідомлення\?</string>
<string name="message_subject_required">Ваше повідомлення повинно мати тему</string>
<string name="message_content_required">Отримувачу треба щось написати</string>
<string name="sending_message">Надсилання</string>
@@ -152,7 +152,7 @@
<string name="send_message_failed">Не вдалося надіслати це повідомлення</string>
<string name="select_a_community">Спочатку оберіть спільноту</string>
<string name="title_required">Допису треба дати хороший заголовок</string>
<string name="link_required">Чуєш, де посилання\?</string>
<string name="link_required">Де ж посилання\?</string>
<string name="select_an_image">Спочатку оберіть зображення</string>
<string name="posting">Публікування</string>
<string name="post_failed">Не вдалося це опублікувати</string>
@@ -1271,4 +1271,16 @@
<string name="enable_random_adaptation">Увімкнути випадкову адаптацію</string>
<string name="handle_link">Обробка посилань</string>
<string name="sample_list_load_error">Не вдалося завантажити один або кілька списків зразків</string>
<string name="community_number_detail">%1$,d спільнот</string>
<string name="settings_hide_user_instance">Ховати сервер користувача</string>
<string name="user_number_detail">%1$,d користувачів</string>
<string name="admins">Адміністратори</string>
<string name="reddit_api_info">Починаючи з 1 липня 2023 року, API Reddit стане платним за використання для сторонніх клієнтів, зокрема Infinity for Reddit. Оголошення від Reddit можна знайти тут: %1$s
\n
\nЩоб пережити цю зміну, після 1 липня Infinity стане додатком лише за підпискою. Більше про зміни можна дізнатися з цієї публікації: %2$s
\n
\nПісля 1 липня Infinity необхідно оновити, щоб отримати нову версію з можливістю підписки. Жодна з попередніх версій (включаючи цю) не працюватиме після 1 липня. Але через стислі терміни, надані Reddit, оновлення може не бути доступним одразу 1 липня, оскільки воно потребує належного тестування. Дякуємо за розуміння!</string>
<string name="theme_name_dayfox">Dayfox</string>
<string name="theme_name_carbonfox">Carbonfox</string>
<string name="theme_name_nightfox">Nightfox</string>
</resources>

View File

@@ -543,17 +543,17 @@
</string-array>
<string-array name="settings_default_sort_time_values">
<item>TopHour</item>
<item>TopSixHour</item>
<item>TopTwelveHour</item>
<item>TopDay</item>
<item>TopWeek</item>
<item>TopMonth</item>
<item>TopThreeMonths</item>
<item>TopSixMonths</item>
<item>TopNineMonths</item>
<item>TopYear</item>
<item>TopAll</item>
<item>hour</item>
<item>SixHour</item>
<item>TwelveHour</item>
<item>day</item>
<item>week</item>
<item>month</item>
<item>ThreeMonths</item>
<item>SixMonths</item>
<item>NineMonths</item>
<item>year</item>
<item>all</item>
</string-array>
<string-array name="settings_default_search_result_tab">

View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="application_name" translatable="false">Eternity</string>
<string name="login_activity_label">Login</string>
@@ -84,7 +85,7 @@
<string name="action_give_award">Give Award</string>
<string name="action_save_to_database">Save to Database</string>
<string name="action_read_all_messages">Read All Messages</string>
<string name="action_add_to_multireddit">Add to Multicommuity</string>
<string name="action_add_to_multireddit">Add to Multicommunity</string>
<string name="action_share_link">Share Link</string>
<string name="action_copy_link">Copy Link</string>
<string name="action_open_external_browser">Open in browser</string>
@@ -135,7 +136,7 @@
<string name="profile">Profile</string>
<string name="subscriptions">Subscriptions</string>
<string name="multi_reddit">Multicommuity</string>
<string name="multi_reddit">Multicommunity</string>
<string name="history">History</string>
<string name="inbox">Inbox</string>
<string name="inbox_with_count">Inbox (%1$,d)</string>
@@ -1383,4 +1384,6 @@
<string name="moderators">Moderators</string>
<string name="admins">Admins</string>
<string name="settings_hide_user_instance">Hide user instance</string>
</resources>
<string name="share_links_on_your_local_instance_rather_than_the_original_creation_instance">Share links on your local instance rather than the original creation instance.</string>
<string name="share_links_on_your_local_instance">Share links on your local instance</string>
</resources>

View File

@@ -46,6 +46,12 @@
app:title="@string/anonymous_account_instance"
app:useSimpleSummaryProvider="true" />
<eu.toldi.infinityforlemmy.customviews.CustomFontSwitchPreference
app:defaultValue="false"
app:key="share_link_on_local_instance"
app:title="@string/share_links_on_your_local_instance"
app:summary="@string/share_links_on_your_local_instance_rather_than_the_original_creation_instance" />
<eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceCategory app:title="@string/settings_miscellaneous_dangerous_group_title" />
<eu.toldi.infinityforlemmy.customviews.CustomFontPreference

View File

@@ -24,8 +24,4 @@ allprojects {
maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 292 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 KiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

32
scripts/fixEventBus.py Normal file
View File

@@ -0,0 +1,32 @@
import re
import sys
def rearrange(filename):
with open(filename, 'r') as file:
content = file.read()
# Regex to find the blocks of code to rearrange
pattern = re.compile(r'(putIndex\(new SimpleSubscriberInfo\(.*?\)\);)', re.DOTALL)
blocks = pattern.findall(content)
# Sort blocks based on the class names mentioned in SimpleSubscriberInfo instances
sorted_blocks = sorted(blocks, key=lambda x: re.search(r'SimpleSubscriberInfo\((.*?),', x).group(1))
# Replace the original blocks with the sorted blocks
sorted_content = pattern.sub(lambda match: sorted_blocks.pop(0), content)
with open(filename, 'w') as file:
file.write(sorted_content)
# Project root relative to the script
project_root = __file__[:-len('/scripts/fixEventBus.py')]
path = './build/generated/ap_generated_sources/release/out/eu/toldi/infinityforlemmy/EventBusIndex.java'
# Print the path to the file to stderr
print(path, file=sys.stderr)
# Call the function with the path to EventBusIndex.java
rearrange(path)