mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-11-01 17:38:12 +01:00
Compare commits
26 Commits
v0.0.5
...
reddit_rem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
562c91acb2 | ||
|
|
484f9607b1 | ||
|
|
9149ee224c | ||
|
|
1bb1d3b9af | ||
|
|
0b76390069 | ||
|
|
5de8751079 | ||
|
|
4bfe1b0c02 | ||
|
|
15c1676d0b | ||
|
|
6d114f84fa | ||
|
|
394cff9ebe | ||
|
|
465abd4498 | ||
|
|
0178569f14 | ||
|
|
f7185445e1 | ||
|
|
d4b107bc79 | ||
|
|
fd14753a1d | ||
|
|
7cc4e93ad4 | ||
|
|
4c95404fe1 | ||
|
|
1c2212f0fe | ||
|
|
065fcedd34 | ||
|
|
3a66a79f49 | ||
|
|
907f6e92c3 | ||
|
|
426c3e6979 | ||
|
|
92292be472 | ||
|
|
3e10186c7c | ||
|
|
1974322013 | ||
|
|
a2e22bc525 |
1
.github/CODE_OF_CONDUCT.md
vendored
1
.github/CODE_OF_CONDUCT.md
vendored
@@ -1 +0,0 @@
|
||||
|
||||
1
.github/CONTRIBUTING.md
vendored
1
.github/CONTRIBUTING.md
vendored
@@ -1 +0,0 @@
|
||||
|
||||
14
.github/DISCUSSION_TEMPLATE/announcements.yml
vendored
14
.github/DISCUSSION_TEMPLATE/announcements.yml
vendored
@@ -1,14 +0,0 @@
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to read this announcement!
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: description
|
||||
description: Please describe the announcement in as much detail as possible.
|
||||
placeholder: Make an announcement here...
|
||||
validations:
|
||||
required: true
|
||||
74
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
74
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
@@ -1,74 +0,0 @@
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Have an idea for a new feature or an improvement? Let us know here!
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: I have used the search function for [open](https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/ideas) **and** [closed](https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/completed-ideas) ideas to see if someone else has already submitted the same request.
|
||||
required: true
|
||||
- label: I will describe the feature with as much detail as possible.
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to share your idea!
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Please describe your idea in as much detail as possible.
|
||||
placeholder: I think it would be great if...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: Please describe any alternative solutions or features you've considered.
|
||||
placeholder: I've considered...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: additional
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add your use-case, screenshots, mock-up, or anything else you think might be helpful.
|
||||
placeholder: I think this would be a great addition because...
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: importance
|
||||
attributes:
|
||||
label: How important is this feature?
|
||||
multiple: false
|
||||
options:
|
||||
- Critical
|
||||
- Important
|
||||
- Nice to have
|
||||
|
||||
- type: textarea
|
||||
id: other
|
||||
attributes:
|
||||
label: Anything else?
|
||||
description: Is there anything else you'd like to add?
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Solution
|
||||
description: If you have an idea of how this can be implemented, please share it here.
|
||||
placeholder: I think this could be done by...
|
||||
validations:
|
||||
required: false
|
||||
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,2 +0,0 @@
|
||||
github: Docile-Alligator
|
||||
patreon: docile_alligator
|
||||
94
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
94
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
@@ -1,94 +0,0 @@
|
||||
name: Bug Report
|
||||
description: Create a report to help us improve existing features
|
||||
labels: ['type: possible bug']
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Checklist
|
||||
options:
|
||||
- label: I have used the search function for [open](https://github.com/Docile-Alligator/Infinity-For-Reddit/issues) **and** [closed](https://github.com/Docile-Alligator/Infinity-For-Reddit/issues?q=is%3Aissue+is%3Aclosed) issues to see if someone else has already submitted the same bug report.
|
||||
required: true
|
||||
- label: I will describe the problem with as much detail as possible.
|
||||
required: true
|
||||
- label: If the bug only occurs with a certain link, post, image..., I will include the URL.
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: App version
|
||||
description: We need the actual version number found on the settings screen.
|
||||
placeholder: x.y.z
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: source
|
||||
attributes:
|
||||
label: Where did you get the app from
|
||||
multiple: false
|
||||
options:
|
||||
- Google Play
|
||||
- F-Droid
|
||||
- Other
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: android_version
|
||||
attributes:
|
||||
label: Android version
|
||||
description: Please mention if you are using a custom rom!
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: device
|
||||
attributes:
|
||||
label: Device model
|
||||
|
||||
- type: input
|
||||
id: first
|
||||
attributes:
|
||||
label: First occurred
|
||||
placeholder: about x days/weeks ago
|
||||
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
placeholder: |
|
||||
1. This
|
||||
2. Then that
|
||||
3. Then this
|
||||
4. Etc.
|
||||
|
||||
- type: textarea
|
||||
id: links
|
||||
attributes:
|
||||
label: Example post, link, markdown...
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behaviour
|
||||
description: After following the steps, what did you think Infinity would do?
|
||||
|
||||
- type: textarea
|
||||
id: current
|
||||
attributes:
|
||||
label: Current behaviour
|
||||
description: What did Infinity do instead? Screenshots might help. Usually, you can take a screenshot of your smartphone by pressing *Power* + *Volume down* for a few seconds.
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs
|
||||
description: If you are experiencing a crash, including the stacktrace will likely get it fixed sooner.
|
||||
11
.github/ISSUE_TEMPLATE/config.yml
vendored
11
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,11 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Feature Request
|
||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/ideas
|
||||
about: Discuss ideas for new features of changes
|
||||
- name: Questions
|
||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/q-a
|
||||
about: Please ask and answer questions here.
|
||||
- name: Help needed
|
||||
url: https://github.com/Docile-Alligator/Infinity-For-Reddit/discussions/categories/help-needed
|
||||
about: Please ask for help here
|
||||
23
.github/dependabot.yml
vendored
23
.github/dependabot.yml
vendored
@@ -1,23 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Updates for Gradle dependencies used in the app
|
||||
- package-ecosystem: gradle
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
commit-message:
|
||||
prefix: "⬆[Gradle]"
|
||||
reviewers:
|
||||
- "Wladefant"
|
||||
- "Docile-Alligator"
|
||||
|
||||
# Updates for GitHub Actions used in the repository
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
commit-message:
|
||||
prefix: "⬆[GitHub Actions]"
|
||||
reviewers:
|
||||
- "Wladefant"
|
||||
- "Docile-Alligator"
|
||||
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
@@ -1,32 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set-up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup and build with Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build -x lint
|
||||
|
||||
- name: Upload apk
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Infinity-${{github.sha}}
|
||||
path: app/build/outputs/apk/
|
||||
if-no-files-found: error
|
||||
34
.github/workflows/codeql-analysis.yml
vendored
34
.github/workflows/codeql-analysis.yml
vendored
@@ -1,34 +0,0 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 12 * * *'
|
||||
|
||||
jobs:
|
||||
Analyze:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: java
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "eu.toldi.infinityforlemmy"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 125
|
||||
versionName "0.0.5"
|
||||
versionCode 126
|
||||
versionName "0.0.6"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@@ -52,6 +52,10 @@ android {
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
doNotStrip '**/*.so'
|
||||
}
|
||||
namespace 'eu.toldi.infinityforlemmy'
|
||||
}
|
||||
|
||||
|
||||
@@ -307,6 +307,7 @@ public interface AppComponent {
|
||||
|
||||
void inject(MorePostsInfoFragment morePostsInfoFragment);
|
||||
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
AppComponent create(@BindsInstance Application application);
|
||||
|
||||
@@ -22,6 +22,8 @@ import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LoopAvailableExoCreator;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.videoautoplay.Config;
|
||||
@@ -192,8 +194,8 @@ abstract class AppModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
static ExoCreator provideExoCreator(Config config,
|
||||
ToroExo toroExo,
|
||||
@Named("default") SharedPreferences sharedPreferences) {
|
||||
ToroExo toroExo,
|
||||
@Named("default") SharedPreferences sharedPreferences) {
|
||||
return new LoopAvailableExoCreator(toroExo, config, sharedPreferences);
|
||||
}
|
||||
|
||||
@@ -202,4 +204,16 @@ abstract class AppModule {
|
||||
static Executor provideExecutor() {
|
||||
return Executors.newFixedThreadPool(4);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static ObjectResolver provideObjectResolver(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new ObjectResolver(retrofitHolder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
static MarkPostAsRead provideMarkPostAsRead(@Named("no_oauth") RetrofitHolder retrofitHolder) {
|
||||
return new MarkPostAsRead(retrofitHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import androidx.annotation.NonNull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.DeletePostDTO;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@@ -13,10 +15,11 @@ import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class DeleteThing {
|
||||
public static void delete(Retrofit oauthRetrofit, String fullname, String accessToken, DeleteThingListener deleteThingListener) {
|
||||
|
||||
public static void deletePost(Retrofit retrofit, int post_id, String accessToken, DeleteThingListener deleteThingListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, fullname);
|
||||
oauthRetrofit.create(RedditAPI.class).delete(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||
params.put(APIUtils.ID_KEY, String.valueOf(post_id));
|
||||
retrofit.create(LemmyAPI.class).postDelete(new DeletePostDTO(post_id, true, accessToken)).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
@@ -33,6 +36,27 @@ public class DeleteThing {
|
||||
});
|
||||
}
|
||||
|
||||
public static void deleteComment(Retrofit retrofit, int comment_id, String accessToken, DeleteThingListener deleteThingListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, String.valueOf(comment_id));
|
||||
retrofit.create(LemmyAPI.class).commentDelete(new DeleteCommentDTO(comment_id, true, accessToken)).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
deleteThingListener.deleteSuccess();
|
||||
} else {
|
||||
deleteThingListener.deleteFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
deleteThingListener.deleteFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public interface DeleteThingListener {
|
||||
void deleteSuccess();
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.work.Worker;
|
||||
@@ -28,13 +30,11 @@ import javax.inject.Named;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.activities.InboxActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.message.ParseMessage;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.utils.NotificationUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import retrofit2.Call;
|
||||
@@ -88,9 +88,16 @@ public class PullNotificationWorker extends Worker {
|
||||
|
||||
if (response != null && response.isSuccessful() && response.body() != null) {
|
||||
String responseBody = response.body();
|
||||
JSONArray messageArray = new JSONObject(responseBody).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.CHILDREN_KEY);
|
||||
ArrayList<Message> messages = ParseMessage.parseMessages(messageArray,
|
||||
context.getResources().getConfiguration().locale, FetchMessage.MESSAGE_TYPE_NOTIFICATION);
|
||||
JSONArray messageArray = new JSONObject(responseBody).getJSONArray("replies");
|
||||
List<CommentInteraction> messages = new ArrayList<>();
|
||||
for (int i = 0; i < messageArray.length(); i++) {
|
||||
JSONObject commentInteractionObject = messageArray.getJSONObject(i);
|
||||
Comment comment = ParseComment.parseSingleComment(commentInteractionObject);
|
||||
boolean isRead = !commentInteractionObject.getJSONObject("comment_reply").getBoolean("read");
|
||||
int id = commentInteractionObject.getJSONObject("comment_reply").getInt("id");
|
||||
messages.add(new CommentInteraction(id, comment, isRead));
|
||||
}
|
||||
|
||||
|
||||
if (!messages.isEmpty()) {
|
||||
NotificationCompat.Builder summaryBuilder = NotificationUtils.buildSummaryNotification(context,
|
||||
@@ -110,77 +117,36 @@ public class PullNotificationWorker extends Worker {
|
||||
|
||||
int pendingIntentFlags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
for (int messageIndex = messageSize - 1; messageIndex >= 0; messageIndex--) {
|
||||
Message message = messages.get(messageIndex);
|
||||
if (message.getTimeUTC() <= lastNotificationTime) {
|
||||
CommentInteraction message = messages.get(messageIndex);
|
||||
if (message.getComment().getCommentTimeMillis() <= lastNotificationTime) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hasValidMessage = true;
|
||||
|
||||
inboxStyle.addLine(message.getAuthor() + " " + message.getBody());
|
||||
inboxStyle.addLine(message.getComment().getAuthorQualifiedName() + " " + message.getComment().getCommentMarkdown());
|
||||
|
||||
|
||||
String title = message.getComment().getAuthorQualifiedName();
|
||||
String summary = message.getComment().getCommunityQualifiedName();
|
||||
|
||||
String kind = message.getKind();
|
||||
String title;
|
||||
String summary;
|
||||
if (kind.equals(Message.TYPE_COMMENT) || kind.equals(Message.TYPE_LINK)) {
|
||||
title = message.getAuthor();
|
||||
summary = message.getSubject().substring(0, 1).toUpperCase() + message.getSubject().substring(1);
|
||||
} else {
|
||||
title = message.getTitle() == null || message.getTitle().equals("") ? message.getSubject() : message.getTitle();
|
||||
if (kind.equals(Message.TYPE_ACCOUNT)) {
|
||||
summary = context.getString(R.string.notification_summary_account);
|
||||
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
||||
summary = context.getString(R.string.notification_summary_message);
|
||||
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
||||
summary = context.getString(R.string.notification_summary_community);
|
||||
} else {
|
||||
summary = context.getString(R.string.notification_summary_award);
|
||||
}
|
||||
}
|
||||
|
||||
NotificationCompat.Builder builder = NotificationUtils.buildNotification(notificationManager,
|
||||
context, title, message.getBody(), summary,
|
||||
context, title, message.getComment().getCommentMarkdown(), summary,
|
||||
NotificationUtils.CHANNEL_ID_NEW_MESSAGES,
|
||||
NotificationUtils.CHANNEL_NEW_MESSAGES,
|
||||
NotificationUtils.getAccountGroupName(accountName), color);
|
||||
|
||||
if (kind.equals(Message.TYPE_COMMENT)) {
|
||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||
Uri uri = Uri.parse(message.getContext());
|
||||
intent.setData(uri);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
|
||||
Intent intent = new Intent(context, InboxActivity.class);
|
||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 1, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(summaryPendingIntent);
|
||||
} else if (kind.equals(Message.TYPE_LINK)) {
|
||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||
Uri uri = Uri.parse(message.getContext());
|
||||
intent.setData(uri);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 2, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
||||
Intent intent = new Intent(context, InboxActivity.class);
|
||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
intent.putExtra(InboxActivity.EXTRA_VIEW_MESSAGE, true);
|
||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 3, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(summaryPendingIntent);
|
||||
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
||||
Intent intent = new Intent(context, InboxActivity.class);
|
||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 4, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(summaryPendingIntent);
|
||||
} else {
|
||||
Intent intent = new Intent(context, InboxActivity.class);
|
||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 5, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(summaryPendingIntent);
|
||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||
Uri uri = Uri.parse(message.getComment().getPermalink());
|
||||
intent.setData(uri);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getId());
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, pendingIntentFlags);
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
if (ActivityCompat.checkSelfPermission(this.getApplicationContext(), android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
return Result.failure();
|
||||
}
|
||||
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
|
||||
}
|
||||
@@ -216,10 +182,7 @@ public class PullNotificationWorker extends Worker {
|
||||
if (retryCount < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
||||
.getMessages(APIUtils.getOAuthHeader(account.getAccessToken()),
|
||||
FetchMessage.WHERE_UNREAD, null);
|
||||
Call<String> call = mRetrofit.getRetrofit().create(LemmyAPI.class).userReplies("New", 1, 25, true, account.getAccessToken());
|
||||
Response<String> response = call.execute();
|
||||
|
||||
if (response.isSuccessful()) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -40,6 +41,7 @@ import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.CommentsListingFragment;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -64,10 +66,15 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
|
||||
private ActivityAccountSavedThingBinding binding;
|
||||
|
||||
@@ -116,6 +123,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
initializeViewPager();
|
||||
}
|
||||
@@ -249,7 +257,17 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(AccountSavedThingActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class SectionsPagerAdapter extends FragmentStateAdapter {
|
||||
|
||||
@@ -39,6 +39,9 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.shape.CornerFamily;
|
||||
import com.google.android.material.shape.MaterialShapeDrawable;
|
||||
import com.google.android.material.shape.ShapeAppearanceModel;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -377,9 +380,18 @@ public abstract class BaseActivity extends AppCompatActivity implements CustomFo
|
||||
button.setTextColor(customThemeWrapper.getFABIconColor());
|
||||
}
|
||||
|
||||
protected void applyFABTheme(FloatingActionButton fab) {
|
||||
protected void applyFABTheme(FloatingActionButton fab, boolean isCircular) {
|
||||
fab.setBackgroundTintList(ColorStateList.valueOf(customThemeWrapper.getColorAccent()));
|
||||
fab.setImageTintList(ColorStateList.valueOf(customThemeWrapper.getFABIconColor()));
|
||||
if (isCircular) {
|
||||
ShapeAppearanceModel shapeAppearanceModel = ShapeAppearanceModel.builder()
|
||||
.setAllCorners(CornerFamily.ROUNDED, 100) // Adjust the radius value to control the roundness
|
||||
.build();
|
||||
|
||||
// Apply the circular shape to the FAB
|
||||
MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
|
||||
fab.setShapeAppearanceModel(shapeAppearanceModel);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fixViewPager2Sensitivity(ViewPager2 viewPager2) {
|
||||
|
||||
@@ -51,6 +51,7 @@ import eu.toldi.infinityforlemmy.customtheme.CustomThemeViewModel;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
||||
import eu.toldi.infinityforlemmy.utils.CustomThemeSharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
|
||||
public class CustomThemeListingActivity extends BaseActivity implements
|
||||
@@ -154,7 +155,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,17 +3,20 @@ package eu.toldi.infinityforlemmy.activities;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -23,18 +26,22 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.json.JSONException;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -48,14 +55,16 @@ import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.UploadImageUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@@ -64,16 +73,19 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class EditPostActivity extends BaseActivity implements UploadImageEnabledActivity {
|
||||
|
||||
public static final String EXTRA_TITLE = "ET";
|
||||
public static final String EXTRA_CONTENT = "EC";
|
||||
public static final String EXTRA_FULLNAME = "EF";
|
||||
public static final String EXTRA_DATA = "ED";
|
||||
|
||||
|
||||
private static final int UPLOAD_IMAGE_REQUEST_CODE = 1;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||
|
||||
private static final String UPLOADED_IMAGES_STATE = "UIS";
|
||||
|
||||
private static final String picturePattern = "https:\\/\\/[^\\/]+\\/pictrs\\/image\\/([a-f\\d-]+\\.jpeg)";
|
||||
|
||||
|
||||
@BindView(R.id.coordinator_layout_edit_post_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@BindView(R.id.appbar_layout_edit_post_activity)
|
||||
@@ -81,13 +93,22 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
@BindView(R.id.toolbar_edit_post_activity)
|
||||
Toolbar toolbar;
|
||||
@BindView(R.id.post_title_text_view_edit_post_activity)
|
||||
TextView titleTextView;
|
||||
EditText titleEditText;
|
||||
@BindView(R.id.divider_edit_post_activity)
|
||||
View divider;
|
||||
@BindView(R.id.post_text_content_edit_text_edit_post_activity)
|
||||
EditText contentEditText;
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_edit_post_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@BindView(R.id.post_link_edit_text_post_edit_activity)
|
||||
EditText linkEditText;
|
||||
|
||||
@BindView(R.id.upload_image_button_post_edit_activity)
|
||||
MaterialButton uploadImageButton;
|
||||
|
||||
@BindView(R.id.image_view_post_edit_activity)
|
||||
ImageView imageView;
|
||||
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@@ -104,13 +125,16 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
private String mFullName;
|
||||
private Post mPost;
|
||||
|
||||
private String mAccessToken;
|
||||
private String mPostContent;
|
||||
private boolean isSubmitting = false;
|
||||
private Uri capturedImageUri;
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
|
||||
private RequestManager mGlide;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -138,11 +162,49 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
mFullName = getIntent().getStringExtra(EXTRA_FULLNAME);
|
||||
mPost = getIntent().getParcelableExtra(EXTRA_DATA);
|
||||
if (mPost == null) {
|
||||
finish();
|
||||
}
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
titleTextView.setText(getIntent().getStringExtra(EXTRA_TITLE));
|
||||
mPostContent = getIntent().getStringExtra(EXTRA_CONTENT);
|
||||
contentEditText.setText(mPostContent);
|
||||
titleEditText.setText(mPost.getTitle());
|
||||
contentEditText.setText(mPost.getSelfText());
|
||||
linkEditText.setText(mPost.getUrl());
|
||||
|
||||
mGlide = Glide.with(this);
|
||||
|
||||
if (mPost.getUrl() != null && mPost.getUrl().matches(picturePattern)) {
|
||||
loadImage();
|
||||
}
|
||||
|
||||
linkEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
if (charSequence.toString().matches(picturePattern)) {
|
||||
loadImage();
|
||||
} else {
|
||||
uploadImageButton.setVisibility(View.VISIBLE);
|
||||
imageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
}
|
||||
});
|
||||
|
||||
uploadImageButton.setOnClickListener(view -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.select_from_gallery)), UPLOAD_IMAGE_REQUEST_CODE);
|
||||
});
|
||||
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
uploadedImages = savedInstanceState.getParcelableArrayList(UPLOADED_IMAGES_STATE);
|
||||
@@ -190,18 +252,27 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
|
||||
titleTextView.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
titleEditText.setTextColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
divider.setBackgroundColor(mCustomThemeWrapper.getPostTitleColor());
|
||||
contentEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
||||
linkEditText.setTextColor(mCustomThemeWrapper.getPostContentColor());
|
||||
|
||||
uploadImageButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
|
||||
uploadImageButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
|
||||
if (titleTypeface != null) {
|
||||
titleTextView.setTypeface(titleTypeface);
|
||||
titleEditText.setTypeface(titleTypeface);
|
||||
}
|
||||
if (contentTypeface != null) {
|
||||
contentEditText.setTypeface(contentTypeface);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
uploadImageButton.setVisibility(View.GONE);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
mGlide.load(mPost.getUrl()).into(imageView);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@@ -237,21 +308,19 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
isSubmitting = true;
|
||||
|
||||
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.THING_ID_KEY, mFullName);
|
||||
params.put(APIUtils.TEXT_KEY, contentEditText.getText().toString());
|
||||
|
||||
mRetrofit.getRetrofit().create(RedditAPI.class)
|
||||
.editPostOrComment(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), titleEditText.getText().toString(), linkEditText.getText().toString(), contentEditText.getText().toString(), mPost.isNSFW(), null, mAccessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
isSubmitting = false;
|
||||
Toast.makeText(EditPostActivity.this, R.string.edit_success, Toast.LENGTH_SHORT).show();
|
||||
Intent returnIntent = new Intent();
|
||||
setResult(RESULT_OK, returnIntent);
|
||||
finish();
|
||||
if (response.isSuccessful()) {
|
||||
Toast.makeText(EditPostActivity.this, R.string.edit_success, Toast.LENGTH_SHORT).show();
|
||||
Intent returnIntent = new Intent();
|
||||
setResult(RESULT_OK, returnIntent);
|
||||
finish();
|
||||
} else {
|
||||
Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,6 +344,39 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == UPLOAD_IMAGE_REQUEST_CODE) {
|
||||
if (data == null) {
|
||||
Snackbar.make(coordinatorLayout, R.string.error_getting_image, Snackbar.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Toast.makeText(this, R.string.uploading_image, Toast.LENGTH_SHORT).show();
|
||||
Handler handler = new Handler();
|
||||
Uri imageUri = data.getData();
|
||||
mExecutor.execute(() -> {
|
||||
try {
|
||||
Bitmap bitmap = Glide.with(this).asBitmap().load(imageUri).submit().get();
|
||||
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, mAccessToken, bitmap);
|
||||
handler.post(() -> {
|
||||
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
||||
String fileName = Utils.getFileName(this, imageUri);
|
||||
if (fileName == null) {
|
||||
fileName = imageUrlOrError;
|
||||
}
|
||||
mPost.setUrl(imageUrlOrError);
|
||||
linkEditText.setText(imageUrlOrError);
|
||||
Snackbar.make(coordinatorLayout, R.string.upload_image_success, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(this, R.string.upload_image_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
handler.post(() -> Toast.makeText(this, R.string.get_image_bitmap_failed, Toast.LENGTH_LONG).show());
|
||||
} catch (XmlPullParserException | JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
handler.post(() -> Toast.makeText(this, R.string.error_processing_image, Toast.LENGTH_LONG).show());
|
||||
}
|
||||
});
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
@@ -282,6 +384,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
editPost();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -305,7 +408,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
|
||||
if (isSubmitting) {
|
||||
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_edit_post_detail);
|
||||
} else {
|
||||
if (contentEditText.getText().toString().equals(mPostContent)) {
|
||||
if (contentEditText.getText().toString().equals(mPost.getSelfText())) {
|
||||
finish();
|
||||
} else {
|
||||
promptAlertDialog(R.string.discard, R.string.discard_detail);
|
||||
|
||||
@@ -103,6 +103,8 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
public SubredditViewModel mSubredditViewModel;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
|
||||
private String mAccountQualifiedName;
|
||||
private String name;
|
||||
private String userWhere;
|
||||
private int postType;
|
||||
@@ -158,6 +160,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
name = getIntent().getStringExtra(EXTRA_NAME);
|
||||
postType = getIntent().getIntExtra(EXTRA_POST_TYPE, PostPagingSource.TYPE_FRONT_PAGE);
|
||||
|
||||
@@ -262,7 +265,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
private void bindView(PostFilter postFilter, boolean initializeFragment) {
|
||||
@@ -470,7 +473,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,6 @@ import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RecyclerViewContentScrollingInterface;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.SwitchAccount;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.slidr.Slidr;
|
||||
@@ -56,14 +55,11 @@ import eu.toldi.infinityforlemmy.events.PassPrivateMessageEvent;
|
||||
import eu.toldi.infinityforlemmy.events.PassPrivateMessageIndexEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.InboxFragment;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class InboxActivity extends BaseActivity implements ActivityToolbarInterface, RecyclerViewContentScrollingInterface {
|
||||
|
||||
@@ -229,7 +225,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
private void getCurrentAccountAndFetchMessage(Bundle savedInstanceState) {
|
||||
@@ -268,13 +264,16 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
}
|
||||
});
|
||||
viewPager2.setAdapter(sectionsPagerAdapter);
|
||||
viewPager2.setOffscreenPageLimit(2);
|
||||
viewPager2.setOffscreenPageLimit(3);
|
||||
new TabLayoutMediator(tabLayout, viewPager2, (tab, position) -> {
|
||||
switch (position) {
|
||||
case 0:
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.notifications));
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.replies));
|
||||
break;
|
||||
case 1:
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.mentions));
|
||||
break;
|
||||
case 2:
|
||||
Utils.setTitleWithCustomFontToTab(typeface, tab, getString(R.string.messages));
|
||||
break;
|
||||
}
|
||||
@@ -302,31 +301,21 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_read_all_messages_inbox_activity) {
|
||||
if (mAccessToken != null) {
|
||||
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
|
||||
mRetrofit.getRetrofit().create(RedditAPI.class).readAllMessages(APIUtils.getOAuthHeader(mAccessToken))
|
||||
.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_success, Toast.LENGTH_SHORT).show();
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.readAllMessages();
|
||||
}
|
||||
EventBus.getDefault().post(new ChangeInboxCountEvent(0));
|
||||
} else {
|
||||
if (response.code() == 429) {
|
||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_time_limit, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
ReadMessage.readAllMessages(mRetrofit.getRetrofit(), mAccessToken, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_success, Toast.LENGTH_SHORT).show();
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.readAllMessages();
|
||||
}
|
||||
EventBus.getDefault().post(new ChangeInboxCountEvent(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
Toast.makeText(InboxActivity.this, R.string.read_all_messages_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void readFailed() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
@@ -438,7 +427,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
}
|
||||
}
|
||||
|
||||
Message getPrivateMessage(int index) {
|
||||
CommentInteraction getPrivateMessage(int index) {
|
||||
if (viewPager2 == null || fragmentManager == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -452,26 +441,29 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
if (position == 0) {
|
||||
InboxFragment fragment = new InboxFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
} else {
|
||||
InboxFragment fragment = new InboxFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
InboxFragment fragment = new InboxFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
switch (position) {
|
||||
case 0:
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_REPLIES);
|
||||
break;
|
||||
case 1:
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MENTIONS);
|
||||
fragment.setArguments(bundle);
|
||||
break;
|
||||
case 2:
|
||||
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_MESSAGES);
|
||||
fragment.setArguments(bundle);
|
||||
break;
|
||||
}
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,12 @@ import javax.inject.Named;
|
||||
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.post.ObjectResolver;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
@@ -35,10 +40,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||
public static final String EXTRA_IS_NSFW = "EIN";
|
||||
|
||||
private static final String POST_PATTERN = "/r/[\\w-]+/comments/\\w+/?\\w+/?";
|
||||
private static final String POST_PATTERN_2 = "/(u|U|user)/[\\w-]+/comments/\\w+/?\\w+/?";
|
||||
private static final String POST_PATTERN = "https?:\\/\\/\\S+\\/post\\/\\d+";
|
||||
private static final String POST_PATTERN_3 = "/[\\w-]+$";
|
||||
private static final String COMMENT_PATTERN = "/(r|u|U|user)/[\\w-]+/comments/\\w+/?[\\w-]+/\\w+/?";
|
||||
private static final String COMMENT_PATTERN = "https?:\\/\\/\\S+\\/comment\\/\\d+";
|
||||
private static final String SUBREDDIT_PATTERN = "(?:https?://[\\w.-]+)?/c/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String USER_PATTERN = "(?:https?://[\\w.-]+)?/u(sers)?/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String SIDEBAR_PATTERN = "/[rR]/[\\w-]+/about/sidebar";
|
||||
@@ -60,6 +64,19 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
|
||||
@Inject
|
||||
ObjectResolver mObjectResolver;
|
||||
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
|
||||
private String mAccessToken;
|
||||
|
||||
private Uri getRedditUriByPath(String path) {
|
||||
if (path.charAt(0) != '/') {
|
||||
return Uri.parse("https://www.reddit.com/" + path);
|
||||
@@ -73,6 +90,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
|
||||
Uri uri = getIntent().getData();
|
||||
if (uri == null) {
|
||||
@@ -169,6 +187,75 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (uri.toString().matches(POST_PATTERN)) {
|
||||
if (mAccessToken == null) {
|
||||
// switch retrofit to use the current instance for anonymous requests
|
||||
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, Integer.parseInt(segments.get(segments.size() - 1)));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
mObjectResolver.resolvePost(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||
@Override
|
||||
public void onResolveObjectSuccess(Object p) {
|
||||
Post post = (Post) p;
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, post.getId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolveObjectFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (uri.toString().matches(COMMENT_PATTERN)) {
|
||||
if (mAccessToken == null) {
|
||||
mRetrofit.setBaseURL(uri.getScheme() + "://" + uri.getHost() + "/");
|
||||
FetchComment.fetchSingleComment(mRetrofit.getRetrofit(), null, Integer.parseInt(segments.get(segments.size() - 1)), new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> comments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
Comment comment = comments.get(0);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchCommentFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mObjectResolver.resolveComment(uri.toString(), mAccessToken, new ObjectResolver.ObjectResolverListener() {
|
||||
@Override
|
||||
public void onResolveObjectSuccess(Object c) {
|
||||
Comment comment = (Comment) c;
|
||||
Intent intent = new Intent(LinkResolverActivity.this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResolveObjectFailed() {
|
||||
Toast.makeText(LinkResolverActivity.this, R.string.could_not_resolve_link, Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (authority.equals("v.redd.it")) {
|
||||
Intent intent = new Intent(this, ViewVideoActivity.class);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
||||
@@ -187,35 +274,12 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
} else if (path.equals("/report")) {
|
||||
openInWebView(uri);
|
||||
} else if (path.matches(POST_PATTERN) || path.matches(POST_PATTERN_2)) {
|
||||
int commentsIndex = segments.lastIndexOf("comments");
|
||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
deepLinkError(uri);
|
||||
}
|
||||
} else if (path.matches(POST_PATTERN_3)) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, path.substring(1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (path.matches(COMMENT_PATTERN)) {
|
||||
int commentsIndex = segments.lastIndexOf("comments");
|
||||
if (commentsIndex >= 0 && commentsIndex < segments.size() - 1) {
|
||||
Intent intent = new Intent(this, ViewPostDetailActivity.class);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, segments.get(commentsIndex + 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, segments.get(segments.size() - 1));
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
deepLinkError(uri);
|
||||
}
|
||||
} else if (path.matches(WIKI_PATTERN)) {
|
||||
String[] pathSegments = path.split("/");
|
||||
String wikiPage;
|
||||
|
||||
@@ -107,12 +107,14 @@ import eu.toldi.infinityforlemmy.events.ChangeLockBottomAppBarEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeNSFWEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeRequireAuthToAccountSectionEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeShowAvatarOnTheRightInTheNavigationDrawerEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeUseCircularFabEvent;
|
||||
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiRedditViewModel;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -213,6 +215,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private NavigationDrawerRecyclerViewMergedAdapter adapter;
|
||||
@@ -225,9 +231,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
private boolean mFetchUserInfoSuccess = false;
|
||||
private boolean mFetchSubscriptionsSuccess = false;
|
||||
private boolean mDrawerOnAccountSwitch = false;
|
||||
private String mMessageFullname;
|
||||
private int mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private boolean hideFab;
|
||||
|
||||
private boolean useCircularFab;
|
||||
private boolean showBottomAppBar;
|
||||
private int mBackButtonAction;
|
||||
private boolean mLockBottomAppBar;
|
||||
@@ -254,6 +262,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
ButterKnife.bind(this);
|
||||
|
||||
hideFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED, false);
|
||||
useCircularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||
showBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY, false);
|
||||
|
||||
navigationWrapper = new NavigationWrapper(findViewById(R.id.bottom_app_bar_bottom_app_bar), findViewById(R.id.linear_layout_bottom_app_bar),
|
||||
@@ -339,11 +348,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||
mFetchSubscriptionsSuccess = savedInstanceState.getBoolean(FETCH_SUBSCRIPTIONS_STATE);
|
||||
mDrawerOnAccountSwitch = savedInstanceState.getBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
inboxCount = savedInstanceState.getInt(INBOX_COUNT_STATE);
|
||||
} else {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
|
||||
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
}
|
||||
|
||||
@@ -380,7 +389,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
navigationView.setBackgroundColor(backgroundColor);
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab);
|
||||
}
|
||||
|
||||
private void initializeNotificationAndBindView() {
|
||||
@@ -1020,11 +1029,11 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
loadUserData();
|
||||
|
||||
if (mAccessToken != null) {
|
||||
if (mMessageFullname != null) {
|
||||
if (mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1067,20 +1076,29 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
private void loadUserData() {
|
||||
if (!mFetchUserInfoSuccess) {
|
||||
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mRetrofit.getRetrofit(), mAccessToken,
|
||||
mAccountName, new FetchUserData.FetchUserDataListener() {
|
||||
FetchUserData.fetchUnreadCount(mRetrofit.getRetrofit(), mAccessToken, new FetchUserData.FetchUserUnreadCountListener() {
|
||||
@Override
|
||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||
public void onFetchUserUnreadCountSuccess(int inboxCount) {
|
||||
MainActivity.this.inboxCount = inboxCount;
|
||||
mAccountName = userData.getName();
|
||||
mFetchUserInfoSuccess = true;
|
||||
if (adapter != null) {
|
||||
adapter.setInboxCount(inboxCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchUserDataFailed() {
|
||||
public void onFetchUserUnreadCountFailed() {
|
||||
}
|
||||
});
|
||||
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mRetrofit.getRetrofit(), mAccessToken,
|
||||
mAccountName, new FetchUserData.FetchUserDataListener() {
|
||||
@Override
|
||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||
mAccountName = userData.getName();
|
||||
mFetchUserInfoSuccess = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchUserDataFailed() {
|
||||
mFetchUserInfoSuccess = false;
|
||||
}
|
||||
});
|
||||
@@ -1172,7 +1190,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||
outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess);
|
||||
outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
outState.putInt(INBOX_COUNT_STATE, inboxCount);
|
||||
}
|
||||
@@ -1331,6 +1349,12 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
navigationWrapper.floatingActionButton.setVisibility(hideFab ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeUseCircularFab(ChangeUseCircularFabEvent event) {
|
||||
useCircularFab = event.isUseCircularFab();
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, useCircularFab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLongPress() {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
@@ -1376,10 +1400,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
randomThing();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.hideReadPosts();
|
||||
@@ -1608,7 +1628,17 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(MainActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void doNotShowRedditAPIInfoAgain() {
|
||||
|
||||
@@ -33,6 +33,7 @@ import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.postfilter.DeletePostFilter;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
public class PostFilterPreferenceActivity extends BaseActivity {
|
||||
|
||||
@@ -205,7 +206,7 @@ public class PostFilterPreferenceActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import eu.toldi.infinityforlemmy.postfilter.PostFilter;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsage;
|
||||
import eu.toldi.infinityforlemmy.postfilter.PostFilterUsageViewModel;
|
||||
import eu.toldi.infinityforlemmy.postfilter.SavePostFilterUsage;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
|
||||
public class PostFilterUsageListingActivity extends BaseActivity {
|
||||
@@ -206,7 +207,7 @@ public class PostFilterUsageListingActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, sharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
coordinatorLayout.setBackgroundColor(customThemeWrapper.getBackgroundColor());
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -25,6 +26,8 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@@ -43,6 +46,7 @@ import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -55,11 +59,16 @@ import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitImagePostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitVideoOrGifPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
@@ -68,12 +77,13 @@ import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class PostImageActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
|
||||
@@ -92,6 +102,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||
|
||||
private static final int PICK_IMAGE_REQUEST_CODE_2 = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE_2 = 200;
|
||||
private static final String COMMUNITY_DATA_STATE = "CDS";
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_image_activity)
|
||||
@@ -153,6 +166,11 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
@Inject
|
||||
@Named("current_account")
|
||||
SharedPreferences mCurrentAccountSharedPreferences;
|
||||
|
||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||
EditText contentEditText;
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@Inject
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
@@ -184,6 +202,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||
private Snackbar mPostingSnackbar;
|
||||
|
||||
private Uri capturedImageUri;
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -376,6 +397,30 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
imageView.setVisibility(View.GONE);
|
||||
constraintLayout.setVisibility(View.VISIBLE);
|
||||
});
|
||||
|
||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int item) {
|
||||
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||
PostImageActivity.this, contentEditText, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadImage() {
|
||||
Utils.hideKeyboard(PostImageActivity.this);
|
||||
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||
uploadedImages);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||
LinearLayoutManager.HORIZONTAL, false));
|
||||
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void loadCurrentAccount() {
|
||||
@@ -430,8 +475,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
applyFABTheme(captureFab);
|
||||
applyFABTheme(selectFromLibraryFab);
|
||||
boolean circleFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||
applyFABTheme(captureFab, circleFab);
|
||||
applyFABTheme(selectFromLibraryFab, circleFab);
|
||||
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
||||
if (typeface != null) {
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
@@ -544,6 +590,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||
@@ -626,6 +673,16 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
if (resultCode == RESULT_OK) {
|
||||
loadImage();
|
||||
}
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE_2) {
|
||||
if (data == null) {
|
||||
Toast.makeText(PostImageActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE_2) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,4 +762,37 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureImage() {
|
||||
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
try {
|
||||
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE_2);
|
||||
} catch (IOException ex) {
|
||||
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package eu.toldi.infinityforlemmy.activities;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.webkit.URLUtil;
|
||||
@@ -19,6 +23,9 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.RequestManager;
|
||||
@@ -34,6 +41,9 @@ import com.libRG.CustomTextView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -46,12 +56,17 @@ import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.UploadImageEnabledActivity;
|
||||
import eu.toldi.infinityforlemmy.UploadedImage;
|
||||
import eu.toldi.infinityforlemmy.account.Account;
|
||||
import eu.toldi.infinityforlemmy.adapters.MarkdownBottomBarRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.TitleSuggestion;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadSubredditIcon;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.AccountChooserBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.UploadedImagesBottomSheetFragment;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.SubmitTextOrLinkPostEvent;
|
||||
import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.services.SubmitPostService;
|
||||
@@ -60,6 +75,7 @@ import eu.toldi.infinityforlemmy.subreddit.SubredditData;
|
||||
import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import pl.droidsonroids.gif.GifImageView;
|
||||
import retrofit2.Call;
|
||||
@@ -69,7 +85,7 @@ import retrofit2.Retrofit;
|
||||
import retrofit2.converter.scalars.ScalarsConverterFactory;
|
||||
|
||||
public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
|
||||
AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
UploadImageEnabledActivity, AccountChooserBottomSheetFragment.AccountChooserListener {
|
||||
|
||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
static final String EXTRA_LINK = "EL";
|
||||
@@ -87,6 +103,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private static final String IS_NSFW_STATE = "INS";
|
||||
|
||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 100;
|
||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
|
||||
private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
|
||||
|
||||
@BindView(R.id.coordinator_layout_post_link_activity)
|
||||
CoordinatorLayout coordinatorLayout;
|
||||
@@ -124,6 +143,11 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
MaterialButton suggestTitleButton;
|
||||
@BindView(R.id.post_link_edit_text_post_link_activity)
|
||||
EditText linkEditText;
|
||||
|
||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||
EditText contentEditText;
|
||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||
RecyclerView markdownBottomBarRecyclerView;
|
||||
@Inject
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@@ -167,6 +191,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private FlairBottomSheetFragment flairSelectionBottomSheetFragment;
|
||||
private Snackbar mPostingSnackbar;
|
||||
|
||||
private Uri capturedImageUri;
|
||||
private ArrayList<UploadedImage> uploadedImages = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -335,21 +362,46 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
.baseUrl("http://localhost/")
|
||||
.addConverterFactory(ScalarsConverterFactory.create())
|
||||
.build().create(TitleSuggestion.class).getHtml(url).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
||||
} else {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
|
||||
} else {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int item) {
|
||||
MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
|
||||
PostLinkActivity.this, contentEditText, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUploadImage() {
|
||||
Utils.hideKeyboard(PostLinkActivity.this);
|
||||
UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment();
|
||||
Bundle arguments = new Bundle();
|
||||
arguments.putParcelableArrayList(UploadedImagesBottomSheetFragment.EXTRA_UPLOADED_IMAGES,
|
||||
uploadedImages);
|
||||
fragment.setArguments(arguments);
|
||||
fragment.show(getSupportFragmentManager(), fragment.getTag());
|
||||
}
|
||||
});
|
||||
|
||||
markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
|
||||
LinearLayoutManager.HORIZONTAL, false));
|
||||
markdownBottomBarRecyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void loadCurrentAccount() {
|
||||
@@ -438,10 +490,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
private void loadSubredditIcon() {
|
||||
LoadSubredditIcon.loadSubredditIcon(mExecutor, new Handler(), mRedditDataRoomDatabase, subredditName,
|
||||
mAccessToken, mOauthRetrofit, mRetrofit.getRetrofit(), iconImageUrl -> {
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
iconUrl = iconImageUrl;
|
||||
displaySubredditIcon();
|
||||
loadSubredditIconSuccessful = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void promptAlertDialog(int titleResId, int messageResId) {
|
||||
@@ -514,7 +566,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_URL, linkEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_LINK);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
@@ -561,8 +614,8 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
|
||||
communityData = data.getExtras().getParcelable(SubredditSelectionActivity.EXTRA_RETURN_COMMUNITY_DATA);
|
||||
subredditName = communityData.getName();
|
||||
iconUrl = communityData.getIconUrl();
|
||||
@@ -574,6 +627,16 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
displaySubredditIcon();
|
||||
|
||||
flair = null;
|
||||
} else if (requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||
if (data == null) {
|
||||
Toast.makeText(PostLinkActivity.this, R.string.error_getting_image, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, data.getData(), uploadedImages);
|
||||
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
|
||||
Utils.uploadImageToReddit(this, mExecutor, mRetrofit,
|
||||
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,4 +692,37 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadImage() {
|
||||
Intent intent = new Intent();
|
||||
intent.setType("image/*");
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
startActivityForResult(Intent.createChooser(intent,
|
||||
getResources().getString(R.string.select_from_gallery)), PICK_IMAGE_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void captureImage() {
|
||||
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
try {
|
||||
capturedImageUri = FileProvider.getUriForFile(this, "eu.toldi.infinityforlemmy.provider",
|
||||
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
|
||||
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
|
||||
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
|
||||
} catch (IOException ex) {
|
||||
Toast.makeText(this, R.string.error_creating_temp_file, Toast.LENGTH_SHORT).show();
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(this, R.string.no_camera_available, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertImageUrl(UploadedImage uploadedImage) {
|
||||
int start = Math.max(contentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(contentEditText.getSelectionEnd(), 0);
|
||||
contentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + uploadedImage.imageName + "](" + uploadedImage.imageUrl + ")",
|
||||
0, "[]()".length() + uploadedImage.imageName.length() + uploadedImage.imageUrl.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, contentEditText.getText().toString());
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||
|
||||
@@ -447,8 +447,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
|
||||
nsfwTextView.setTextColor(primaryTextColor);
|
||||
titleEditText.setTextColor(primaryTextColor);
|
||||
titleEditText.setHintTextColor(secondaryTextColor);
|
||||
applyFABTheme(captureFab);
|
||||
applyFABTheme(selectFromLibraryFab);
|
||||
boolean circularFab = mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false);
|
||||
applyFABTheme(captureFab, circularFab);
|
||||
applyFABTheme(selectFromLibraryFab, circularFab);
|
||||
selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
|
||||
if (typeface != null) {
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
|
||||
@@ -238,7 +238,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
private void bindView(Bundle savedInstanceState) {
|
||||
@@ -558,10 +558,6 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
random();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.hideReadPosts();
|
||||
|
||||
@@ -194,7 +194,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -573,9 +573,9 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||
if (post.isCrosspost()) {
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, "t3_" + post.getCrosspostParentId());
|
||||
} else {
|
||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, post.getFullName());
|
||||
intent.putExtra(SubmitPostService.EXTRA_BODY, post.getFullName());
|
||||
}
|
||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||
|
||||
@@ -221,7 +221,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
searchEditText.setTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor());
|
||||
searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarSecondaryTextColor());
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
});
|
||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(sectionsPagerAdapter);
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
viewPager.setOffscreenPageLimit(1);
|
||||
if (viewPager.getCurrentItem() != 2) {
|
||||
fab.hide();
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
}
|
||||
|
||||
if (!(!forceLoad && mInsertMultiredditSuccess)) {
|
||||
loadMultiReddits();
|
||||
//loadMultiReddits();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
public void success() {
|
||||
Toast.makeText(SubscribedThingListingActivity.this,
|
||||
R.string.delete_multi_reddit_success, Toast.LENGTH_SHORT).show();
|
||||
loadMultiReddits();
|
||||
//loadMultiReddits();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -439,7 +439,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
|
||||
@Subscribe
|
||||
public void onRefreshMultiRedditsEvent(RefreshMultiRedditsEvent event) {
|
||||
loadMultiReddits();
|
||||
//loadMultiReddits();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -477,6 +477,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
default:
|
||||
case 0: {
|
||||
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
@@ -487,28 +488,12 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
case 1: {
|
||||
FollowedUsersListingFragment fragment = new FollowedUsersListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
|
||||
bundle.putString(FollowedUsersListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
default: {
|
||||
MultiRedditListingFragment fragment = new MultiRedditListingFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(MultiRedditListingFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||
bundle.putString(MultiRedditListingFragment.EXTRA_ACCOUNT_NAME, mAccountName == null ? "-" : mAccountName);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,6 +67,7 @@ import eu.toldi.infinityforlemmy.events.SwitchAccountEvent;
|
||||
import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.multireddit.DeleteMultiReddit;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -131,8 +132,11 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private String multiPath;
|
||||
private Fragment mFragment;
|
||||
private int fabOption;
|
||||
@@ -221,6 +225,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
@@ -848,7 +853,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar);
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -868,7 +873,17 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewMultiRedditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -931,10 +946,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
random();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||
if (mFragment instanceof PostFragment) {
|
||||
((PostFragment) mFragment).hideReadPosts();
|
||||
|
||||
@@ -335,7 +335,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
protected void applyCustomTheme() {
|
||||
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(mAppBarLayout, mCollapsingToolbarLayout, mToolbar);
|
||||
applyFABTheme(fab);
|
||||
applyFABTheme(fab, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
searchPanelMaterialCardView.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimary()));
|
||||
int searchPanelTextAndIconColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor();
|
||||
searchTextInputLayout.setBoxStrokeColor(searchPanelTextAndIconColor);
|
||||
@@ -425,11 +425,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
|
||||
|
||||
public void deleteComment(String fullName, int position) {
|
||||
public void deleteComment(int comment_id, int position) {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
|
||||
if (fragment != null) {
|
||||
fragment.deleteComment(fullName, position);
|
||||
fragment.deleteComment(comment_id, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,13 +229,15 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
if (fullnames.length() > 0) {
|
||||
fullnames.deleteCharAt(fullnames.length() - 1);
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, fullnames.toString(),
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, 0,
|
||||
new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {}
|
||||
public void readSuccess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFailed() {}
|
||||
public void readFailed() {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -332,7 +334,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
|
||||
@Subscribe
|
||||
public void onPassPrivateMessageEvent(PassPrivateMessageEvent passPrivateMessageEvent) {
|
||||
privateMessage = passPrivateMessageEvent.message;
|
||||
/* privateMessage = passPrivateMessageEvent.message;
|
||||
if (privateMessage != null) {
|
||||
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||
if (privateMessage.getReplies() != null) {
|
||||
@@ -351,7 +353,7 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
||||
}
|
||||
|
||||
bindView();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public interface ProvideUserAvatarCallback {
|
||||
|
||||
@@ -93,6 +93,7 @@ import eu.toldi.infinityforlemmy.fragments.SidebarFragment;
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -196,6 +197,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
private NavigationWrapper navigationWrapper;
|
||||
@@ -217,7 +221,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private boolean hideFab;
|
||||
private boolean showBottomAppBar;
|
||||
private boolean lockBottomAppBar;
|
||||
private String mMessageFullname;
|
||||
private int mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
private RequestManager glide;
|
||||
private int expandedTabTextColor;
|
||||
@@ -348,12 +352,12 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageFullname = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
} else {
|
||||
mFetchSubredditInfoSuccess = savedInstanceState.getBoolean(FETCH_SUBREDDIT_INFO_STATE);
|
||||
mNCurrentOnlineSubscribers = savedInstanceState.getInt(CURRENT_ONLINE_SUBSCRIBERS_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageFullname = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
|
||||
if (mFetchSubredditInfoSuccess) {
|
||||
@@ -416,7 +420,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
descriptionTextView.setTextColor(primaryTextColor);
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
if (typeface != null) {
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
subscribeSubredditChip.setTypeface(typeface);
|
||||
@@ -550,12 +554,9 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
creationTimeTextView.setText(subredditData.getCreatedUTC());
|
||||
description = subredditData.getDescription();
|
||||
|
||||
if (hideSubredditDescription || description.equals("")) {
|
||||
descriptionTextView.setVisibility(View.GONE);
|
||||
} else {
|
||||
descriptionTextView.setVisibility(View.VISIBLE);
|
||||
markwon.setMarkdown(descriptionTextView, description);
|
||||
}
|
||||
|
||||
descriptionTextView.setVisibility(View.GONE);
|
||||
|
||||
|
||||
if (subredditData.isNSFW()) {
|
||||
if (nsfwWarningBuilder == null
|
||||
@@ -868,11 +869,11 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
if (mMessageFullname != null) {
|
||||
if (mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1230,7 +1231,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(FETCH_SUBREDDIT_INFO_STATE, mFetchSubredditInfoSuccess);
|
||||
outState.putInt(CURRENT_ONLINE_SUBSCRIBERS_STATE, mNCurrentOnlineSubscribers);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
}
|
||||
|
||||
@@ -1398,10 +1399,6 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
random();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.hideReadPosts();
|
||||
@@ -1562,7 +1559,18 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewSubredditDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -95,6 +95,7 @@ import eu.toldi.infinityforlemmy.fragments.PostFragment;
|
||||
import eu.toldi.infinityforlemmy.markdown.MarkdownUtils;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.multireddit.MultiReddit;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
@@ -202,6 +203,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
CustomThemeWrapper mCustomThemeWrapper;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
public UserViewModel userViewModel;
|
||||
private FragmentManager fragmentManager;
|
||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||
@@ -210,6 +214,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private Call<String> subredditAutocompleteCall;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private String username;
|
||||
private String qualifiedName;
|
||||
private String description;
|
||||
@@ -228,7 +233,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private boolean hideFab;
|
||||
private boolean showBottomAppBar;
|
||||
private boolean lockBottomAppBar;
|
||||
private String mMessageFullname;
|
||||
private int mMessageId;
|
||||
private String mNewAccountName;
|
||||
|
||||
private UserData mUserData;
|
||||
@@ -272,15 +277,16 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageId = getIntent().getIntExtra(EXTRA_MESSAGE_FULLNAME, 0);
|
||||
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
|
||||
} else {
|
||||
mFetchUserInfoSuccess = savedInstanceState.getBoolean(FETCH_USER_INFO_STATE);
|
||||
mMessageFullname = savedInstanceState.getString(MESSAGE_FULLNAME_STATE);
|
||||
mMessageId = savedInstanceState.getInt(MESSAGE_FULLNAME_STATE);
|
||||
mNewAccountName = savedInstanceState.getString(NEW_ACCOUNT_NAME_STATE);
|
||||
}
|
||||
|
||||
@@ -625,7 +631,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
karmaTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
cakedayTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton, mSharedPreferences.getBoolean(SharedPreferencesUtils.USE_CIRCULAR_FAB, false));
|
||||
descriptionTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor());
|
||||
subscribeUserChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
@@ -700,11 +706,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
fixViewPager2Sensitivity(viewPager2);
|
||||
|
||||
if (mMessageFullname != null) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
if (mMessageId != 0) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageId, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageId = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1092,12 +1098,12 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteComment(String fullName) {
|
||||
public void deleteComment(int commentId) {
|
||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.delete_this_comment)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||
-> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
-> DeleteThing.deleteComment(mRetrofit.getRetrofit(), commentId, mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
@Override
|
||||
public void deleteSuccess() {
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
|
||||
@@ -1262,7 +1268,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess);
|
||||
outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname);
|
||||
outState.putInt(MESSAGE_FULLNAME_STATE, mMessageId);
|
||||
outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName);
|
||||
}
|
||||
|
||||
@@ -1335,10 +1341,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
goToUser();
|
||||
break;
|
||||
}
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_RANDOM: {
|
||||
random();
|
||||
break;
|
||||
}
|
||||
|
||||
case FABMoreOptionsBottomSheetFragment.FAB_HIDE_READ_POSTS: {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
sectionsPagerAdapter.hideReadPosts();
|
||||
@@ -1550,7 +1553,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
@Override
|
||||
public void markPostAsRead(Post post) {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
|
||||
markPostAsRead.markPostAsRead(post.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, post.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(ViewUserDetailActivity.this, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -161,7 +161,7 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
|
||||
public CommentsRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
||||
CustomThemeWrapper customThemeWrapper,
|
||||
Executor executor, Retrofit retrofit, Retrofit oauthRetrofit,
|
||||
Executor executor, Retrofit retrofit,
|
||||
String accessToken, String accountName,
|
||||
Post post, Locale locale, Integer singleCommentId,
|
||||
boolean isSingleCommentThreadMode,
|
||||
@@ -171,7 +171,6 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
||||
mFragment = fragment;
|
||||
mExecutor = executor;
|
||||
mRetrofit = retrofit;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
mGlide = Glide.with(activity);
|
||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||
mCommentTextColor = customThemeWrapper.getCommentColor();
|
||||
|
||||
@@ -19,10 +19,24 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeInboxCountEvent;
|
||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
import io.noties.markwon.Markwon;
|
||||
import io.noties.markwon.MarkwonConfiguration;
|
||||
@@ -33,40 +47,25 @@ import io.noties.markwon.inlineparser.HtmlInlineProcessor;
|
||||
import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin;
|
||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.LinkResolverActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPrivateMessagesActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewUserDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeInboxCountEvent;
|
||||
import eu.toldi.infinityforlemmy.markdown.RedditHeadingPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerAwareMovementMethod;
|
||||
import eu.toldi.infinityforlemmy.markdown.SpoilerParserPlugin;
|
||||
import eu.toldi.infinityforlemmy.markdown.SuperscriptPlugin;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, RecyclerView.ViewHolder> {
|
||||
public class MessageRecyclerViewAdapter extends PagedListAdapter<CommentInteraction, RecyclerView.ViewHolder> {
|
||||
private static final int VIEW_TYPE_DATA = 0;
|
||||
private static final int VIEW_TYPE_ERROR = 1;
|
||||
private static final int VIEW_TYPE_LOADING = 2;
|
||||
private static final DiffUtil.ItemCallback<Message> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
||||
private static final DiffUtil.ItemCallback<CommentInteraction> DIFF_CALLBACK = new DiffUtil.ItemCallback<>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull Message message, @NonNull Message t1) {
|
||||
return message.getId().equals(t1.getId());
|
||||
public boolean areItemsTheSame(@NonNull CommentInteraction message, @NonNull CommentInteraction t1) {
|
||||
return message.getComment().getId() == t1.getComment().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull Message message, @NonNull Message t1) {
|
||||
return message.getBody().equals(t1.getBody());
|
||||
public boolean areContentsTheSame(@NonNull CommentInteraction message, @NonNull CommentInteraction t1) {
|
||||
return message.getComment().getCommentMarkdown().equals(t1.getComment().getCommentMarkdown());
|
||||
}
|
||||
};
|
||||
private BaseActivity mActivity;
|
||||
private Retrofit mOauthRetrofit;
|
||||
private Retrofit retrofit;
|
||||
private Markwon mMarkwon;
|
||||
private String mAccessToken;
|
||||
private int mMessageType;
|
||||
@@ -88,7 +87,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
mActivity = activity;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
retrofit = oauthRetrofit;
|
||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||
|
||||
mColorAccent = customThemeWrapper.getColorAccent();
|
||||
@@ -154,41 +153,35 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof DataViewHolder) {
|
||||
Message message = getItem(holder.getBindingAdapterPosition());
|
||||
CommentInteraction message = getItem(holder.getBindingAdapterPosition());
|
||||
if (message != null) {
|
||||
ArrayList<Message> replies = message.getReplies();
|
||||
Message displayedMessage;
|
||||
if (replies != null && !replies.isEmpty() && replies.get(replies.size() - 1) != null) {
|
||||
displayedMessage = replies.get(replies.size() - 1);
|
||||
} else {
|
||||
displayedMessage = message;
|
||||
}
|
||||
if (message.isNew()) {
|
||||
|
||||
if (message.isRead()) {
|
||||
if (markAllMessagesAsRead) {
|
||||
message.setNew(false);
|
||||
message.markAsRead();
|
||||
} else {
|
||||
holder.itemView.setBackgroundColor(
|
||||
mUnreadMessageBackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (message.wasComment()) {
|
||||
((DataViewHolder) holder).titleTextView.setText(message.getTitle());
|
||||
} else {
|
||||
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
((DataViewHolder) holder).authorTextView.setText(displayedMessage.getAuthor());
|
||||
String subject = displayedMessage.getSubject().substring(0, 1).toUpperCase() + displayedMessage.getSubject().substring(1);
|
||||
((DataViewHolder) holder).titleTextView.setVisibility(View.GONE);
|
||||
|
||||
|
||||
((DataViewHolder) holder).authorTextView.setText(message.getComment().getAuthorQualifiedName());
|
||||
String subject = message.getComment().getCommunityQualifiedName();
|
||||
((DataViewHolder) holder).subjectTextView.setText(subject);
|
||||
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, displayedMessage.getBody());
|
||||
mMarkwon.setMarkdown(((DataViewHolder) holder).contentCustomMarkwonView, message.getComment().getCommentMarkdown());
|
||||
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
||||
&& message.getContext() != null && !message.getContext().equals("")) {
|
||||
Uri uri = Uri.parse(message.getContext());
|
||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||
intent.setData(uri);
|
||||
&& message.getComment() != null) {
|
||||
|
||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, message.getComment().getPostId());
|
||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, message.getComment().getId());
|
||||
mActivity.startActivity(intent);
|
||||
} else if (mMessageType == FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE) {
|
||||
Intent intent = new Intent(mActivity, ViewPrivateMessagesActivity.class);
|
||||
@@ -197,20 +190,21 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
|
||||
if (displayedMessage.isNew()) {
|
||||
if (message.isRead()) {
|
||||
holder.itemView.setBackgroundColor(mMessageBackgroundColor);
|
||||
message.setNew(false);
|
||||
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, message.getFullname(),
|
||||
|
||||
ReadMessage.readMessage(retrofit, mAccessToken, message.getId(),
|
||||
new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
message.markAsRead();
|
||||
EventBus.getDefault().post(new ChangeInboxCountEvent(-1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFailed() {
|
||||
message.setNew(true);
|
||||
message.markAsUnRead();
|
||||
holder.itemView.setBackgroundColor(mUnreadMessageBackgroundColor);
|
||||
}
|
||||
});
|
||||
@@ -218,11 +212,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
});
|
||||
|
||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||
if (message.isAuthorDeleted()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getComment().getAuthor());
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, message.getComment().getAuthorQualifiedName());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
@@ -280,9 +273,9 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMessageReply(Message newReply, int position) {
|
||||
public void updateMessageReply(CommentInteraction newReply, int position) {
|
||||
if (position >= 0 && position < super.getItemCount()) {
|
||||
Message message = getItem(position);
|
||||
CommentInteraction message = getItem(position);
|
||||
if (message != null) {
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,9 @@ import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.exoplayer2.Tracks;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.exoplayer2.ui.DefaultTimeBar;
|
||||
@@ -214,7 +216,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
public PostDetailRecyclerViewAdapter(BaseActivity activity, ViewPostDetailFragment fragment,
|
||||
Executor executor, CustomThemeWrapper customThemeWrapper,
|
||||
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
|
||||
Retrofit retrofit, Retrofit gfycatRetrofit,
|
||||
Retrofit redgifsRetrofit, Provider<StreamableAPI> streamableApiProvider,
|
||||
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
||||
boolean separatePostAndComments, String accessToken,
|
||||
@@ -229,7 +231,6 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
mFragment = fragment;
|
||||
mExecutor = executor;
|
||||
mRetrofit = retrofit;
|
||||
mOauthRetrofit = oauthRetrofit;
|
||||
mGfycatRetrofit = gfycatRetrofit;
|
||||
mRedgifsRetrofit = redgifsRetrofit;
|
||||
mStreamableApiProvider = streamableApiProvider;
|
||||
@@ -635,8 +636,20 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
|
||||
Post.Preview preview = getSuitablePreview(mPost.getPreviews());
|
||||
if (preview != null) {
|
||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView);
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) width / height);
|
||||
((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||
}
|
||||
@@ -844,9 +857,45 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
});
|
||||
|
||||
if (blurImage) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10))).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
}
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
}
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailImageAndGifAutoplayViewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (holder instanceof PostDetailVideoAndGifPreviewHolder) {
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||
@@ -872,9 +921,45 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
}
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailVideoAndGifPreviewHolder) holder).mImageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
}
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailVideoAndGifPreviewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (holder instanceof PostDetailLinkViewHolder) {
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(preview.getPreviewUrl())
|
||||
@@ -900,9 +985,51 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
||||
|
||||
if ((mPost.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()))) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostDetailLinkViewHolder) holder).mImageView);
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
} else {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostDetailLinkViewHolder) holder).mImageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(resource);
|
||||
if (preview.getPreviewHeight() == 0 || preview.getPreviewWidth() == 0) {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) height / width);
|
||||
((PostDetailLinkViewHolder) holder).mImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
} else {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
((PostDetailLinkViewHolder) holder).mImageView.setImageDrawable(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.exoplayer2.Tracks;
|
||||
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
|
||||
import com.google.android.exoplayer2.ui.DefaultTimeBar;
|
||||
@@ -439,7 +441,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
switch (post.getPostType()) {
|
||||
case Post.VIDEO_TYPE:
|
||||
if (mAutoplay) {
|
||||
if ((!mAutoplayNsfwVideos && post.isNSFW()) ) {
|
||||
if ((!mAutoplayNsfwVideos && post.isNSFW())) {
|
||||
return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
|
||||
}
|
||||
return VIEW_TYPE_POST_CARD_2_VIDEO_AUTOPLAY_TYPE;
|
||||
@@ -524,7 +526,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
|
||||
((PostBaseViewHolder) holder).titleTextView.setTextColor(mReadPostTitleColor);
|
||||
}
|
||||
String authorPrefixed = post.getAuthorNamePrefixed();
|
||||
String authorPrefixed = post.getAuthorNamePrefixed();
|
||||
|
||||
if (mHideSubredditAndUserPrefix) {
|
||||
((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditName());
|
||||
@@ -714,8 +716,28 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (!mFixedHeightPreviewInCard && preview != null) {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource);
|
||||
if (preview.getPreviewHeight() <= 0 || preview.getPreviewWidth() <= 0) {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) height / width);
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
} else {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = preview.getPreviewHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||
}
|
||||
@@ -752,7 +774,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||
} else if (post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||
((PostVideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||
mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
|
||||
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||
@@ -833,21 +855,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
if (preview != null) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
|
||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||
@@ -873,10 +886,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostBaseGalleryTypeViewHolder) holder).imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size()));
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (preview != null) {
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
} else {
|
||||
((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
} else {
|
||||
((PostBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
@@ -886,7 +897,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
(post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit())));
|
||||
}
|
||||
} else if (holder instanceof PostTextTypeViewHolder) {
|
||||
if (!mHideTextPostContent && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
|
||||
if (!mHideTextPostContent && post.getSelfTextPlainTrimmed() != null && !post.getSelfTextPlainTrimmed().equals("")) {
|
||||
((PostTextTypeViewHolder) holder).contentTextView.setVisibility(View.VISIBLE);
|
||||
if (post.isRead()) {
|
||||
((PostTextTypeViewHolder) holder).contentTextView.setTextColor(mReadPostContentColor);
|
||||
@@ -897,8 +908,28 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostCard2VideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
|
||||
Post.Preview preview = getSuitablePreview(post.getPreviews());
|
||||
if (!mFixedHeightPreviewInCard && preview != null) {
|
||||
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
|
||||
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
int width = resource.getIntrinsicWidth();
|
||||
int height = resource.getIntrinsicHeight();
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.setImageDrawable(resource);
|
||||
if (preview.getPreviewHeight() <= 0 || preview.getPreviewWidth() <= 0) {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) height / width);
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height;
|
||||
preview.setPreviewHeight(height);
|
||||
preview.setPreviewWidth(width);
|
||||
} else {
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
((PostVideoAutoplayViewHolder) holder).previewImageView.getLayoutParams().height = height;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio(1);
|
||||
}
|
||||
@@ -935,7 +966,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if(post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||
} else if (post.isStreamable() && !post.isLoadGfycatOrStreamableVideoSuccess()) {
|
||||
((PostCard2VideoAutoplayViewHolder) holder).fetchGfycatOrStreamableVideoCall =
|
||||
mStreamableApiProvider.get().getStreamableData(post.getStreamableShortCode());
|
||||
FetchStreamableVideo.fetchStreamableVideoInRecyclerViewAdapter(mExecutor, new Handler(),
|
||||
@@ -1023,21 +1054,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostCard2WithPreviewViewHolder) holder).preview = preview;
|
||||
if (preview != null) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostCard2WithPreviewViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
@@ -1078,7 +1100,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
final String subredditNamePrefixed = post.getSubredditNamePrefixed();
|
||||
String subredditName = subredditNamePrefixed.substring(2);
|
||||
String authorPrefixed = post.getAuthorNamePrefixed();
|
||||
String authorPrefixed = post.getAuthorNamePrefixed();
|
||||
final String title = post.getTitle();
|
||||
int voteType = post.getVoteType();
|
||||
boolean nsfw = post.isNSFW();
|
||||
@@ -1401,21 +1423,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
@@ -1423,7 +1436,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
break;
|
||||
}
|
||||
case Post.GIF_TYPE: {
|
||||
if (post.getPostType() == Post.GIF_TYPE && ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mAutoplay && mAutoplayNsfwVideos)) )) {
|
||||
if (post.getPostType() == Post.GIF_TYPE && ((post.isNSFW() && mNeedBlurNsfw && !(mDoNotBlurNsfwInNsfwSubreddits && mFragment != null && mFragment.getIsNsfwSubreddit()) && !(mAutoplay && mAutoplayNsfwVideos)))) {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
} else {
|
||||
@@ -1435,21 +1448,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
|
||||
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_image_24dp);
|
||||
@@ -1466,21 +1470,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
|
||||
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_outline_video_24dp);
|
||||
@@ -1496,21 +1491,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).videoOrGifIndicatorImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_link_post_type_indicator));
|
||||
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
int height = (int) (400 * mScale);
|
||||
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView
|
||||
.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
((PostGalleryViewHolder) holder).imageView.removeOnLayoutChangeListener(this);
|
||||
loadImage(holder);
|
||||
}
|
||||
});
|
||||
loadImage(holder);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).noPreviewImageView.setImageResource(R.drawable.ic_link);
|
||||
@@ -1549,10 +1535,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).frameLayout.setVisibility(View.VISIBLE);
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).imageIndexTextView.setText(mActivity.getString(R.string.image_index_in_gallery, 1, post.getGallery().size()));
|
||||
if (preview != null) {
|
||||
if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
|
||||
if (mFixedHeightPreviewInCard) {
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
} else {
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio((float) preview.getPreviewHeight() / preview.getPreviewWidth());
|
||||
}
|
||||
} else {
|
||||
((PostGalleryBaseGalleryTypeViewHolder) holder).adapter.setRatio(-1);
|
||||
@@ -1605,9 +1589,71 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(((PostWithPreviewTypeViewHolder) holder).glideRequestListener);
|
||||
if (blurImage) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(1);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostWithPreviewTypeViewHolder) holder).imageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setRatio(1);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostWithPreviewTypeViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostWithPreviewTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (holder instanceof PostCompactBaseViewHolder) {
|
||||
@@ -1645,9 +1691,71 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
|
||||
if (blurImage) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostGalleryViewHolder) holder).imageView);
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(1);
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostGalleryViewHolder) holder).imageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostGalleryViewHolder) holder).imageView.setRatio(1);
|
||||
((PostGalleryViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostGalleryViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostGalleryViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (holder instanceof PostCard2WithPreviewViewHolder) {
|
||||
@@ -1665,9 +1773,71 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
|
||||
if (blurImage) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
||||
.into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(1);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(((PostCard2WithPreviewViewHolder) holder).imageView);
|
||||
imageRequestBuilder.centerInside().downsample(mSaveMemoryCenterInsideDownsampleStrategy).into(new CustomTarget<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
int height = resource.getIntrinsicHeight();
|
||||
if (!mFixedHeightPreviewInCard) {
|
||||
float imageRatio = (float) resource.getIntrinsicHeight() / resource.getIntrinsicWidth();
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(imageRatio);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(resource);
|
||||
} else {
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(-1);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
|
||||
}
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
// Reset to default aspect ratio
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setRatio(1);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setImageDrawable(placeholder);
|
||||
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.GONE);
|
||||
((PostCard2WithPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3307,7 +3477,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
downY = e.getRawY();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
|
||||
if (Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
|
||||
dragged = true;
|
||||
}
|
||||
break;
|
||||
@@ -3510,21 +3680,21 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
}
|
||||
|
||||
void setBaseView(AspectRatioGifImageView iconGifImageView,
|
||||
TextView nameTextView, ImageView stickiedPostImageView,
|
||||
TextView postTimeTextView, ConstraintLayout titleAndImageConstraintLayout,
|
||||
TextView titleTextView, CustomTextView typeTextView,
|
||||
ImageView archivedImageView, ImageView lockedImageView,
|
||||
ImageView crosspostImageView, CustomTextView nsfwTextView,
|
||||
CustomTextView spoilerTextView, CustomTextView flairTextView,
|
||||
CustomTextView awardsTextView, TextView linkTextView,
|
||||
RelativeLayout relativeLayout, ProgressBar progressBar,
|
||||
ImageView imageView, ImageView playButtonImageView,
|
||||
FrameLayout noPreviewLinkImageFrameLayout,
|
||||
ImageView noPreviewLinkImageView, Barrier imageBarrier,
|
||||
ConstraintLayout bottomConstraintLayout, ImageView upvoteButton,
|
||||
TextView scoreTextView, ImageView downvoteButton,
|
||||
TextView commentsCountTextView, ImageView saveButton,
|
||||
ImageView shareButton, View divider) {
|
||||
TextView nameTextView, ImageView stickiedPostImageView,
|
||||
TextView postTimeTextView, ConstraintLayout titleAndImageConstraintLayout,
|
||||
TextView titleTextView, CustomTextView typeTextView,
|
||||
ImageView archivedImageView, ImageView lockedImageView,
|
||||
ImageView crosspostImageView, CustomTextView nsfwTextView,
|
||||
CustomTextView spoilerTextView, CustomTextView flairTextView,
|
||||
CustomTextView awardsTextView, TextView linkTextView,
|
||||
RelativeLayout relativeLayout, ProgressBar progressBar,
|
||||
ImageView imageView, ImageView playButtonImageView,
|
||||
FrameLayout noPreviewLinkImageFrameLayout,
|
||||
ImageView noPreviewLinkImageView, Barrier imageBarrier,
|
||||
ConstraintLayout bottomConstraintLayout, ImageView upvoteButton,
|
||||
TextView scoreTextView, ImageView downvoteButton,
|
||||
TextView commentsCountTextView, ImageView saveButton,
|
||||
ImageView shareButton, View divider) {
|
||||
this.iconGifImageView = iconGifImageView;
|
||||
this.nameTextView = nameTextView;
|
||||
this.stickiedPostImageView = stickiedPostImageView;
|
||||
@@ -4419,7 +4589,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
||||
downTime = System.currentTimeMillis();
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
|
||||
if (Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
|
||||
dragged = true;
|
||||
}
|
||||
if (!dragged) {
|
||||
|
||||
@@ -24,8 +24,8 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
|
||||
private static final int VIEW_TYPE_MENU_GROUP_TITLE = 1;
|
||||
private static final int VIEW_TYPE_MENU_ITEM = 2;
|
||||
private static final int ACCOUNT_SECTION_ITEMS = 5;
|
||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 3;
|
||||
private static final int ACCOUNT_SECTION_ITEMS = 4;
|
||||
private static final int ANONYMOUS_ACCOUNT_SECTION_ITEMS = 2;
|
||||
|
||||
private BaseActivity baseActivity;
|
||||
private int inboxCount;
|
||||
@@ -101,10 +101,6 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
||||
break;
|
||||
case 3:
|
||||
stringId = R.string.multi_reddit;
|
||||
drawableId = R.drawable.ic_multi_reddit_24dp;
|
||||
break;
|
||||
case 4:
|
||||
setOnClickListener = false;
|
||||
if (inboxCount > 0) {
|
||||
((MenuItemViewHolder) holder).menuTextView.setText(baseActivity.getString(R.string.inbox_with_count, inboxCount));
|
||||
@@ -118,23 +114,21 @@ public class AccountSectionRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
});
|
||||
break;
|
||||
default:
|
||||
stringId = R.string.history;
|
||||
drawableId = R.drawable.ic_history_24dp;
|
||||
|
||||
stringId = R.string.account_saved_thing_activity_label;
|
||||
drawableId = R.drawable.ic_outline_bookmarks_24dp;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (position) {
|
||||
|
||||
case 1:
|
||||
stringId = R.string.subscriptions;
|
||||
drawableId = R.drawable.ic_subscritptions_bottom_app_bar_24dp;
|
||||
break;
|
||||
case 2:
|
||||
stringId = R.string.multi_reddit;
|
||||
drawableId = R.drawable.ic_multi_reddit_24dp;
|
||||
break;
|
||||
default:
|
||||
stringId = R.string.history;
|
||||
drawableId = R.drawable.ic_history_24dp;
|
||||
stringId = R.string.anonymous_account_instance;
|
||||
drawableId = R.drawable.ic_account_circle_24dp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ import eu.toldi.infinityforlemmy.subscribedsubreddit.SubscribedSubredditData;
|
||||
public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
private HeaderSectionRecyclerViewAdapter headerSectionRecyclerViewAdapter;
|
||||
private AccountSectionRecyclerViewAdapter accountSectionRecyclerViewAdapter;
|
||||
private RedditSectionRecyclerViewAdapter redditSectionRecyclerViewAdapter;
|
||||
private PostSectionRecyclerViewAdapter postSectionRecyclerViewAdapter;
|
||||
private PreferenceSectionRecyclerViewAdapter preferenceSectionRecyclerViewAdapter;
|
||||
private FavoriteSubscribedSubredditsSectionRecyclerViewAdapter favoriteSubscribedSubredditsSectionRecyclerViewAdapter;
|
||||
private SubscribedSubredditsRecyclerViewAdapter subscribedSubredditsRecyclerViewAdapter;
|
||||
@@ -49,10 +47,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
});
|
||||
accountSectionRecyclerViewAdapter = new AccountSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
||||
redditSectionRecyclerViewAdapter = new RedditSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, itemClickListener, accountName != null);
|
||||
postSectionRecyclerViewAdapter = new PostSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
navigationDrawerSharedPreferences, accountName != null, itemClickListener);
|
||||
preferenceSectionRecyclerViewAdapter = new PreferenceSectionRecyclerViewAdapter(baseActivity, customThemeWrapper,
|
||||
accountName, nsfwAndSpoilerSharedPreferences, navigationDrawerSharedPreferences, itemClickListener);
|
||||
favoriteSubscribedSubredditsSectionRecyclerViewAdapter = new FavoriteSubscribedSubredditsSectionRecyclerViewAdapter(
|
||||
@@ -65,8 +59,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
mainPageConcatAdapter = new ConcatAdapter(
|
||||
headerSectionRecyclerViewAdapter,
|
||||
accountSectionRecyclerViewAdapter,
|
||||
redditSectionRecyclerViewAdapter,
|
||||
postSectionRecyclerViewAdapter,
|
||||
preferenceSectionRecyclerViewAdapter,
|
||||
favoriteSubscribedSubredditsSectionRecyclerViewAdapter,
|
||||
subscribedSubredditsRecyclerViewAdapter);
|
||||
@@ -78,8 +70,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
|
||||
private void openAccountSection() {
|
||||
mainPageConcatAdapter.removeAdapter(accountSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(redditSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(postSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(preferenceSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.removeAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||
@@ -91,8 +81,6 @@ public class NavigationDrawerRecyclerViewMergedAdapter {
|
||||
mainPageConcatAdapter.removeAdapter(accountManagementSectionRecyclerViewAdapter);
|
||||
|
||||
mainPageConcatAdapter.addAdapter(accountSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(redditSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(postSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(preferenceSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(favoriteSubscribedSubredditsSectionRecyclerViewAdapter);
|
||||
mainPageConcatAdapter.addAdapter(subscribedSubredditsRecyclerViewAdapter);
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.apis;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import eu.toldi.infinityforlemmy.dto.AccountLoginDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.AuthDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.CommentVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.DeleteCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.DeletePostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.FollowCommunityDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.PostVoteDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadMessageDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SaveCommentDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SavePostDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.SubmitPostDTO;
|
||||
import eu.toldi.infinityforlemmy.message.MessageCount;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Response;
|
||||
@@ -32,6 +42,30 @@ public interface LemmyAPI {
|
||||
@GET("api/v3/user")
|
||||
Call<String> userInfo(@Query("username") String username, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/user/mention")
|
||||
Call<String> userMentions(@Query("sort") String sort, @Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/user/replies")
|
||||
Call<String> userReplies(@Query("sort") String sort, @Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/private_message/list")
|
||||
Call<String> privateMessageList(@Query("page") Integer page, @Query("limit") Integer limit, @Query("unread_only") boolean unread_only, @Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/user/unread_count")
|
||||
Call<MessageCount> userUnreadCount(@NonNull @Query("auth") String access_token);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/user/mention/mark_as_read")
|
||||
Call<String> userMentionMarkAsRead(@Body ReadMessageDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/comment/mark_as_read")
|
||||
Call<String> commentMarkAsRead(@Body ReadCommentDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/user/mark_all_as_read")
|
||||
Call<String> userMarkAllAsRead(@Body AuthDTO params);
|
||||
|
||||
@GET("api/v3/community")
|
||||
Call<String> communityInfo(@Query("name") String name, @Query("auth") String access_token);
|
||||
|
||||
@@ -42,6 +76,14 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/post")
|
||||
Call<String> postCreate(@Body SubmitPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/post")
|
||||
Call<String> postUpdate(@Body EditPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post/delete")
|
||||
Call<String> postDelete(@Body DeletePostDTO params);
|
||||
|
||||
@GET("api/v3/user")
|
||||
ListenableFuture<Response<String>> getUserPosts(
|
||||
@Query("username") String username,
|
||||
@@ -98,6 +140,10 @@ public interface LemmyAPI {
|
||||
@PUT("api/v3/post/save")
|
||||
Call<String> postSave(@Body SavePostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/post/mark_as_read")
|
||||
Call<String> postRead(@Body ReadPostDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/comment/save")
|
||||
Call<String> commentSave(@Body SaveCommentDTO params);
|
||||
@@ -149,6 +195,10 @@ public interface LemmyAPI {
|
||||
@POST("api/v3/comment")
|
||||
Call<String> postComment(@Body CommentDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@POST("api/v3/comment/delete")
|
||||
Call<String> commentDelete(@Body DeleteCommentDTO params);
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@PUT("api/v3/comment")
|
||||
Call<String> commentEdit(@Body EditCommentDTO params);
|
||||
@@ -159,4 +209,16 @@ public interface LemmyAPI {
|
||||
@Header("Cookie") String token,
|
||||
@Part MultipartBody.Part filePart
|
||||
);
|
||||
|
||||
@GET("api/v3/resolve_object")
|
||||
Call<String> resolveObject(
|
||||
@Query("q") String query,
|
||||
@Query("auth") String auth
|
||||
);
|
||||
|
||||
@GET("api/v3/comment")
|
||||
Call<String> getComment(
|
||||
@Query("id") int commentId,
|
||||
@Query("auth") String auth
|
||||
);
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ public class CommentMoreBottomSheetFragment extends LandscapeExpandedRoundedBott
|
||||
deleteTextView.setOnClickListener(view -> {
|
||||
dismiss();
|
||||
if (activity instanceof ViewPostDetailActivity) {
|
||||
((ViewPostDetailActivity) activity).deleteComment(comment.getFullName(), bundle.getInt(EXTRA_POSITION));
|
||||
((ViewPostDetailActivity) activity).deleteComment(comment.getId(), bundle.getInt(EXTRA_POSITION));
|
||||
} else if (activity instanceof ViewUserDetailActivity) {
|
||||
((ViewUserDetailActivity) activity).deleteComment(comment.getFullName());
|
||||
((ViewUserDetailActivity) activity).deleteComment(comment.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
|
||||
public static final int FAB_OPTION_SEARCH = 4;
|
||||
public static final int FAB_OPTION_GO_TO_SUBREDDIT = 5;
|
||||
public static final int FAB_OPTION_GO_TO_USER = 6;
|
||||
public static final int FAB_RANDOM = 7;
|
||||
public static final int FAB_HIDE_READ_POSTS = 8;
|
||||
public static final int FAB_FILTER_POSTS = 9;
|
||||
public static final int FAB_GO_TO_TOP = 10;
|
||||
@@ -86,10 +85,6 @@ public class FABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedB
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.randomTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||
activity.fabOptionSelected(FAB_RANDOM);
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.filterPostsTextViewFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> {
|
||||
activity.fabOptionSelected(FAB_FILTER_POSTS);
|
||||
|
||||
@@ -31,16 +31,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
||||
|
||||
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
|
||||
|
||||
@BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView relevanceTypeTextView;
|
||||
@BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView hotTypeTextView;
|
||||
@BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView topTypeTextView;
|
||||
@BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView newTypeTextView;
|
||||
@BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView commentsTypeTextView;
|
||||
@BindView(R.id.old_type_text_view_search_sort_type_bottom_sheet_fragment)
|
||||
TextView oldTypeTextView;
|
||||
private BaseActivity activity;
|
||||
public SearchPostSortTypeBottomSheetFragment() {
|
||||
// Required empty public constructor
|
||||
@@ -61,14 +57,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
||||
ButterKnife.bind(this, rootView);
|
||||
|
||||
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
|
||||
if (currentSortType.equals(SortType.Type.HOT.fullName)) {
|
||||
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||
} else if (currentSortType.equals(SortType.Type.TOP.fullName)) {
|
||||
if (currentSortType.equals(SortType.Type.TOP.fullName)) {
|
||||
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
|
||||
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||
} else if (currentSortType.equals(SortType.Type.OLD.fullName)) {
|
||||
commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||
oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||
@@ -76,15 +70,6 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
||||
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
}
|
||||
|
||||
/*relevanceTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name());
|
||||
dismiss();
|
||||
});*/
|
||||
|
||||
hotTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name());
|
||||
dismiss();
|
||||
});
|
||||
|
||||
topTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name());
|
||||
@@ -92,12 +77,12 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
|
||||
});
|
||||
|
||||
newTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW));
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW,null));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
commentsTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.MOST_COMMENTS.name());
|
||||
oldTypeTextView.setOnClickListener(view -> {
|
||||
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD,null));
|
||||
dismiss();
|
||||
});
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ public class Comment implements Parcelable {
|
||||
private int depth;
|
||||
private int childCount;
|
||||
private boolean collapsed;
|
||||
|
||||
private boolean isDeleted;
|
||||
private boolean hasReply;
|
||||
private boolean saved;
|
||||
private boolean isExpanded;
|
||||
@@ -67,7 +69,7 @@ public class Comment implements Parcelable {
|
||||
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
||||
String linkId, String communityName, String communityQualifiedName, Integer parentId, int score,
|
||||
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
||||
int depth, boolean collapsed, boolean hasReply, boolean saved, long edited, String[] path) {
|
||||
int depth, boolean collapsed, boolean hasReply, boolean saved, boolean deleted, long edited, String[] path) {
|
||||
this.id = id;
|
||||
this.postId = postId;
|
||||
this.fullName = fullName;
|
||||
@@ -90,6 +92,7 @@ public class Comment implements Parcelable {
|
||||
this.collapsed = collapsed;
|
||||
this.hasReply = hasReply;
|
||||
this.saved = saved;
|
||||
this.isDeleted = deleted;
|
||||
this.isExpanded = false;
|
||||
this.hasExpandedBefore = false;
|
||||
this.editedTimeMillis = edited;
|
||||
|
||||
@@ -5,6 +5,9 @@ import android.os.Handler;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@@ -98,6 +101,32 @@ public class FetchComment {
|
||||
});
|
||||
}
|
||||
|
||||
public static void fetchSingleComment(Retrofit retrofit, @Nullable String accessToken, int commentId,
|
||||
FetchCommentListener fetchCommentListener) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
Call<String> comment = api.getComment(commentId, accessToken);
|
||||
comment.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
try {
|
||||
Comment c = ParseComment.parseSingleComment(new JSONObject(response.body()).getJSONObject("comment_view"));
|
||||
ArrayList<Comment> comments = new ArrayList<>();
|
||||
comments.add(c);
|
||||
fetchCommentListener.onFetchCommentSuccess(comments, null, null);
|
||||
} catch (JSONException e) {
|
||||
fetchCommentListener.onFetchCommentFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
fetchCommentListener.onFetchCommentFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface FetchCommentListener {
|
||||
void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children);
|
||||
|
||||
|
||||
@@ -327,11 +327,12 @@ public class ParseComment {
|
||||
boolean collapsed = false;
|
||||
boolean hasReply = countsObj.getInt("child_count") > 0;
|
||||
boolean saved = jsonObject.getBoolean("saved");
|
||||
boolean deleted = commentObj.getBoolean("deleted");
|
||||
long edited = 0;
|
||||
|
||||
Comment comment = new Comment(id,postID, fullName, author, authorQualifiedName, linkAuthor, commentTimeMillis,
|
||||
Comment comment = new Comment(id, postID, fullName, author, authorQualifiedName, linkAuthor, commentTimeMillis,
|
||||
commentMarkdown, commentRawText, linkId, communityName, communityQualifiedName, parentId,
|
||||
score, voteType, isSubmitter, distinguished, permalink, depth, collapsed, hasReply, saved, edited, path);
|
||||
score, voteType, isSubmitter, distinguished, permalink, depth, collapsed, hasReply, saved, deleted, edited, path);
|
||||
int child_count = countsObj.getInt("child_count");
|
||||
comment.setChildCount(child_count);
|
||||
return comment;
|
||||
|
||||
14
app/src/main/java/eu/toldi/infinityforlemmy/dto/AuthDTO.java
Normal file
14
app/src/main/java/eu/toldi/infinityforlemmy/dto/AuthDTO.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class AuthDTO {
|
||||
|
||||
private String auth;
|
||||
|
||||
public AuthDTO(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class DeleteCommentDTO {
|
||||
|
||||
private int comment_id;
|
||||
boolean deleted;
|
||||
String auth;
|
||||
|
||||
public DeleteCommentDTO(int comment_id, boolean deleted, String auth) {
|
||||
this.comment_id = comment_id;
|
||||
this.deleted = deleted;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getComment_id() {
|
||||
return comment_id;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class DeletePostDTO {
|
||||
|
||||
int post_id;
|
||||
boolean deleted;
|
||||
String auth;
|
||||
|
||||
public DeletePostDTO(int post_id, boolean deleted, String auth) {
|
||||
this.post_id = post_id;
|
||||
this.deleted = deleted;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPost_id() {
|
||||
return post_id;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class EditPostDTO {
|
||||
|
||||
private int post_id;
|
||||
private String name;
|
||||
private String url;
|
||||
private String body;
|
||||
private boolean nsfw;
|
||||
private Integer language_id;
|
||||
private String auth;
|
||||
|
||||
public EditPostDTO(int post_id, String name, String url, String body, boolean nsfw, Integer language_id, String auth) {
|
||||
this.post_id = post_id;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.body = body;
|
||||
this.nsfw = nsfw;
|
||||
this.language_id = language_id;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPost_id() {
|
||||
return post_id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public boolean isNsfw() {
|
||||
return nsfw;
|
||||
}
|
||||
|
||||
public Integer getLanguage_id() {
|
||||
return language_id;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadCommentDTO {
|
||||
|
||||
private int comment_reply_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadCommentDTO(int comment_reply_id, boolean read, String auth) {
|
||||
this.comment_reply_id = comment_reply_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getComment_reply_id() {
|
||||
return comment_reply_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadMessageDTO {
|
||||
|
||||
private int person_mention_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadMessageDTO(int person_mention_id, boolean read, String auth) {
|
||||
this.person_mention_id = person_mention_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPerson_mention_id() {
|
||||
return person_mention_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package eu.toldi.infinityforlemmy.dto;
|
||||
|
||||
public class ReadPostDTO {
|
||||
|
||||
private int post_id;
|
||||
private boolean read;
|
||||
private String auth;
|
||||
|
||||
public ReadPostDTO(int post_id, boolean read, String auth) {
|
||||
this.post_id = post_id;
|
||||
this.read = read;
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public int getPost_id() {
|
||||
return post_id;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return read;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package eu.toldi.infinityforlemmy.events;
|
||||
|
||||
public class ChangeUseCircularFabEvent {
|
||||
|
||||
private boolean useCircularFab;
|
||||
|
||||
public ChangeUseCircularFabEvent(boolean useCircularFab) {
|
||||
this.useCircularFab = useCircularFab;
|
||||
}
|
||||
|
||||
public boolean isUseCircularFab() {
|
||||
return useCircularFab;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package eu.toldi.infinityforlemmy.events;
|
||||
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
|
||||
public class PassPrivateMessageEvent {
|
||||
public Message message;
|
||||
public CommentInteraction message;
|
||||
|
||||
public PassPrivateMessageEvent(Message message) {
|
||||
public PassPrivateMessageEvent(CommentInteraction message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +35,15 @@ import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.RecyclerViewContentScrollingInterface;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.activities.BaseActivity;
|
||||
import eu.toldi.infinityforlemmy.adapters.MessageRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.events.RepliedToPrivateMessageEvent;
|
||||
import eu.toldi.infinityforlemmy.message.CommentInteraction;
|
||||
import eu.toldi.infinityforlemmy.message.FetchMessage;
|
||||
import eu.toldi.infinityforlemmy.message.Message;
|
||||
import eu.toldi.infinityforlemmy.message.MessageViewModel;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
@@ -61,8 +61,8 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
TextView mFetchMessageInfoTextView;
|
||||
MessageViewModel mMessageViewModel;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Named("no_oauth")
|
||||
RetrofitHolder mRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
@@ -106,7 +106,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
|
||||
mWhere = arguments.getString(EXTRA_MESSAGE_WHERE, FetchMessage.WHERE_INBOX);
|
||||
mAdapter = new MessageRecyclerViewAdapter(mActivity, mOauthRetrofit, mCustomThemeWrapper,
|
||||
mAdapter = new MessageRecyclerViewAdapter(mActivity, mRetrofit.getRetrofit(), mCustomThemeWrapper,
|
||||
mAccessToken, mWhere, () -> mMessageViewModel.retryLoadingMore());
|
||||
mLinearLayoutManager = new LinearLayoutManagerBugFixed(mActivity);
|
||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||
@@ -127,7 +127,7 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
});
|
||||
}
|
||||
|
||||
MessageViewModel.Factory factory = new MessageViewModel.Factory(mOauthRetrofit,
|
||||
MessageViewModel.Factory factory = new MessageViewModel.Factory(mRetrofit.getRetrofit(),
|
||||
getResources().getConfiguration().locale, mAccessToken, mWhere);
|
||||
mMessageViewModel = new ViewModelProvider(this, factory).get(MessageViewModel.class);
|
||||
mMessageViewModel.getMessages().observe(getViewLifecycleOwner(), messages -> mAdapter.submitList(messages));
|
||||
@@ -216,11 +216,11 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
mAdapter.setNetworkState(null);
|
||||
}
|
||||
|
||||
public Message getMessageByIndex(int index) {
|
||||
public CommentInteraction getMessageByIndex(int index) {
|
||||
if (mMessageViewModel == null || index < 0) {
|
||||
return null;
|
||||
}
|
||||
PagedList<Message> messages = mMessageViewModel.getMessages().getValue();
|
||||
PagedList<CommentInteraction> messages = mMessageViewModel.getMessages().getValue();
|
||||
if (messages == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -245,8 +245,8 @@ public class InboxFragment extends Fragment implements FragmentCommunicator {
|
||||
|
||||
@Subscribe
|
||||
public void onRepliedToPrivateMessageEvent(RepliedToPrivateMessageEvent repliedToPrivateMessageEvent) {
|
||||
if (mAdapter != null && mWhere.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||
/* if (mAdapter != null && mWhere.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||
mAdapter.updateMessageReply(repliedToPrivateMessageEvent.newReply, repliedToPrivateMessageEvent.messagePosition);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -460,9 +460,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
nameOfUsage = PostFilterUsage.NO_USAGE;
|
||||
|
||||
String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.TOP_ALL.value);
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
||||
String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sort.equalsIgnoreCase(SortType.Type.TOP.value) ? SortType.Time.ALL.name() : null);
|
||||
SortType.Type st = SortType.Type.fromValue(sort);
|
||||
sortType = new SortType(st == null ? SortType.Type.TOP_ALL : st, SortType.Time.valueOf(sortTime));
|
||||
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,
|
||||
@@ -1385,6 +1385,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, sortType.getType().name()).apply();
|
||||
if (sortType.getTime() != null) {
|
||||
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, sortType.getTime().name()).apply();
|
||||
}else {
|
||||
mSortTypeSharedPreferences.edit().remove(SharedPreferencesUtils.SORT_TIME_SEARCH_POST).apply();
|
||||
}
|
||||
break;
|
||||
case PostPagingSource.TYPE_MULTI_REDDIT:
|
||||
|
||||
@@ -85,7 +85,7 @@ import eu.toldi.infinityforlemmy.activities.SubmitCrosspostActivity;
|
||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||
import eu.toldi.infinityforlemmy.adapters.CommentsRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.adapters.PostDetailRecyclerViewAdapter;
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||
import eu.toldi.infinityforlemmy.asynctasks.LoadUserData;
|
||||
import eu.toldi.infinityforlemmy.bottomsheetfragments.FlairBottomSheetFragment;
|
||||
@@ -97,6 +97,7 @@ import eu.toldi.infinityforlemmy.comment.FetchRemovedCommentReveddit;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomToroContainer;
|
||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||
import eu.toldi.infinityforlemmy.dto.EditPostDTO;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeNSFWBlurEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeNetworkStatusEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeSpoilerBlurEvent;
|
||||
@@ -107,6 +108,7 @@ import eu.toldi.infinityforlemmy.message.ReadMessage;
|
||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||
import eu.toldi.infinityforlemmy.post.FetchRemovedPost;
|
||||
import eu.toldi.infinityforlemmy.post.HidePost;
|
||||
import eu.toldi.infinityforlemmy.post.MarkPostAsRead;
|
||||
import eu.toldi.infinityforlemmy.post.Post;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||
@@ -154,9 +156,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
@Named("reveddit")
|
||||
Retrofit revedditRetrofit;
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
@Named("gfycat")
|
||||
Retrofit mGfycatRetrofit;
|
||||
@Inject
|
||||
@@ -190,6 +189,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
ExoCreator mExoCreator;
|
||||
@Inject
|
||||
Executor mExecutor;
|
||||
@Inject
|
||||
MarkPostAsRead markPostAsRead;
|
||||
@State
|
||||
Post mPost;
|
||||
@State
|
||||
@@ -212,7 +213,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
@State
|
||||
boolean isFetchingComments = false;
|
||||
@State
|
||||
String mMessageFullname;
|
||||
int mMessageFullname;
|
||||
@State
|
||||
SortType.Type sortType;
|
||||
@State
|
||||
@@ -225,6 +226,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
private Menu mMenu;
|
||||
private String mAccessToken;
|
||||
private String mAccountName;
|
||||
private String mAccountQualifiedName;
|
||||
private int postListPosition = -1;
|
||||
private Integer mSingleCommentId;
|
||||
private String mContextNumber;
|
||||
@@ -277,6 +279,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
|
||||
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
mAccountQualifiedName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_QUALIFIED_NAME, null);
|
||||
|
||||
mSavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_toolbar_24dp);
|
||||
mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp);
|
||||
@@ -307,7 +310,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(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
|
||||
mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountQualifiedName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false);
|
||||
if (savedInstanceState == null) {
|
||||
mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false);
|
||||
viewPostDetailFragmentId = System.currentTimeMillis();
|
||||
@@ -550,7 +553,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
if (mSingleCommentId != 0) {
|
||||
isSingleCommentThreadMode = true;
|
||||
}
|
||||
mMessageFullname = getArguments().getString(EXTRA_MESSAGE_FULLNAME);
|
||||
mMessageFullname = getArguments().getInt(EXTRA_MESSAGE_FULLNAME);
|
||||
|
||||
if (!mRespectSubredditRecommendedSortType || isSingleCommentThreadMode) {
|
||||
sortType = loadSortType();
|
||||
@@ -572,11 +575,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
private void bindView() {
|
||||
if (mAccessToken != null && mMessageFullname != null) {
|
||||
ReadMessage.readMessage(mOauthRetrofit, mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
if (mAccessToken != null && mMessageFullname != 0) {
|
||||
ReadMessage.readMessage(mRetrofit.getRetrofit(), mAccessToken, mMessageFullname, new ReadMessage.ReadMessageListener() {
|
||||
@Override
|
||||
public void readSuccess() {
|
||||
mMessageFullname = null;
|
||||
mMessageFullname = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -596,13 +599,13 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
setupMenu();
|
||||
|
||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||
this, mExecutor, mCustomThemeWrapper, mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit,
|
||||
this, mExecutor, mCustomThemeWrapper, mRetrofit.getRetrofit(), mGfycatRetrofit,
|
||||
mRedgifsRetrofit, mStreamableApiProvider, mRedditDataRoomDatabase, mGlide,
|
||||
mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale,
|
||||
mSharedPreferences, mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences,
|
||||
mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||
this, mCustomThemeWrapper, mExecutor, mRetrofit.getRetrofit(), mOauthRetrofit,
|
||||
this, mCustomThemeWrapper, mExecutor, mRetrofit.getRetrofit(),
|
||||
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
|
||||
isSingleCommentThreadMode, mSharedPreferences,
|
||||
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
||||
@@ -686,10 +689,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
hideItem.setVisible(false);
|
||||
}
|
||||
|
||||
if (mPost.getAuthor().equals(mAccountName)) {
|
||||
if (mPost.getPostType() == Post.TEXT_TYPE) {
|
||||
mMenu.findItem(R.id.action_edit_view_post_detail_fragment).setVisible(true);
|
||||
}
|
||||
if (mPost.getAuthorNamePrefixed().equals(mAccountQualifiedName)) {
|
||||
mMenu.findItem(R.id.action_edit_view_post_detail_fragment).setVisible(true);
|
||||
mMenu.findItem(R.id.action_delete_view_post_detail_fragment).setVisible(true);
|
||||
|
||||
MenuItem nsfwItem = mMenu.findItem(R.id.action_nsfw_view_post_detail_fragment);
|
||||
@@ -773,29 +774,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
}
|
||||
|
||||
public void changeFlair(Flair flair) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||
params.put(APIUtils.FLAIR_TEMPLATE_ID_KEY, flair.getId());
|
||||
params.put(APIUtils.LINK_KEY, mPost.getFullName());
|
||||
params.put(APIUtils.TEXT_KEY, flair.getText());
|
||||
|
||||
mOauthRetrofit.create(RedditAPI.class).selectFlair(mPost.getSubredditNamePrefixed(),
|
||||
APIUtils.getOAuthHeader(mAccessToken), params).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
refresh(true, false);
|
||||
showMessage(R.string.update_flair_success);
|
||||
} else {
|
||||
showMessage(R.string.update_flair_failed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
showMessage(R.string.update_flair_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void changeSortType(SortType sortType) {
|
||||
@@ -949,7 +928,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
SavePost savePost = new SavePost();
|
||||
if (mPost.isSaved()) {
|
||||
item.setIcon(mUnsavedIcon);
|
||||
savePost.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getId(),
|
||||
savePost.unsaveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -973,7 +952,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
});
|
||||
} else {
|
||||
item.setIcon(mSavedIcon);
|
||||
savePost.saveThing(mOauthRetrofit, mAccessToken, mPost.getId(),
|
||||
savePost.saveThing(mRetrofit.getRetrofit(), mAccessToken, mPost.getId(),
|
||||
new SaveThing.SaveThingListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
@@ -1014,7 +993,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
if (mPost.isHidden()) {
|
||||
Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_hide_post));
|
||||
|
||||
HidePost.unhidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
|
||||
HidePost.unhidePost(mRetrofit.getRetrofit(), mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
mPost.setHidden(false);
|
||||
@@ -1034,7 +1013,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
} else {
|
||||
Utils.setTitleWithCustomFontToMenuItem(activity.typeface, item, getString(R.string.action_unhide_post));
|
||||
|
||||
HidePost.hidePost(mOauthRetrofit, mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
|
||||
HidePost.hidePost(mRetrofit.getRetrofit(), mAccessToken, mPost.getFullName(), new HidePost.HidePostListener() {
|
||||
@Override
|
||||
public void success() {
|
||||
mPost.setHidden(true);
|
||||
@@ -1056,9 +1035,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
return true;
|
||||
} else if (itemId == R.id.action_edit_view_post_detail_fragment) {
|
||||
Intent editPostIntent = new Intent(activity, EditPostActivity.class);
|
||||
editPostIntent.putExtra(EditPostActivity.EXTRA_FULLNAME, mPost.getFullName());
|
||||
editPostIntent.putExtra(EditPostActivity.EXTRA_TITLE, mPost.getTitle());
|
||||
editPostIntent.putExtra(EditPostActivity.EXTRA_CONTENT, mPost.getSelfText());
|
||||
editPostIntent.putExtra(EditPostActivity.EXTRA_DATA, mPost);
|
||||
startActivityForResult(editPostIntent, EDIT_POST_REQUEST_CODE);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_delete_view_post_detail_fragment) {
|
||||
@@ -1066,7 +1043,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
.setTitle(R.string.delete_this_post)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||
-> DeleteThing.delete(mOauthRetrofit, mPost.getFullName(), mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
-> DeleteThing.deletePost(mRetrofit.getRetrofit(), mPost.getId(), mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
@Override
|
||||
public void deleteSuccess() {
|
||||
Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
|
||||
@@ -1166,8 +1143,18 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
private void tryMarkingPostAsRead() {
|
||||
if (mMarkPostsAsRead && mPost != null && !mPost.isRead()) {
|
||||
mPost.markAsRead();
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, mPost.getId());
|
||||
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
|
||||
markPostAsRead.markPostAsRead(mPost.getId(), mAccessToken, new MarkPostAsRead.MarkPostAsReadListener() {
|
||||
@Override
|
||||
public void onMarkPostAsReadSuccess() {
|
||||
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountQualifiedName, mPost.getId());
|
||||
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkPostAsReadFailed() {
|
||||
Toast.makeText(activity, R.string.mark_post_as_read_failed, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1251,20 +1238,20 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
mPost = post;
|
||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||
mRetrofit.getRetrofit(), mGfycatRetrofit, mRedgifsRetrofit,
|
||||
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
||||
mPostDetailsSharedPreferences, mExoCreator,
|
||||
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||
mSwipeRefreshLayout.setRefreshing(false);
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, subredditId, mSingleCommentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, post.getId(), mSingleCommentId == 0 ? null : mSingleCommentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||
@Override
|
||||
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||
pages_loaded++;
|
||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
|
||||
mRetrofit.getRetrofit(), mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
|
||||
mRetrofit.getRetrofit(), mAccessToken, mAccountName, mPost, mLocale,
|
||||
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
|
||||
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
||||
@Override
|
||||
@@ -1556,7 +1543,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||
mOauthRetrofit.create(RedditAPI.class).markNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), mPost.getTitle(), mPost.getUrl(), mPost.getSelfText(), true, null, mAccessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
@@ -1594,7 +1581,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||
mRetrofit.getRetrofit().create(LemmyAPI.class).postUpdate(new EditPostDTO(mPost.getId(), mPost.getTitle(), mPost.getUrl(), mPost.getSelfText(), false, null, mAccessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
@@ -1625,88 +1612,12 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
||||
});
|
||||
}
|
||||
|
||||
private void markSpoiler() {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_unmark_spoiler);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||
mOauthRetrofit.create(RedditAPI.class).markSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_unmark_spoiler);
|
||||
}
|
||||
|
||||
refresh(true, false);
|
||||
showMessage(R.string.mark_spoiler_success);
|
||||
} else {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_mark_spoiler);
|
||||
}
|
||||
|
||||
showMessage(R.string.mark_spoiler_failed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_mark_spoiler);
|
||||
}
|
||||
|
||||
showMessage(R.string.mark_spoiler_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void unmarkSpoiler() {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_mark_spoiler);
|
||||
}
|
||||
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_mark_spoiler);
|
||||
}
|
||||
|
||||
refresh(true, false);
|
||||
showMessage(R.string.unmark_spoiler_success);
|
||||
} else {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_unmark_spoiler);
|
||||
}
|
||||
|
||||
showMessage(R.string.unmark_spoiler_failed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
if (mMenu != null) {
|
||||
mMenu.findItem(R.id.action_spoiler_view_post_detail_fragment).setTitle(R.string.action_unmark_spoiler);
|
||||
}
|
||||
|
||||
showMessage(R.string.unmark_spoiler_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteComment(String fullName, int position) {
|
||||
public void deleteComment(int commentId, int position) {
|
||||
new MaterialAlertDialogBuilder(activity, R.style.MaterialAlertDialogTheme)
|
||||
.setTitle(R.string.delete_this_comment)
|
||||
.setMessage(R.string.are_you_sure)
|
||||
.setPositiveButton(R.string.delete, (dialogInterface, i)
|
||||
-> DeleteThing.delete(mOauthRetrofit, fullName, mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
-> DeleteThing.deleteComment(mRetrofit.getRetrofit(), commentId, mAccessToken, new DeleteThing.DeleteThingListener() {
|
||||
@Override
|
||||
public void deleteSuccess() {
|
||||
Toast.makeText(activity, R.string.delete_post_success, Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
|
||||
public class CommentInteraction {
|
||||
int id;
|
||||
private Comment comment;
|
||||
private boolean isRead;
|
||||
|
||||
public CommentInteraction(int id, Comment comment, boolean isRead) {
|
||||
this.id = id;
|
||||
this.comment = comment;
|
||||
this.isRead = isRead;
|
||||
}
|
||||
|
||||
public Comment getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
return this.isRead;
|
||||
}
|
||||
|
||||
public void markAsUnRead() {
|
||||
this.isRead = false;
|
||||
}
|
||||
|
||||
|
||||
public void markAsRead() {
|
||||
this.isRead = true;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class FetchCommentInteractions {
|
||||
public static void fetchReplies(Retrofit retrofit, Integer page, boolean unreadOnly, String auth, FetchCommentInteractionsListener fetchMessagesListener) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
|
||||
api.userReplies("New", page, 25, unreadOnly, auth).enqueue(
|
||||
new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response.body());
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("replies");
|
||||
List<CommentInteraction> commentInteractions = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject commentInteractionObject = jsonArray.getJSONObject(i);
|
||||
Comment comment = ParseComment.parseSingleComment(commentInteractionObject);
|
||||
boolean isRead = !commentInteractionObject.getJSONObject("comment_reply").getBoolean("read");
|
||||
int id = commentInteractionObject.getJSONObject("comment_reply").getInt("id");
|
||||
commentInteractions.add(new CommentInteraction(id, comment, isRead));
|
||||
}
|
||||
fetchMessagesListener.fetchSuccess(commentInteractions);
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
} else {
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static void fetchMentions(Retrofit retrofit, Integer page, boolean unreadOnly, String auth, FetchCommentInteractionsListener fetchMessagesListener) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
|
||||
api.userMentions("New", page, 25, unreadOnly, auth).enqueue(
|
||||
new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(response.body());
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("mentions");
|
||||
List<CommentInteraction> commentInteractions = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject commentInteractionObject = jsonArray.getJSONObject(i);
|
||||
Comment comment = ParseComment.parseSingleComment(commentInteractionObject);
|
||||
boolean isRead = commentInteractionObject.getJSONObject("person_mention").getBoolean("read");
|
||||
int id = commentInteractionObject.getJSONObject("person_mention").getInt("id");
|
||||
commentInteractions.add(new CommentInteraction(id, comment, isRead));
|
||||
}
|
||||
fetchMessagesListener.fetchSuccess(commentInteractions);
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
} else {
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
fetchMessagesListener.fetchFailed();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public interface FetchCommentInteractionsListener {
|
||||
void fetchSuccess(List<CommentInteraction> commentInteractions);
|
||||
|
||||
void fetchFailed();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class FetchMessage {
|
||||
|
||||
public static final String WHERE_REPLIES = "replies";
|
||||
public static final String WHERE_MENTIONS = "mentions";
|
||||
public static final String WHERE_INBOX = "inbox";
|
||||
public static final String WHERE_UNREAD = "unread";
|
||||
public static final String WHERE_SENT = "sent";
|
||||
@@ -24,6 +26,9 @@ public class FetchMessage {
|
||||
public static final int MESSAGE_TYPE_INBOX = 0;
|
||||
public static final int MESSAGE_TYPE_PRIVATE_MESSAGE = 1;
|
||||
public static final int MESSAGE_TYPE_NOTIFICATION = 2;
|
||||
public static final int MESSAGE_TYPE_REPLIES = 3;
|
||||
public static final int MESSAGE_TYPE_MENTIONS = 4;
|
||||
|
||||
|
||||
static void fetchInbox(Retrofit oauthRetrofit, Locale locale, String accessToken, String where,
|
||||
String after, int messageType, FetchMessagesListener fetchMessagesListener) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
public class MessageCount {
|
||||
|
||||
/*
|
||||
Example:
|
||||
{
|
||||
"replies": 1,
|
||||
"mentions": 0,
|
||||
"private_messages": 0
|
||||
}
|
||||
*/
|
||||
public int replies;
|
||||
public int mentions;
|
||||
public int private_messages;
|
||||
|
||||
public MessageCount(int replies, int mentions, int private_messages) {
|
||||
this.replies = replies;
|
||||
this.mentions = mentions;
|
||||
this.private_messages = private_messages;
|
||||
}
|
||||
|
||||
public int getReplies() {
|
||||
return replies;
|
||||
}
|
||||
|
||||
public int getMentions() {
|
||||
return mentions;
|
||||
}
|
||||
|
||||
public int getPrivate_messages() {
|
||||
return private_messages;
|
||||
}
|
||||
|
||||
public int getSum() {
|
||||
return replies + mentions + private_messages;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.paging.PageKeyedDataSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import eu.toldi.infinityforlemmy.NetworkState;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
||||
private Retrofit oauthRetrofit;
|
||||
class MessageDataSource extends PageKeyedDataSource<Integer, CommentInteraction> {
|
||||
private Retrofit retrofit;
|
||||
private Locale locale;
|
||||
private String accessToken;
|
||||
private String where;
|
||||
@@ -22,18 +22,22 @@ class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
||||
private MutableLiveData<NetworkState> initialLoadStateLiveData;
|
||||
private MutableLiveData<Boolean> hasPostLiveData;
|
||||
|
||||
private LoadParams<String> params;
|
||||
private LoadCallback<String, Message> callback;
|
||||
private LoadParams<Integer> params;
|
||||
private LoadCallback<Integer, CommentInteraction> callback;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
MessageDataSource(Retrofit oauthRetrofit, Locale locale, String accessToken, String where) {
|
||||
this.oauthRetrofit = oauthRetrofit;
|
||||
this.retrofit = oauthRetrofit;
|
||||
this.locale = locale;
|
||||
this.accessToken = accessToken;
|
||||
this.where = where;
|
||||
if (where.equals(FetchMessage.WHERE_MESSAGES)) {
|
||||
messageType = FetchMessage.MESSAGE_TYPE_PRIVATE_MESSAGE;
|
||||
} else if (where.equals(FetchMessage.WHERE_REPLIES)) {
|
||||
messageType = FetchMessage.MESSAGE_TYPE_REPLIES;
|
||||
} else {
|
||||
messageType = FetchMessage.MESSAGE_TYPE_INBOX;
|
||||
messageType = FetchMessage.MESSAGE_TYPE_MENTIONS;
|
||||
}
|
||||
paginationNetworkStateLiveData = new MutableLiveData<>();
|
||||
initialLoadStateLiveData = new MutableLiveData<>();
|
||||
@@ -57,63 +61,97 @@ class MessageDataSource extends PageKeyedDataSource<String, Message> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadInitial(@NonNull LoadInitialParams<String> params, @NonNull LoadInitialCallback<String, Message> callback) {
|
||||
public void loadInitial(@NonNull LoadInitialParams<Integer> params, @NonNull LoadInitialCallback<Integer, CommentInteraction> callback) {
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADING);
|
||||
|
||||
FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, null, messageType,
|
||||
new FetchMessage.FetchMessagesListener() {
|
||||
@Override
|
||||
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
||||
if (messages.size() == 0) {
|
||||
hasPostLiveData.postValue(false);
|
||||
} else {
|
||||
if (messageType == FetchMessage.MESSAGE_TYPE_REPLIES) {
|
||||
FetchCommentInteractions.fetchReplies(retrofit, 1, false, accessToken, new FetchCommentInteractions.FetchCommentInteractionsListener() {
|
||||
@Override
|
||||
public void fetchSuccess(List<CommentInteraction> commentInteractions) {
|
||||
hasPostLiveData.postValue(true);
|
||||
if (commentInteractions.size() == 0) {
|
||||
callback.onResult(commentInteractions, null, null);
|
||||
} else {
|
||||
callback.onResult(commentInteractions, null, 2);
|
||||
}
|
||||
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
if (after == null || after.equals("") || after.equals("null")) {
|
||||
callback.onResult(messages, null, null);
|
||||
} else {
|
||||
callback.onResult(messages, null, after);
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetch messages"));
|
||||
}
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
});
|
||||
} else if (messageType == FetchMessage.MESSAGE_TYPE_MENTIONS) {
|
||||
FetchCommentInteractions.fetchMentions(retrofit, 1, false, accessToken, new FetchCommentInteractions.FetchCommentInteractionsListener() {
|
||||
@Override
|
||||
public void fetchSuccess(List<CommentInteraction> commentInteractions) {
|
||||
hasPostLiveData.postValue(true);
|
||||
if (commentInteractions.size() == 0) {
|
||||
callback.onResult(commentInteractions, null, null);
|
||||
} else {
|
||||
callback.onResult(commentInteractions, null, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetch messages"));
|
||||
}
|
||||
});
|
||||
initialLoadStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetch messages"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadBefore(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Message> callback) {
|
||||
public void loadBefore(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, CommentInteraction> callback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAfter(@NonNull LoadParams<String> params, @NonNull LoadCallback<String, Message> callback) {
|
||||
public void loadAfter(@NonNull LoadParams<Integer> params, @NonNull LoadCallback<Integer, CommentInteraction> callback) {
|
||||
this.params = params;
|
||||
this.callback = callback;
|
||||
|
||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
||||
if (messageType == FetchMessage.MESSAGE_TYPE_REPLIES) {
|
||||
FetchCommentInteractions.fetchReplies(retrofit, params.key, false, accessToken, new FetchCommentInteractions.FetchCommentInteractionsListener() {
|
||||
@Override
|
||||
public void fetchSuccess(List<CommentInteraction> commentInteractions) {
|
||||
hasPostLiveData.postValue(true);
|
||||
if (commentInteractions.size() == 0) {
|
||||
callback.onResult(new ArrayList<>(), null);
|
||||
} else {
|
||||
callback.onResult(commentInteractions, params.key + 1);
|
||||
}
|
||||
|
||||
FetchMessage.fetchInbox(oauthRetrofit, locale, accessToken, where, params.key, messageType,
|
||||
new FetchMessage.FetchMessagesListener() {
|
||||
@Override
|
||||
public void fetchSuccess(ArrayList<Message> messages, @Nullable String after) {
|
||||
if (after == null || after.equals("") || after.equals("null")) {
|
||||
callback.onResult(messages, null);
|
||||
} else {
|
||||
callback.onResult(messages, after);
|
||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetch messages"));
|
||||
}
|
||||
});
|
||||
} else if (messageType == FetchMessage.MESSAGE_TYPE_MENTIONS) {
|
||||
FetchCommentInteractions.fetchMentions(retrofit, params.key, false, accessToken, new FetchCommentInteractions.FetchCommentInteractionsListener() {
|
||||
@Override
|
||||
public void fetchSuccess(List<CommentInteraction> commentInteractions) {
|
||||
hasPostLiveData.postValue(true);
|
||||
if (commentInteractions.size() == 0) {
|
||||
callback.onResult(new ArrayList<>(), null);
|
||||
} else {
|
||||
callback.onResult(commentInteractions, params.key + 1);
|
||||
}
|
||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetching data"));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void fetchFailed() {
|
||||
paginationNetworkStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error fetch messages"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MessageViewModel extends ViewModel {
|
||||
private LiveData<NetworkState> paginationNetworkState;
|
||||
private LiveData<NetworkState> initialLoadingState;
|
||||
private LiveData<Boolean> hasMessageLiveData;
|
||||
private LiveData<PagedList<Message>> messages;
|
||||
private LiveData<PagedList<CommentInteraction>> messages;
|
||||
private MutableLiveData<String> whereLiveData;
|
||||
|
||||
public MessageViewModel(Retrofit retrofit, Locale locale, String accessToken, String where) {
|
||||
@@ -47,7 +47,7 @@ public class MessageViewModel extends ViewModel {
|
||||
});
|
||||
}
|
||||
|
||||
public LiveData<PagedList<Message>> getMessages() {
|
||||
public LiveData<PagedList<CommentInteraction>> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,38 @@ package eu.toldi.infinityforlemmy.message;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.AuthDTO;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadCommentDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class ReadMessage {
|
||||
public static void readMessage(Retrofit oauthRetrofit, String accessToken, String commaSeparatedFullnames,
|
||||
public static void readMessage(Retrofit oauthRetrofit, String accessToken, int messageId,
|
||||
ReadMessageListener readMessageListener) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put(APIUtils.ID_KEY, commaSeparatedFullnames);
|
||||
oauthRetrofit.create(RedditAPI.class).readMessage(APIUtils.getOAuthHeader(accessToken), params)
|
||||
oauthRetrofit.create(LemmyAPI.class).commentMarkAsRead(new ReadCommentDTO(messageId, true, accessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
if (response.isSuccessful()) {
|
||||
readMessageListener.readSuccess();
|
||||
} else {
|
||||
readMessageListener.readFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||
readMessageListener.readFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void readAllMessages(Retrofit retrofit, String accessToken,
|
||||
ReadMessageListener readMessageListener) {
|
||||
retrofit.create(LemmyAPI.class).userMarkAllAsRead(new AuthDTO(accessToken))
|
||||
.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package eu.toldi.infinityforlemmy.post;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.dto.ReadPostDTO;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class MarkPostAsRead {
|
||||
RetrofitHolder retrofitHolder;
|
||||
|
||||
public MarkPostAsRead(RetrofitHolder retrofitHolder) {
|
||||
this.retrofitHolder = retrofitHolder;
|
||||
}
|
||||
|
||||
private void setPostAsRead(int post_id, boolean markAsRead, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
lemmyAPI.postRead(new ReadPostDTO(post_id, markAsRead, auth)).enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
markPostAsReadListener.onMarkPostAsReadSuccess();
|
||||
} else {
|
||||
markPostAsReadListener.onMarkPostAsReadFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
markPostAsReadListener.onMarkPostAsReadFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void markPostAsRead(int post_id, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
setPostAsRead(post_id, true, auth, markPostAsReadListener);
|
||||
}
|
||||
|
||||
public void markPostAsUnread(int post_id, String auth, MarkPostAsReadListener markPostAsReadListener) {
|
||||
setPostAsRead(post_id, false, auth, markPostAsReadListener);
|
||||
}
|
||||
|
||||
public interface MarkPostAsReadListener {
|
||||
void onMarkPostAsReadSuccess();
|
||||
|
||||
void onMarkPostAsReadFailed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package eu.toldi.infinityforlemmy.post;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import eu.toldi.infinityforlemmy.RetrofitHolder;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.comment.Comment;
|
||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class ObjectResolver {
|
||||
|
||||
RetrofitHolder retrofitHolder;
|
||||
|
||||
public ObjectResolver(RetrofitHolder retrofitHolder) {
|
||||
this.retrofitHolder = retrofitHolder;
|
||||
}
|
||||
|
||||
public void resolvePost(String query, String auth, ObjectResolverListener objectResolverListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
Call<String> response = lemmyAPI.resolveObject(query, auth);
|
||||
response.enqueue(new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(response.body())).getJSONObject("post");
|
||||
Post p = ParsePost.parseBasicData(jsonObject);
|
||||
objectResolverListener.onResolveObjectSuccess(p);
|
||||
} catch (JSONException e) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
|
||||
} else {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void resolveComment(String query, String auth, ObjectResolverListener objectResolverListener) {
|
||||
LemmyAPI lemmyAPI = retrofitHolder.getRetrofit().create(LemmyAPI.class);
|
||||
|
||||
Call<String> response = lemmyAPI.resolveObject(query, auth);
|
||||
response.enqueue(
|
||||
new Callback<String>() {
|
||||
@Override
|
||||
public void onResponse(Call<String> call, Response<String> response) {
|
||||
if (response.isSuccessful()
|
||||
&& response.body() != null) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(response.body())).getJSONObject("comment");
|
||||
Comment c = ParseComment.parseSingleComment(jsonObject);
|
||||
objectResolverListener.onResolveObjectSuccess(c);
|
||||
} catch (JSONException e) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
|
||||
} else {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<String> call, Throwable t) {
|
||||
objectResolverListener.onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public interface ObjectResolverListener {
|
||||
void onResolveObjectSuccess(Object resolvedObject);
|
||||
|
||||
void onResolveObjectFailed();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import static java.lang.Integer.max;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -191,8 +190,8 @@ public class ParsePost {
|
||||
ArrayList <Post.Preview> previews = new ArrayList<>();
|
||||
if(!post.isNull("thumbnail_url")) {
|
||||
String thumbnail = post.getString("thumbnail_url");
|
||||
int[] wh_array = getImageDimension(thumbnail);
|
||||
previews.add(new Post.Preview(thumbnail, wh_array[0], wh_array[1], "", ""));
|
||||
//int[] wh_array = getImageDimension(thumbnail);
|
||||
previews.add(new Post.Preview(thumbnail, 0, 0, "", ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -684,8 +683,7 @@ public class ParsePost {
|
||||
}
|
||||
|
||||
public static int[] getImageDimension(String imageUrl) {
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy); //Permit all for simplicity. You may want to revise this for your actual app.
|
||||
|
||||
|
||||
HttpURLConnection urlConnection = null;
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.toldi.infinityforlemmy.post;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
@@ -624,6 +625,8 @@ public class Post implements Parcelable {
|
||||
private String previewCaption;
|
||||
private String previewCaptionUrl;
|
||||
|
||||
private Bitmap previewBitmap;
|
||||
|
||||
public Preview(String previewUrl, int previewWidth, int previewHeight, String previewCaption, String previewCaptionUrl) {
|
||||
this.previewUrl = previewUrl;
|
||||
this.previewWidth = previewWidth;
|
||||
@@ -638,6 +641,7 @@ public class Post implements Parcelable {
|
||||
previewHeight = in.readInt();
|
||||
previewCaption = in.readString();
|
||||
previewCaptionUrl = in.readString();
|
||||
previewBitmap = in.readParcelable(Bitmap.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static final Creator<Preview> CREATOR = new Creator<Preview>() {
|
||||
@@ -686,13 +690,23 @@ public class Post implements Parcelable {
|
||||
return previewCaptionUrl;
|
||||
}
|
||||
|
||||
public void setPreviewCaptionUrl(String previewCaptionUrl) { this.previewCaptionUrl = previewCaptionUrl; }
|
||||
public void setPreviewCaptionUrl(String previewCaptionUrl) {
|
||||
this.previewCaptionUrl = previewCaptionUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Bitmap getPreviewBitmap() {
|
||||
return previewBitmap;
|
||||
}
|
||||
|
||||
public void setPreviewBitmap(Bitmap previewBitmap) {
|
||||
this.previewBitmap = previewBitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int i) {
|
||||
parcel.writeString(previewUrl);
|
||||
@@ -700,6 +714,7 @@ public class Post implements Parcelable {
|
||||
parcel.writeInt(previewHeight);
|
||||
parcel.writeString(previewCaption);
|
||||
parcel.writeString(previewCaptionUrl);
|
||||
parcel.writeParcelable(previewBitmap, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,23 +23,23 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class SubmitPost {
|
||||
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||
int communityId, String title, String content,
|
||||
int communityId, String title, String body, String url,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
SubmitPostListener submitPostListener) {
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, content,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, body,
|
||||
isNSFW, receivePostReplyNotifications, kind, url, submitPostListener);
|
||||
}
|
||||
|
||||
public static void submitImagePost(Executor executor, Handler handler, RetrofitHolder mRetrofit,
|
||||
String accessToken, int communityId, String title, Bitmap image,
|
||||
String accessToken, int communityId, String title, String body, Bitmap image,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
|
||||
try {
|
||||
String imageUrlOrError = UploadImageUtils.uploadImage(mRetrofit, accessToken, image);
|
||||
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
||||
submitPost(executor, handler, mRetrofit.getRetrofit(), accessToken,
|
||||
communityId, title, null, flair, isSpoiler, isNSFW,
|
||||
communityId, title, body, isNSFW,
|
||||
receivePostReplyNotifications, APIUtils.KIND_IMAGE, imageUrlOrError, submitPostListener);
|
||||
} else {
|
||||
submitPostListener.submitFailed(imageUrlOrError);
|
||||
@@ -56,12 +56,12 @@ public class SubmitPost {
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
SubmitPostListener submitPostListener) {
|
||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||
}
|
||||
|
||||
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||
int communityId, String title, String content,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||
boolean isNSFW,
|
||||
boolean receivePostReplyNotifications, String kind,
|
||||
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
|
||||
LemmyAPI api = oauthRetrofit.create(LemmyAPI.class);
|
||||
|
||||
@@ -64,7 +64,9 @@ public class SubmitPostService extends Service {
|
||||
public static final String EXTRA_ACCOUNT = "EA";
|
||||
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||
public static final String EXTRA_TITLE = "ET";
|
||||
public static final String EXTRA_CONTENT = "EC";
|
||||
public static final String EXTRA_BODY = "EC";
|
||||
|
||||
public static final String EXTRA_URL = "EU";
|
||||
public static final String EXTRA_REDDIT_GALLERY_PAYLOAD = "ERGP";
|
||||
public static final String EXTRA_POLL_PAYLOAD = "EPP";
|
||||
public static final String EXTRA_KIND = "EK";
|
||||
@@ -129,20 +131,20 @@ public class SubmitPostService extends Service {
|
||||
boolean isNSFW = bundle.getBoolean(EXTRA_IS_NSFW, false);
|
||||
boolean receivePostReplyNotifications = bundle.getBoolean(EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, true);
|
||||
int postType = bundle.getInt(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
|
||||
|
||||
String body = bundle.getString(EXTRA_BODY);
|
||||
String url = bundle.getString(EXTRA_URL);
|
||||
|
||||
if (postType == EXTRA_POST_TEXT_OR_LINK) {
|
||||
String content = bundle.getString(EXTRA_CONTENT);
|
||||
|
||||
String kind = bundle.getString(EXTRA_KIND);
|
||||
submitTextOrLinkPost(mRetrofit.getRetrofit(), account, subredditName, title, content, flair, isSpoiler, isNSFW,
|
||||
submitTextOrLinkPost(mRetrofit.getRetrofit(), account, subredditName, title, body, url, flair, isSpoiler, isNSFW,
|
||||
receivePostReplyNotifications, kind);
|
||||
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
||||
String content = bundle.getString(EXTRA_CONTENT);
|
||||
submitCrosspost(mExecutor, handler, mRetrofit.getRetrofit(), account, subredditName, title, content,
|
||||
submitCrosspost(mExecutor, handler, mRetrofit.getRetrofit(), account, subredditName, title, body,
|
||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications);
|
||||
} else if (postType == EXTRA_POST_TYPE_IMAGE) {
|
||||
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
||||
submitImagePost(mRetrofit, account, mediaUri, subredditName, title, flair, isSpoiler, isNSFW,
|
||||
submitImagePost(mRetrofit, account, mediaUri, subredditName, title, body, flair, isSpoiler, isNSFW,
|
||||
receivePostReplyNotifications);
|
||||
} else if (postType == EXTRA_POST_TYPE_GALLERY) {
|
||||
submitGalleryPost(mRetrofit.getRetrofit(), account, bundle.getString(EXTRA_REDDIT_GALLERY_PAYLOAD));
|
||||
@@ -214,11 +216,11 @@ public class SubmitPostService extends Service {
|
||||
.build();
|
||||
}
|
||||
|
||||
private void submitTextOrLinkPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, int communityId, String title, String content,
|
||||
private void submitTextOrLinkPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, int communityId, String title, String body, String url,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications,
|
||||
String kind) {
|
||||
SubmitPost.submitTextOrLinkPost(mExecutor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(),
|
||||
communityId, title, content, flair, isSpoiler,
|
||||
communityId, title, body, url, flair, isSpoiler,
|
||||
isNSFW, receivePostReplyNotifications, kind, new SubmitPost.SubmitPostListener() {
|
||||
@Override
|
||||
public void submitSuccessful(Post post) {
|
||||
@@ -259,12 +261,12 @@ public class SubmitPostService extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
private void submitImagePost(RetrofitHolder newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri, int communityId, String title,
|
||||
private void submitImagePost(RetrofitHolder newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri, int communityId, String title, String body,
|
||||
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
|
||||
try {
|
||||
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
|
||||
SubmitPost.submitImagePost(mExecutor, handler, newAuthenticatorOauthRetrofit,
|
||||
selectedAccount.getAccessToken(), communityId, title, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||
selectedAccount.getAccessToken(), communityId, title, body, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||
new SubmitPost.SubmitPostListener() {
|
||||
@Override
|
||||
public void submitSuccessful(Post post) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.customviews.CustomFontPreferenceFragmentCompat;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeHideFabInPostFeedEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeUseCircularFabEvent;
|
||||
import eu.toldi.infinityforlemmy.events.ChangeVoteButtonsPositionEvent;
|
||||
import eu.toldi.infinityforlemmy.events.RecreateActivityEvent;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
@@ -23,6 +24,7 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom
|
||||
|
||||
Preference immersiveInterfaceEntryPreference = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_ENTRY_KEY);
|
||||
SwitchPreference hideFabInPostFeedSwitchPreference = findPreference(SharedPreferencesUtils.HIDE_FAB_IN_POST_FEED);
|
||||
SwitchPreference useCircularFAbSwitchPreference = findPreference(SharedPreferencesUtils.USE_CIRCULAR_FAB);
|
||||
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
|
||||
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
|
||||
|
||||
@@ -37,6 +39,13 @@ public class InterfacePreferenceFragment extends CustomFontPreferenceFragmentCom
|
||||
});
|
||||
}
|
||||
|
||||
if (useCircularFAbSwitchPreference != null) {
|
||||
useCircularFAbSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new ChangeUseCircularFabEvent((Boolean) newValue));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (bottomAppBarSwitch != null) {
|
||||
bottomAppBarSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
|
||||
@@ -8,7 +8,12 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import eu.toldi.infinityforlemmy.utils.JSONUtils;
|
||||
|
||||
@@ -47,7 +52,11 @@ public class ParseSubredditData {
|
||||
}
|
||||
|
||||
boolean removed = community.getBoolean("removed");
|
||||
String published = community.getString("published");
|
||||
String published_raw = community.getString("published");
|
||||
String published = formatISOTime(published_raw);
|
||||
if(published == null){
|
||||
published = published_raw;
|
||||
}
|
||||
String updated = "";
|
||||
if (!community.isNull("updated")) {
|
||||
updated = community.getString("updated");
|
||||
@@ -170,4 +179,25 @@ public class ParseSubredditData {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatISOTime(String isoTime) {
|
||||
// Truncate the time to millisecond precision
|
||||
String truncatedTime = isoTime.substring(0, 23);
|
||||
|
||||
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
|
||||
isoFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
|
||||
try {
|
||||
Date date = isoFormat.parse(truncatedTime);
|
||||
|
||||
// Set your desired output format here
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss", Locale.US);
|
||||
outputFormat.setTimeZone(TimeZone.getDefault()); // Set to device's default timezone
|
||||
|
||||
return outputFormat.format(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.ArrayList;
|
||||
import eu.toldi.infinityforlemmy.RedditDataRoomDatabase;
|
||||
import eu.toldi.infinityforlemmy.SortType;
|
||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
||||
import eu.toldi.infinityforlemmy.message.MessageCount;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Retrofit;
|
||||
@@ -85,6 +86,33 @@ public class FetchUserData {
|
||||
});
|
||||
}
|
||||
|
||||
public static void fetchUnreadCount(Retrofit retrofit, String accessToken, FetchUserUnreadCountListener fetchUserUnreadCountListener) {
|
||||
LemmyAPI api = retrofit.create(LemmyAPI.class);
|
||||
|
||||
Call<MessageCount> userUnreadCount = api.userUnreadCount(accessToken);
|
||||
userUnreadCount.enqueue(new Callback<>() {
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<MessageCount> call, @NonNull retrofit2.Response<MessageCount> response) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
fetchUserUnreadCountListener.onFetchUserUnreadCountSuccess(response.body().getSum());
|
||||
} else {
|
||||
fetchUserUnreadCountListener.onFetchUserUnreadCountFailed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<MessageCount> call, @NonNull Throwable t) {
|
||||
fetchUserUnreadCountListener.onFetchUserUnreadCountFailed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface FetchUserUnreadCountListener {
|
||||
void onFetchUserUnreadCountSuccess(int unreadCount);
|
||||
|
||||
void onFetchUserUnreadCountFailed();
|
||||
}
|
||||
|
||||
public interface FetchUserDataListener {
|
||||
void onFetchUserDataSuccess(UserData userData, int inboxCount);
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ public class SharedPreferencesUtils {
|
||||
public static final String REDDIT_USER_AGREEMENT_KEY = "reddit_user_agreement";
|
||||
public static final String HIDE_FAB_IN_POST_FEED = "hide_fab_in_post_feed";
|
||||
|
||||
public static final String USE_CIRCULAR_FAB = "use_circular_fab";
|
||||
|
||||
public static final String SORT_TYPE_SHARED_PREFERENCES_FILE = "eu.toldi.infinityforlemmy.sort_type";
|
||||
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
|
||||
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
<EditText
|
||||
android:id="@+id/post_title_text_view_edit_post_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -49,10 +49,53 @@
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:fontFamily="?attr/title_font_family" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider_edit_post_activity"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:id="@+id/divider_edit_post_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_link_edit_text_post_edit_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_link_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/content_font_18" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/upload_image_button_post_edit_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/upload_image"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_post_edit_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp" />
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart"
|
||||
android:visibility="gone" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider2_edit_post_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_text_content_edit_text_edit_post_activity"
|
||||
|
||||
@@ -23,211 +23,237 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_image_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_image_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_image_activity"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_image_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/title_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
android:textSize="?attr/title_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="32dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/capture_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/select_from_library_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_select_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_image_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_image_activity"
|
||||
android:id="@+id/select_again_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="16dp"
|
||||
android:text="@string/select_again"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textSize="?attr/font_default"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart"
|
||||
android:visibility="gone" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_text_content_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#00000000"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18"
|
||||
android:fontFamily="?attr/title_font_family" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/select_image_constraint_layout_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="32dp">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/capture_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_add_a_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_image_activity"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/select_from_library_fab_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:src="@drawable/ic_outline_select_photo_24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_chainStyle="spread"
|
||||
app:layout_constraintStart_toEndOf="@+id/capture_fab_post_image_activity"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_again_text_view_post_image_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:text="@string/select_again"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view_post_image_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/markdown_bottom_bar_recycler_view_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:scrollbars="horizontal" />
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -23,190 +23,216 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
android:orientation="vertical">
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:id="@+id/account_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp">
|
||||
|
||||
</LinearLayout>
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/account_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
<TextView
|
||||
android:id="@+id/account_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="32dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_link_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
<pl.droidsonroids.gif.GifImageView
|
||||
android:id="@+id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_toStartOf="@id/rules_button_post_link_activity"
|
||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_link_activity"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/choose_a_communities"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/rules_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/rules"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_1_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</LinearLayout>
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_custom_text_view_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/nsfw"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:lib_setRadius="6dp"
|
||||
app:lib_setRoundedView="true"
|
||||
app:lib_setShape="rectangle" />
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/title_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/receive_post_reply_notifications_text_view_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/receive_post_reply_notifications"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/suggest_title_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:text="@string/suggest_title"
|
||||
android:textSize="?attr/font_default" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/receive_post_reply_notifications_switch_material_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/divider_2_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_title_edit_text_post_link_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/post_link_edit_text_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_title_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:hint="@string/post_link_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/title_font_18"
|
||||
android:fontFamily="?attr/title_font_family" />
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/suggest_title_button_post_link_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/suggest_title"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family" />
|
||||
<EditText
|
||||
android:id="@+id/post_text_content_edit_text_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:fontFamily="?attr/content_font_family"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_text_content_hint"
|
||||
android:inputType="textCapSentences|textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textSize="?attr/content_font_18" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/post_link_edit_text_post_link_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
android:gravity="top"
|
||||
android:hint="@string/post_link_hint"
|
||||
android:inputType="textMultiLine"
|
||||
android:padding="16dp"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/content_font_18"
|
||||
android:fontFamily="?attr/content_font_family" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/markdown_bottom_bar_recycler_view_post_text_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:scrollbars="horizontal" />
|
||||
</LinearLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
@@ -144,25 +144,6 @@
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/random_text_view_fab_more_options_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:text="@string/random"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
android:fontFamily="?attr/font_family"
|
||||
app:drawableStartCompat="@drawable/ic_random_24dp"
|
||||
android:drawablePadding="48dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/hide_read_posts_text_view_fab_more_options_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -11,43 +11,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/relevance_type_text_view_search_sort_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:drawableStart="@drawable/ic_best_24"
|
||||
android:drawablePadding="48dp"
|
||||
android:focusable="true"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/sort_relevance"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:drawableTint="?attr/primaryTextColor" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/hot_type_text_view_search_sort_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:drawableStart="@drawable/ic_hot_24"
|
||||
android:drawablePadding="48dp"
|
||||
android:focusable="true"
|
||||
android:fontFamily="?attr/font_family"
|
||||
android:paddingStart="32dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/sort_hot"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:drawableTint="?attr/primaryTextColor" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment"
|
||||
@@ -88,7 +51,7 @@
|
||||
app:drawableTint="?attr/primaryTextColor" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/comments_type_text_view_search_sort_type_bottom_sheet_fragment"
|
||||
android:id="@+id/old_type_text_view_search_sort_type_bottom_sheet_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@@ -101,7 +64,7 @@
|
||||
android:paddingTop="16dp"
|
||||
android:paddingEnd="32dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:text="@string/sort_comments"
|
||||
android:text="@string/sort_old"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="?attr/font_default"
|
||||
app:drawableTint="?attr/primaryTextColor" />
|
||||
|
||||
@@ -380,8 +380,8 @@
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Reddit účet"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Sdílet"</string>
|
||||
<string name="settings_share_summary">"Pokud máte rádi tuto aplikaci, sdílejte ji s ostatními lidmi"</string>
|
||||
<string name="settings_version_title">"Infinity pro Reddit"</string>
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
<string name="view_message_activity_label">"Posteingang"</string>
|
||||
<string name="settings_activity_label">"Einstellungen"</string>
|
||||
<string name="account_saved_thing_activity_label">"Gespeichert"</string>
|
||||
<string name="create_multi_reddit_activity_label">"Multireddit erstellen"</string>
|
||||
<string name="community_multiselection_activity_label">"Multireddits auswählen"</string>
|
||||
<string name="create_multi_reddit_activity_label">Multicommunity erstellen</string>
|
||||
<string name="community_multiselection_activity_label">Multicommunity auswählen</string>
|
||||
<string name="custom_theme_listing_activity_label">"Benutzerdefinierte Themen"</string>
|
||||
<string name="customize_theme_activity_label">"Thema anpassen"</string>
|
||||
<string name="customize_theme_activity_create_theme_label">"Thema erstellen"</string>
|
||||
<string name="theme_preview_activity_label">"Thema-Vorschau"</string>
|
||||
<string name="edit_multi_reddit_activity_label">"Multireddit bearbeiten"</string>
|
||||
<string name="selected_subeddits_activity_label">"Ausgewählte Subreddits"</string>
|
||||
<string name="edit_multi_reddit_activity_label">Multicommunity bearbeiten</string>
|
||||
<string name="selected_subeddits_activity_label">Ausgewählte Communities</string>
|
||||
<string name="report_activity_label">"Melden"</string>
|
||||
<string name="view_imgur_media_activity_image_label">"Bild %1$d/%2$d"</string>
|
||||
<string name="view_imgur_media_activity_video_label">"Video %1$d/%2$d"</string>
|
||||
@@ -55,8 +55,8 @@
|
||||
<string name="action_edit_flair">"Flair bearbeiten"</string>
|
||||
<string name="action_change_post_layout">"Beitragslayout ändern"</string>
|
||||
<string name="action_save">"Speichern"</string>
|
||||
<string name="action_edit_multi_reddit">"Multireddit bearbeiten"</string>
|
||||
<string name="action_delete_multi_reddit">"Multireddit löschen"</string>
|
||||
<string name="action_edit_multi_reddit">Multicommunity bearbeiten</string>
|
||||
<string name="action_delete_multi_reddit">Multicommunity löschen</string>
|
||||
<string name="action_share">"Teilen"</string>
|
||||
<string name="action_preview">"Vorschau"</string>
|
||||
<string name="action_report">"Melden"</string>
|
||||
@@ -83,7 +83,7 @@ Tippen für Neuversuch."</string>
|
||||
<string name="no_comments">"Keine Kommentare gefunden"</string>
|
||||
<string name="no_communities">"Keine Subreddits gefunden"</string>
|
||||
<string name="no_users">"Keine Benutzer gefunden"</string>
|
||||
<string name="no_multi_reddits">"Keine Multireddits gefunden"</string>
|
||||
<string name="no_multi_reddits">Keine Multicommunities gefunden</string>
|
||||
<string name="no_storage_permission">"Keine Speicherberechtigung, um diese Datei zu speichern"</string>
|
||||
<string name="load_comments_failed">"Fehler beim Laden der Kommentare.
|
||||
Tippen für Neuversuch."</string>
|
||||
@@ -104,7 +104,7 @@ Tippen für Neuversuch."</string>
|
||||
<string name="since">"Seit:"</string>
|
||||
<string name="profile">"Profil"</string>
|
||||
<string name="subscriptions">"Abonnements"</string>
|
||||
<string name="multi_reddit">"Multireddit"</string>
|
||||
<string name="multi_reddit">Multicommunity</string>
|
||||
<string name="inbox">"Posteingang"</string>
|
||||
<string name="upvoted">"Upgevotet"</string>
|
||||
<string name="downvoted">"Downgevotet"</string>
|
||||
@@ -117,7 +117,7 @@ Tippen für Neuversuch."</string>
|
||||
<string name="cannot_fetch_community_info">"Kann Subredddit-Info nicht abrufen"</string>
|
||||
<string name="cannot_fetch_user_info">"Kann Benutzer-Info nicht abrufen"</string>
|
||||
<string name="cannot_fetch_sidebar">"Kann Seitenleiste nicht abrufen"</string>
|
||||
<string name="cannot_fetch_multireddit">"Kann Multireddit-Info nicht abrufen"</string>
|
||||
<string name="cannot_fetch_multireddit">Kann Multicommunity-Info nicht abrufen</string>
|
||||
<string name="subscribe">"Abonnieren"</string>
|
||||
<string name="unsubscribe">"Deabonnieren"</string>
|
||||
<string name="subscribed">"Abonniert"</string>
|
||||
@@ -171,9 +171,9 @@ Tippen für Neuversuch."</string>
|
||||
<string name="choose_a_communities">"Wähle ein Subreddit"</string>
|
||||
<string name="rules">"Regeln"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddits"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Benutzer"</string>
|
||||
<string name="multi_reddits">"Multireddits"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Text"</string>
|
||||
<string name="bottom_sheet_post_link">"Link"</string>
|
||||
<string name="bottom_sheet_post_image">"Bild"</string>
|
||||
@@ -408,10 +408,10 @@ Tippen für Neuversuch."</string>
|
||||
<string name="settings_rate_summary">"Gib mir eine 5-Stern-Bewertung und mach mich richtig glücklich"</string>
|
||||
<string name="settings_email_title">"E-Mail"</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Reddit-Konto"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_reddit_account_title">Lemmy-Konto</string>
|
||||
<string name="settings_reddit_account_summary">\@bazsalanszky@lemmy.toldi.eu</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@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>
|
||||
@@ -434,10 +434,10 @@ Tippen für Neuversuch."</string>
|
||||
<string name="settings_tab_3_summary">"Reiter 3"</string>
|
||||
<string name="settings_tab_title">"Titel"</string>
|
||||
<string name="settings_tab_post_type">"Typ"</string>
|
||||
<string name="settings_tab_community_name">"Subreddit-Name (ohne r/ Präfix)"</string>
|
||||
<string name="settings_tab_community_name">Community-Name (ohne r/ Präfix)</string>
|
||||
|
||||
<!-- Fuzzy -->
|
||||
<string name="settings_tab_multi_reddit_name">"Multireddit-Name (/user/DeinBenutzername/m/DeinMultiredditName)"</string>
|
||||
<string name="settings_tab_multi_reddit_name">Multicommunity-Name (/user/DeinBenutzername/m/DeinMulticommunityName)</string>
|
||||
<string name="settings_tab_username">"Benutzername (ohne u/ Präfix)"</string>
|
||||
<string name="no_developer_easter_egg">"Es gibt hier keine Entwickleroptionen"</string>
|
||||
<string name="no_link_available">"Konnte den Link nicht abrufen"</string>
|
||||
@@ -475,8 +475,8 @@ Tippen für Neuversuch."</string>
|
||||
<string name="elapsed_time_months_ago">"%1$d Monate"</string>
|
||||
<string name="elapsed_time_a_year_ago">"1 Jahr"</string>
|
||||
<string name="elapsed_time_years_ago">"%1$d Jahre"</string>
|
||||
<string name="error_getting_multi_reddit_data">"Fehler beim Abrufen der Multireddit-Daten"</string>
|
||||
<string name="error_loading_multi_reddit_list">"Kann Multireddits nicht synchronisieren"</string>
|
||||
<string name="error_getting_multi_reddit_data">Fehler beim Abrufen der Multicommunity-Daten</string>
|
||||
<string name="error_loading_multi_reddit_list">Kann Multicommunities nicht synchronisieren</string>
|
||||
<string name="error_loading_subscriptions">"Kann Abonnements nicht synchronisieren"</string>
|
||||
<string name="share_this_app">"Schau dir Infinity for Reddit an, ein super Reddit-Client!
|
||||
https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy"</string>
|
||||
@@ -506,9 +506,9 @@ https://play.google.com/store/apps/details?id=eu.toldi.infinityforlemmy"</string
|
||||
<string name="multi_reddit_description_hint">"Beschreibung"</string>
|
||||
<string name="private_multi_reddit">"Privat"</string>
|
||||
<string name="no_multi_reddit_name">"Wo ist der Name?"</string>
|
||||
<string name="create_multi_reddit_failed">"Kann dieses Multireddit nicht erstellen"</string>
|
||||
<string name="duplicate_multi_reddit">"Dieses Multireddit existiert bereits"</string>
|
||||
<string name="edit_multi_reddit_failed">"Kann dieses Multireddit nicht bearbeiten"</string>
|
||||
<string name="create_multi_reddit_failed">Kann dieses Multicommunity nicht erstellen</string>
|
||||
<string name="duplicate_multi_reddit">Dieses Multicommunity existiert bereits</string>
|
||||
<string name="edit_multi_reddit_failed">Kann diese Multicommunity nicht bearbeiten</string>
|
||||
<string name="delete_multi_reddit_success">"Löschen erfolgreich"</string>
|
||||
<string name="delete_multi_reddit_failed">"Löschen fehlgeschlagen"</string>
|
||||
<string name="delete_multi_reddit_dialog_message">"Bist du sicher?"</string>
|
||||
@@ -745,7 +745,7 @@ Basiere auf Indigo-AMOLED-Thema"</string>
|
||||
<!-- Fuzzy -->
|
||||
<string name="reset_all_settings_success">"Alle Einstellungen erfolgreich gelöscht"</string>
|
||||
<string name="username_preview">"u/Hostilenemy"</string>
|
||||
<string name="community_preview">"r/Infinity_For_Reddit"</string>
|
||||
<string name="community_preview">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="primary_text_preview">"Primärer Text"</string>
|
||||
<string name="secondary_text_preview">"Sekundärer Text"</string>
|
||||
<string name="post_title_preview">"Dies ist ein Beitrag"</string>
|
||||
@@ -756,8 +756,8 @@ Basiere auf Indigo-AMOLED-Thema"</string>
|
||||
<string name="author_flair_preview">"Autor-Flair"</string>
|
||||
<string name="comment_content_preview">"Ich habe für meine Freundin eine “Gute Besserung“-Karte besorgt.
|
||||
Sie ist nicht krank oder so, aber sie könnte sich definitiv bessern."</string>
|
||||
<string name="edit_multi_reddit">"Multireddit bearbeiten"</string>
|
||||
<string name="delete_multi_reddit">"Multireddit löschen"</string>
|
||||
<string name="edit_multi_reddit">Multicommunity bearbeiten</string>
|
||||
<string name="delete_multi_reddit">Multicommunity löschen</string>
|
||||
<string name="n_awards">"%1$d Auszeichnungen"</string>
|
||||
<string name="one_award">"1 Auszeichnung"</string>
|
||||
<string name="report">"Melden"</string>
|
||||
@@ -822,7 +822,7 @@ Beispiel: DeinPasswort:123456"</string>
|
||||
<string name="settings_more_tabs_summary">"Mehr Reiter"</string>
|
||||
<string name="settings_more_tabs_info_summary">"Die folgenden Optionen zu aktivieren, kann zu ungewollten Verhalten führen:
|
||||
Reiter könnten den Inhalt verlieren, wenn zu anderen gewechselt wird. Selbes Verhalten wie beim Neuladen der Seite."</string>
|
||||
<string name="settings_more_tabs_show_favorite_subscribed_communities_title">"Favoriten der abonnierten Subreddits anzeigen"</string>
|
||||
<string name="settings_more_tabs_show_favorite_subscribed_communities_title">Favoriten der abonnierten Communities anzeigen</string>
|
||||
<string name="settings_more_tabs_show_subscribed_communities_title">"Abonnierte Subreddits anzeigen"</string>
|
||||
<string name="settings_download_location_title">"Downloadpfad"</string>
|
||||
<string name="settings_image_download_location_title">"Downloadpfad für Bilder"</string>
|
||||
@@ -855,7 +855,7 @@ Reiter könnten den Inhalt verlieren, wenn zu anderen gewechselt wird. Selbes Ve
|
||||
<!-- Fuzzy -->
|
||||
<string name="settings_data_saving_mode_info_summary">"Im Datensparmodus:
|
||||
Vorschaubilder haben eine geringere Auflösung.
|
||||
Reddit-Videos haben eine geringere Auflösung.
|
||||
Lemmy-Videos haben eine geringere Auflösung.
|
||||
Automatisches Abspielen von Videos ist deaktiviert."</string>
|
||||
<string name="settings_translation_title">"Übersetzung"</string>
|
||||
<string name="settings_translation_summary">"Übersetze diese App auf POEditor. Danke an alle Beitragenden."</string>
|
||||
@@ -933,10 +933,10 @@ Nachricht: %2$s"</string>
|
||||
<string name="filtered_posts_activity_subtitle">"Gefilterte Beiträge"</string>
|
||||
<string name="post_filter_preference_activity_label">"Beitragsfilter"</string>
|
||||
<string name="search_users_result_activity_label">"Benutzer"</string>
|
||||
<string name="multireddit_selection_activity_label">"Wähle ein Multireddit"</string>
|
||||
<string name="multireddit_selection_activity_label">Wähle eine Multicommunity</string>
|
||||
<string name="action_save_to_database">"In der Datenbank speichern"</string>
|
||||
<string name="action_read_all_messages">"Alle Nachrichten lesen"</string>
|
||||
<string name="action_add_to_multireddit">"Zum Multireddit hinzufügen"</string>
|
||||
<string name="action_add_to_multireddit">Zum Multicommunity hinzufügen</string>
|
||||
<string name="search_only_communities_hint">"Subreddits durchsuchen"</string>
|
||||
<string name="search_only_users_hint">"Benutzer durchsuchen"</string>
|
||||
<string name="post_type_gif">"GIF"</string>
|
||||
@@ -995,19 +995,19 @@ Nachricht: %2$s"</string>
|
||||
<string name="post_filter_usage_user_all">"Benutzer"</string>
|
||||
|
||||
<!-- This is inconsistant. Sometimes we call it Multireddit, other times MultiReddit. -->
|
||||
<string name="post_filter_usage_multireddit">"Multireddit: %1$s"</string>
|
||||
<string name="post_filter_usage_multireddit">Multicommunity: %1$s</string>
|
||||
|
||||
<!-- This is inconsistant. Sometimes we call it Multireddit, other times MultiReddit. -->
|
||||
<string name="post_filter_usage_multireddit_all">"Multireddit"</string>
|
||||
<string name="post_filter_usage_multireddit_all">Multicommunity</string>
|
||||
<string name="post_filter_usage_search">"Suche"</string>
|
||||
<string name="community">"Subreddit"</string>
|
||||
<string name="user">"Benutzer"</string>
|
||||
<string name="edit_post_filter_name_of_usage_info">"Leer lassen, um diesen Beitragsfilter auf alle Subreddits / Benutzer / Multireddits anzuwenden"</string>
|
||||
<string name="edit_post_filter_name_of_usage_info">Leer lassen, um diesen Beitragsfilter auf alle Subreddits / Benutzer / Multicommunities anzuwenden</string>
|
||||
<string name="read_all_messages_time_limit">"Du machst das zu oft hintereinander. Versuche es später noch einmal. Dies ist eine Beschränkung der Reddit-API."</string>
|
||||
<string name="read_all_messages_success">"Alle Nachrichten erfolgreich als gelesen markiert"</string>
|
||||
<string name="read_all_messages_failed">"Kann nicht alle Nachrichten als gelesen markieren"</string>
|
||||
<string name="add_community_or_user_to_multireddit_success">"%1$s wurde zu Multireddit %2$s hinzugefügt"</string>
|
||||
<string name="add_community_or_user_to_multireddit_failed">"Konnte %1$s nicht zu Multireddit %2$s hinzufügen"</string>
|
||||
<string name="add_community_or_user_to_multireddit_success">%1$s wurde zu Multicommunity %2$s hinzugefügt</string>
|
||||
<string name="add_community_or_user_to_multireddit_failed">Konnte %1$s nicht zu Multicommunity %2$s hinzufügen</string>
|
||||
<string name="choose_a_user">"Wähle einen Benutzer"</string>
|
||||
<string name="settings_click_to_show_media_in_gallery_layout">"Antippen, um die Medien in der Galerie-Ansicht anzuzeigen"</string>
|
||||
<string name="settings_hide_post_type">"Beitragsart verstecken"</string>
|
||||
@@ -1097,8 +1097,8 @@ Nachricht: %2$s"</string>
|
||||
<string name="settings_show_only_one_comment_level_indicator">"Nur einen Indikator für die Kommentarebene anzeigen"</string>
|
||||
<string name="save_comment">"Speichern"</string>
|
||||
<string name="unsave_comment">"Nicht mehr speichern"</string>
|
||||
<string name="copy_multi_reddit_path">"Pfad des Multireddit kopieren"</string>
|
||||
<string name="copy_multi_reddit_path_failed">"Pfad des Multireddit kann nicht kopiert werden"</string>
|
||||
<string name="copy_multi_reddit_path">Pfad der Multicommunity kopieren</string>
|
||||
<string name="copy_multi_reddit_path_failed">Pfad der Multicommunity kann nicht kopiert werden</string>
|
||||
<string name="crash_reports_deleted">"Absturzmeldungen werden gelöscht"</string>
|
||||
<string name="disable_nsfw_forever_message">"Wenn du diese Option aktivierst, wird NSFW dauerhaft deaktiviert, egal ob die NSFW-Option ein- oder ausgeschaltet ist. Diese Option ist irreversibel, wenn du NSFW wieder einschalten willst, müssen die Daten der App gelöscht werden.
|
||||
|
||||
@@ -1125,9 +1125,9 @@ Benenne diese Themen sonst neu."</string>
|
||||
<string name="settings_enable_material_you_summary">"Infinity Theme ihrem Hintergrund anpassen"</string>
|
||||
<string name="settings_apply_material_you_title">"Material You anwenden"</string>
|
||||
<string name="settings_apply_material_you_summary">"Sollte Infinity den Theme nicht gewechselt haben"</string>
|
||||
<string name="settings_more_tabs_show_favorite_multireddits_title">"Multireddits Favoriten anzeigen"</string>
|
||||
<string name="settings_more_tabs_show_multireddits_title">"Multireddits anzeigen"</string>
|
||||
<string name="settings_collapse_reddit_section_title">"Sektion für Reddit zusammenklappen"</string>
|
||||
<string name="settings_more_tabs_show_favorite_multireddits_title">Multicommunities Favoriten anzeigen</string>
|
||||
<string name="settings_more_tabs_show_multireddits_title">Multicommunities anzeigen</string>
|
||||
<string name="settings_collapse_reddit_section_title">Sektion für Lemmy zusammenklappen</string>
|
||||
<string name="settings_video_player_automatic_landscape_orientation">"Automatisch zum Querformat im Videospieler wechseln"</string>
|
||||
<string name="settings_remember_muting_option_in_post_feed">"Stummschalt-Option im Beitragsfeed merken"</string>
|
||||
<string name="link_post_layout_auto">"Automatisch"</string>
|
||||
@@ -1190,7 +1190,7 @@ Antippen zum Wiederholen."</string>
|
||||
<string name="title_contains_strings_hint">"Titel: enthält Schlüsselwörter (key1,key2)"</string>
|
||||
<string name="title_contains_regex_hint">"Titel: enthält Regex"</string>
|
||||
<string name="contain_domains_hint">"Domains cont"</string>
|
||||
<string name="anonymous_multireddit_no_community">"Dieses Multireddit hat kein Subreddit!"</string>
|
||||
<string name="anonymous_multireddit_no_community">Dieses Multicommunity hat kein Subreddit!</string>
|
||||
<string name="error_fetching_v_redd_it_video_cannot_get_video_url">"Fehler beim Abrufen von v.redd.it video: Kann Video URL nicht finden"</string>
|
||||
<string name="contain_domain">"Diese Domain containen"</string>
|
||||
<string name="lock_screen_text">"Ruhig Brauner!!!"</string>
|
||||
@@ -1256,13 +1256,13 @@ Antippen zum Wiederholen."</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">"Reddit 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>
|
||||
<string name="settings_post_feed_max_resolution_warning_title">"Wert erhöhen um Vorschau in höherer Qualität zu zeigen, aber die App kann unerwartet abstürzen."</string>
|
||||
<string name="settings_post_feed_max_resolution_title">"Beitragsvorschau maximale Auflösung (Höhe * Breite)"</string>
|
||||
<string name="settings_reddit_video_default_resolution">"Reddit Video Standardauflösung"</string>
|
||||
<string name="settings_reddit_video_default_resolution">Lemmy Video Standardauflösung</string>
|
||||
<string name="select_a_ttf_font">"ttf Schriftart Datei auswählen"</string>
|
||||
<string name="unable_to_get_font_file">"Schriftart konnte nicht geladen werden"</string>
|
||||
<string name="unable_to_load_font">"Benutzerdefinierte Schriftart konnte nicht geladen werden"</string>
|
||||
|
||||
@@ -175,7 +175,7 @@ Toca para reintentar."</string>
|
||||
<string name="choose_a_communities">"Elige un subreddit"</string>
|
||||
<string name="rules">"Reglas"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddits"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Usuarios"</string>
|
||||
<string name="multi_reddits">"Multireddits"</string>
|
||||
<string name="bottom_sheet_post_text">"Texto"</string>
|
||||
@@ -401,7 +401,7 @@ Premio means prize, so it's better suited the first word instead of the second o
|
||||
<string name="settings_reddit_account_title">"Cuenta de Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Compartir"</string>
|
||||
<string name="settings_share_summary">"Si te gusta esta aplicación ¡Compártela!"</string>
|
||||
<string name="settings_version_title">"Infinity for Reddit"</string>
|
||||
|
||||
@@ -177,9 +177,9 @@
|
||||
<string name="choose_a_communities">"Choisir une subreddit"</string>
|
||||
<string name="rules">"Règles"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddits"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Utilisateurs"</string>
|
||||
<string name="multi_reddits">"Multireddits"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Texte"</string>
|
||||
<string name="bottom_sheet_post_link">"Lien"</string>
|
||||
<string name="bottom_sheet_post_image">"Image"</string>
|
||||
@@ -439,8 +439,8 @@ peut ne pas fonctionner sur Android 11"</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Compte Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@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>
|
||||
|
||||
@@ -430,7 +430,7 @@ Behavior -->
|
||||
<string name="settings_reddit_account_title">"रैडिट खाता "</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"सबरैडिट "</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"साझा करें "</string>
|
||||
<string name="settings_share_summary">"यदि आप इसका आनंद लेते हैं तो एप्प को अन्य लोगों के साथ साझा करें "</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -400,7 +400,7 @@
|
||||
<string name="settings_reddit_account_title">"Reddit račun"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Podreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Dijeljenje"</string>
|
||||
<string name="settings_share_summary">"Ako Vam se aplikacija sviđa, podijelite ju s drugima"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<string name="settings_reddit_account_title">"Reddit fiók"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Közösség"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Megosztás"</string>
|
||||
<string name="settings_share_summary">"Ha tetszik az app oszd meg másokkal is"</string>
|
||||
<string name="settings_version_title">"Infiniti Reddithez"</string>
|
||||
|
||||
@@ -164,9 +164,9 @@ Tocca per riprovare."</string>
|
||||
<string name="choose_a_communities">"Scegli un subreddit"</string>
|
||||
<string name="rules">"Regole"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddit"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Utenti"</string>
|
||||
<string name="multi_reddits">"MultiReddit"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Testo"</string>
|
||||
<string name="bottom_sheet_post_link">"Link"</string>
|
||||
<string name="bottom_sheet_post_image">"Immagine"</string>
|
||||
@@ -373,8 +373,8 @@ Tocca per riprovare."</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Account Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Condividi"</string>
|
||||
<string name="settings_share_summary">"Condividi questa app con altre persone se la apprezzi"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -432,8 +432,8 @@
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Redditアカウント"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"共有"</string>
|
||||
<string name="settings_share_summary">"このアプリが気に入ったようでしたら、ぜひ他の方々にもご紹介ください"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -166,9 +166,9 @@ Druk om opnieuw te proberen."</string>
|
||||
<string name="choose_a_communities">"Kies een subreddit"</string>
|
||||
<string name="rules">"Regels"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddits"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Gebruikers"</string>
|
||||
<string name="multi_reddits">"MultiReddits"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Tekst"</string>
|
||||
<string name="bottom_sheet_post_link">"Link"</string>
|
||||
<string name="bottom_sheet_post_image">"Afbeelding"</string>
|
||||
@@ -383,8 +383,8 @@ Druk om opnieuw te proberen."</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Reddit-account"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Delen"</string>
|
||||
<string name="settings_share_summary">"Deel deze app met anderen als je hem graag gebruikt"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -378,8 +378,8 @@
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Konto Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Udostępnij"</string>
|
||||
<string name="settings_share_summary">"Udostępnij tą aplikację, jeśli ci się ona podoba"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -173,9 +173,9 @@ Toque para tentar novamente."</string>
|
||||
<string name="choose_a_communities">"Escolha um subreddit"</string>
|
||||
<string name="rules">"Regras"</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Subreddits"</string>
|
||||
<string name="communities">Communities</string>
|
||||
<string name="users">"Usuários"</string>
|
||||
<string name="multi_reddits">"Multireddits"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Texto"</string>
|
||||
<string name="bottom_sheet_post_link">"Link"</string>
|
||||
<string name="bottom_sheet_post_image">"Imagem"</string>
|
||||
@@ -382,8 +382,8 @@ Toque para tentar novamente."</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Conta Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Compartilhar"</string>
|
||||
<string name="settings_share_summary">"Compartilhe esse App com outros se você está gostando dele"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -171,7 +171,7 @@ Toque para tentar novamente."</string>
|
||||
<string name="post_link_hint">"URL"</string>
|
||||
<string name="communities">"Comunidades"</string>
|
||||
<string name="users">"Utilizadores"</string>
|
||||
<string name="multi_reddits">"MultiReddits"</string>
|
||||
<string name="multi_reddits">MultiCommunity</string>
|
||||
<string name="bottom_sheet_post_text">"Texto"</string>
|
||||
<string name="bottom_sheet_post_link">"Ligação"</string>
|
||||
<string name="bottom_sheet_post_image">"Imagem"</string>
|
||||
@@ -388,7 +388,7 @@ Toque para tentar novamente."</string>
|
||||
<string name="settings_reddit_account_title">"Conta do Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Comunidade"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Partilhar"</string>
|
||||
<string name="settings_share_summary">"Se aprecia esta aplicação, partilhe-a com outros"</string>
|
||||
<string name="settings_version_title">"Infinity For Reddit"</string>
|
||||
|
||||
@@ -402,8 +402,8 @@ Atinge pentru a reîncerca."</string>
|
||||
<string name="settings_email_summary">"docilealligator.app@gmail.com"</string>
|
||||
<string name="settings_reddit_account_title">"Cont Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Subreddit"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_title">Community</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Distribuie"</string>
|
||||
<string name="settings_share_summary">"Distribuie această aplicație altor persoane dacă îți place"</string>
|
||||
<string name="settings_version_title">"Infinit Pentru Reddit"</string>
|
||||
|
||||
@@ -389,7 +389,7 @@
|
||||
<string name="settings_reddit_account_title">"Аккаунт Reddit"</string>
|
||||
<string name="settings_reddit_account_summary">"u/Hostilenemy"</string>
|
||||
<string name="settings_community_title">"Сабреддит"</string>
|
||||
<string name="settings_community_summary">"r/Infinity_For_Reddit"</string>
|
||||
<string name="settings_community_summary">!infinityforlemmy@lemdro.id</string>
|
||||
<string name="settings_share_title">"Поделиться"</string>
|
||||
<string name="settings_share_summary">"Поделитесь этим приложением с другими людьми, если оно вам нравится"</string>
|
||||
<string name="settings_version_title">"Infinity для Reddit"</string>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user